ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

navigation base controller output

asked 2011-05-26 01:22:02 -0500

sam gravatar image

updated 2011-05-27 23:37:57 -0500

Hi, I have wrote the following package totally the same as tutorials:robot_setup_tf,laser_scan_publisher,odometry_publisher. And I also wrote the following base controller package but when I run by roslaunch, it seems not call the callback. the base controller code:

  #include <ros/ros.h>
  #include <geometry_msgs/Twist.h>
  #include <iostream>

  using namespace std;

  void cmdVelReceived(const geometry_msgs::Twist::ConstPtr& cmd_vel);

  int main(int argc,char **argv)
    cout << "123" << endl;
    ros::init(argc, argv, "robot_setup_base");
      ros::Subscriber cmd_vel_sub;
      ros::NodeHandle node_;
      cmd_vel_sub =       node_.subscribe<geometry_msgs::Twist>("robot_0/cmd_vel", 1,       boost::bind(cmdVelReceived,_1));
    return 0;

  void cmdVelReceived(const geometry_msgs::Twist::ConstPtr& cmd_vel)
    cout << "x=" << cmd_vel->linear.x << endl;
    cout << "y=" << cmd_vel->linear.y << endl;
    cout << "theta=" << cmd_vel->angular.z << endl;

And my launch file is


    <master auto="start"/>
    <param name="/use_sim_time" value="true"/>  

    <node pkg="robot_setup_laser" type="laser"       name="sensor_node_name" output="screen">
      <param name="sensor_param" value="param_value" />

    <node pkg="robot_setup_odometry" type="odometry"       name="odom_node" output="screen">
      <param name="odom_param" value="param_value" />

    <node pkg="robot_setup_tf" type="tf_broadcaster"       name="transform_configuration_name" output="screen">
      <param name="transform_configuration_param" value="param_value"       />

    <node pkg="robot_setup_base" type="base" name="base"       output="screen">
      <param name="transform_configuration_param" value="param_value"       />

    <!--- Run AMCL -->
    <include file="$(find amcl)/examples/amcl_diff.launch" />

    <node pkg="map_server" type="map_server" name="map_server"       args="$(find navigation_stage)/stage_config/maps/willow-full.pgm 0.1"       respawn="false" >
      <param name="frame_id" value="/map" />

    <node pkg="stage" type="stageros" name="stageros" args="$(optenv       ROS_STAGE_GRAPHICS -g) $(find       navigation_stage)/stage_config/worlds/" respawn="false">
      <param name="base_watchdog_timeout" value="0.2"/>

    <!-- Throttle the voxel grid that is being published for rviz -->
    <node ns="move_base_node/local_costmap"       name="voxel_grid_throttle" pkg="topic_tools" type="throttle" args="messages       voxel_grid 3.0 voxel_grid_throttled" />

    <group ns="robot_0">
      <param name="tf_prefix" value="robot_0" />
      <node pkg="move_base" type="move_base" respawn="false"       name="move_base_node" output="screen">
        <remap from="map" to="/map" />
        <param name="controller_frequency" value="10.0" />
        <rosparam file="$(find       navigation_stage)/move_base_config/costmap_common_params.yaml"       command="load" ns="global_costmap" />
        <rosparam file="$(find       navigation_stage)/move_base_config/costmap_common_params.yaml"       command="load" ns="local_costmap" />
        <rosparam file="$(find       navigation_stage)/move_base_config/local_costmap_params.yaml"       command="load" />
        <rosparam file="$(find       navigation_stage)/move_base_config/global_costmap_params.yaml"       command="load" />
        <rosparam file="$(find       navigation_stage)/move_base_config/base_local_planner_params.yaml"       command="load" />

        <node pkg="fake_localization" type="fake_localization"       name="fake_localization" respawn="false">

    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find       navigation_stage)/multi_robot.vcg" />

  And the output:

  sam@sam-M51Kr:~/code/ros/ira_navigation/nav_core/launch$ roslaunch       robot_conf.launch 
  ... logging to       /home/sam/.ros/log/e84ff146-891a-11e0-93d5-0015afe5d6b9/roslaunch-sam-M51      Kr-4359.log
  Checking log directory for disk usage. This may take awhile.
  Press Ctrl-C to interrupt
  Done checking log file disk usage. Usage is <1GB.

  WARNING: ignoring defunct <master /> tag
  started roslaunch server http://sam-M51Kr:41097/


   * /use_sim_time
   * /amcl/gui_publish_rate
   *       /robot_0/move_base_node/TrajectoryPlannerROS/min_in_place_rotational_vel
   * /base/transform_configuration_param
   * /robot_0/move_base_node/TrajectoryPlannerROS/y_vels
   * /robot_0/move_base_node/local_costmap/unknown_threshold
   * /amcl/recovery_alpha_slow
   * /amcl/laser_z_short
   * /robot_0/move_base_node/local_costmap/origin_y
   * /robot_0/move_base_node/TrajectoryPlannerROS/min_vel_x
   * /robot_0/move_base_node/TrajectoryPlannerROS/sim_time
   * /robot_0/move_base_node/TrajectoryPlannerROS/heading_lookahead
   * /robot_0/move_base_node/global_costmap/base_scan/data_type
   * /robot_0/move_base_node/global_costmap/static_map
   * /amcl/laser_z_rand
   * /robot_0/move_base_node/global_costmap/mark_threshold
   * /robot_0/move_base_node/local_costmap/mark_threshold ...
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-05-26 01:33:05 -0500

Eric Perko gravatar image

updated 2011-05-26 02:49:33 -0500

In order for your cmd_vel callback to be called, you will have to have some node actually publishing to the cmd_vel topic. This could be a teleoperation node if you are driving around manually with a joystick or an autonomous controller like move_base, which is part of the ROS Navigation stack.

To really simply test your code, you could try the following in another terminal while your base controller is running:

rostopic pub /cmd_vel geometry_msgs/Twist -r 20 '[1,0,0]' '[0,0,0.5]'

That will publish a Twist message corresponding to 1 meter/s of forwards motion and 0.5 rad/s of yaw at a rate of 20Hz.

You can also verify that a publisher is working by doing:

rostopic echo /cmd_vel

If you don't see any output from rostopic echo, then you should not expect a callback on the topic you echoed to be called.

Update to address followup questions

I'll address each individually:

  1. A properly configured move_base setup will output commands on the cmd_vel topic, as I'm guessing you expected. However, you have some tf errors that I'll address later that likely are preventing the navigation stack from getting very far in it's initialization process (or otherwise causing it to not output velocity commands). To check if the navigation stack is outputting velocity commands, you use rostopic echo as mentioned above. If I recall correctly, you'll also have to give the navigation stack a goal before it will output any commands. You can do that from rviz pretty easily; see the tutorial Using rviz with the Navigation Stack for details on how to setup a good visualization to use while running navigation.

  2. A geometry_msgs/Twist contains 6 fields (once expanded; see the online documentation for exact field names), hence the 6 different input values for rostopic pub (details on that command line syntax can be found at the YAML Commandline wiki page). Since you only output 3 of those 6 values in your callback (linear.x, linear.y, angular.z), you only see 3 values per message in the output from your node.

  3. It means that, as you have it configured, the navigation stack (specifically the costmaps) expect there to be a transform available between the /odom reference frame and the /base_footprint frame. If you are using different names for either of those reference frames, your configuration files will need to be updated to reflect that. You can see what available paths there are in the transform tree by running

    rosrun tf view_frames

    in a terminal while the rest of your code (that should be providing your required tf frames) is running. If you are still unsure about how to fix it after looking at the output of view_frames (a file called frames.pdf in the directory you ran view_frames from), please update your answer to include both frames.pdf and your config files (or links to those files).

edit flag offensive delete link more

answered 2011-05-26 02:18:28 -0500

sam gravatar image

updated 2011-05-27 23:06:44 -0500

Thank you for you suggestion.

edit flag offensive delete link more


@sam: I've updated my answer to reflect these followup questions, but you should edit your original question to include these as followups instead of posting another answer so that this Q&A will be easier to follow in the future. Answers are sorted by # of votes, so the order can change over time.
Eric Perko gravatar imageEric Perko ( 2011-05-26 02:30:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

The deadline to submit a proposal to present at ROSCon 2017 is June 25, 2017. Submit yours now!

Question Tools

1 follower


Asked: 2011-05-26 01:22:02 -0500

Seen: 1,756 times

Last updated: May 27 '11