从0学习如何map并导航(1-单个机器人建模)

1.main.launch

<launch>
  <param name="/use_sim_time" value="true" />

  <!-- start world -->
  <node name="gazebo" pkg="gazebo_ros" type="gazebo"
   args="$(find a309_room)/worlds/a.world" respawn="false" output="screen" />

  <!-- include our robots -->
  <include file="$(find multiple_turtlebots_sim)/launch/robots.launch"/>

  <!-- load the controllers of WPR1 -->
   <include file="$(find wpr_simulation)/launch/wpr1_controllers.launch"/>

  <!-- Gmapping -->
  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping">
    <param name="base_frame" value="base_footprint"/>
  </node>

  <!-- Rviz -->
  <arg name="model" default="$(find wpr1_bringup)/urdf/wpr1.urdf"/>

  <param name="robot_description" command="$(find xacro)/xacro $(arg model)" />
  <node name="rviz" pkg="rviz" type="rviz" required="true" /> 

  <!-- Axes Velcmd -->
  <param name="axis_linear" value="1" type="int"/>
  <param name="axis_angular" value="0" type="int"/>
  <param name="scale_linear" value="0.5" type="double"/>
  <param name="scale_angular" value="1" type="double"/>
  <node pkg="wpr1_bringup" type="wpr1_js_velcmd" name="teleop"/>


</launch>

1.1 启动仿真环境

  <!-- start world -->
  <node name="gazebo" pkg="gazebo_ros" type="gazebo"
   args="$(find a309_room)/worlds/a.world" respawn="false" output="screen" />

这里的世界,是使用ros2的traffic-editor创造了一个简单世界

1.2 加载启明机器人

  <!-- include our robots -->
  <include file="$(find multiple_turtlebots_sim)/launch/robots.launch"/>

robots.launch:

<launch>
  <!-- No namespace here as we will share this description.
       Access with slash at the beginning -->

  <!-- BEGIN ROBOT 1-->
  <group ns="/wpr1">
    <!-- <param name="tf_prefix" value="robot1_tf" /> -->
    <include file="$(find multiple_turtlebots_sim)/launch/one_robot.launch" >
      <arg name="init_pose" value="-x 6.799 -y -6.955 -z 0" />
      <arg name="robot_name"  value="Robot1" />
    </include>
  </group>
    
</launch>

1.robot_description:为启动rviz时,机器人的各个功能提供文件
2.加载gazebo中的机器人one_robot.launch

tf_prefix仅在加载多机器人时用到:
在这里插入图片描述

one_robot.launch

<launch>
    <arg name="robot_name"/>
    <arg name="init_pose"/>

    <node name="spawn_minibot_model" pkg="gazebo_ros" type="spawn_model"
     args="-file $(find wpr_simulation)/models/wpr1.model $(arg init_pose) -urdf -model $(arg robot_name)"
     respawn="false" output="screen" />

    <node name="rviz" pkg="rviz" type="rviz"  />
</launch>

在gazebo中加载wpr1.model(机器人的模型)

1.3 添加机器人控制

  <!-- load the controllers of WPR1 -->
   <include file="$(find wpr_simulation)/launch/wpr1_controllers.launch"/>

这里是针对gazebo环境中的。
wpr1_controllers.launch

<launch>

   <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find wpr_simulation)/config/wpr1_control.yaml" command="load"/>

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"  output="screen" ns="/wpr1"  args=
  "joint_state_controller
    base_to_torso_position_controller
    torso_to_upperarm_position_controller
    upperarm_to_forearm_position_controller
    forearm_to_palm_position_controller
    palm_left_finger_position_controller
    left_finger_tip_position_controller
    palm_right_finger_position_controller
    right_finger_tip_position_controller"/>

  <!-- convert joint states to TF transforms for rviz, etc -->
  <param name="wpr1_description" textfile="$(find wpr_simulation)/models/wpr1.model" />
  <node name="gazebo_wpr1_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
    <remap from="robot_description" to="wpr1_description" />
    <remap from="/joint_states" to="/wpr1/joint_states" />
  </node>

  <node name="wpr1_sim" pkg="wpr_simulation" type="wpr1_sim" output="screen"/>
  
</launch>

对于启明机器人而言:controller_spawner,对应的是机械臂、深度相机部分,当修改ns为robot1(非原来的wpr1后)会变为:

在这里插入图片描述

1.4 添加建图部分

<!-- Gmapping -->
  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping">
    <param name="base_frame" value="base_footprint"/>
  </node>

必须添加此部分

在这里插入图片描述
机器人才会如此显示,不然只有一个白色的机器人(无slam部分!)
在这里插入图片描述
rviz此部分也会正常的tranform,不然就是error!

1.5 添加rviz部分

  <!-- Rviz -->
  <arg name="model" default="$(find wpr1_bringup)/urdf/wpr1.urdf"/>

  <param name="robot_description" command="$(find xacro)/xacro $(arg model)" />
  <node name="rviz" pkg="rviz" type="rviz" required="true" /> 

1.在rviz中加载urdf文件。
2.启动rviz

1.6添加控制部分

  <!-- Axes Velcmd -->
  <param name="axis_linear" value="1" type="int"/>
  <param name="axis_angular" value="0" type="int"/>
  <param name="scale_linear" value="0.5" type="double"/>
  <param name="scale_angular" value="1" type="double"/>
  <node pkg="wpr1_bringup" type="wpr1_js_velcmd" name="teleop"/>

2 演示

在这里插入图片描述

3.控制机器人建图

 rosrun teleop_twist_keyboard teleop_twist_keyboard.py /cmd_vel:=/robot1/cmd_vel

gmapping负责建图,在rviz内建完图后
在这里插入图片描述
保存:

rz@rz:~/test7-make-map/src/map$ rosrun map_server map_saver -f 309

在这里插入图片描述

3.1 正常时候的主题

/clicked_point
/clock
/cmd_vel
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/kinect2/hd/camera_info
/kinect2/hd/image_color_rect
/kinect2/hd/image_color_rect/compressed
/kinect2/hd/image_color_rect/compressed/parameter_descriptions
/kinect2/hd/image_color_rect/compressed/parameter_updates
/kinect2/hd/image_color_rect/compressedDepth
/kinect2/hd/image_color_rect/compressedDepth/parameter_descriptions
/kinect2/hd/image_color_rect/compressedDepth/parameter_updates
/kinect2/hd/image_color_rect/theora
/kinect2/hd/image_color_rect/theora/parameter_descriptions
/kinect2/hd/image_color_rect/theora/parameter_updates
/kinect2/hd/parameter_descriptions
/kinect2/hd/parameter_updates
/kinect2/qhd/camera_info
/kinect2/qhd/image_color_rect
/kinect2/qhd/image_color_rect/compressed
/kinect2/qhd/image_color_rect/compressed/parameter_descriptions
/kinect2/qhd/image_color_rect/compressed/parameter_updates
/kinect2/qhd/image_color_rect/compressedDepth
/kinect2/qhd/image_color_rect/compressedDepth/parameter_descriptions
/kinect2/qhd/image_color_rect/compressedDepth/parameter_updates
/kinect2/qhd/image_color_rect/theora
/kinect2/qhd/image_color_rect/theora/parameter_descriptions
/kinect2/qhd/image_color_rect/theora/parameter_updates
/kinect2/qhd/parameter_descriptions
/kinect2/qhd/parameter_updates
/kinect2/qhd/points
/kinect2/sd/camera_info
/kinect2/sd/depth/camera_info
/kinect2/sd/image_depth_rect
/kinect2/sd/image_ir_rect
/kinect2/sd/image_ir_rect/compressed
/kinect2/sd/image_ir_rect/compressed/parameter_descriptions
/kinect2/sd/image_ir_rect/compressed/parameter_updates
/kinect2/sd/image_ir_rect/compressedDepth
/kinect2/sd/image_ir_rect/compressedDepth/parameter_descriptions
/kinect2/sd/image_ir_rect/compressedDepth/parameter_updates
/kinect2/sd/image_ir_rect/theora
/kinect2/sd/image_ir_rect/theora/parameter_descriptions
/kinect2/sd/image_ir_rect/theora/parameter_updates
/kinect2/sd/parameter_descriptions
/kinect2/sd/parameter_updates
/kinect2/sd/points
/map
/map_metadata
/map_updates
/move_base/GlobalPlanner/plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base_simple/goal
/odom
/particlecloud
/rosout
/rosout_agg
/scan
/slam_gmapping/entropy
/tf
/tf_static
/visualization_marker
/visualization_marker_array
/waypoints_marker
/waypoints_marker_array
/wpr1/base_to_torso_position_controller/command
/wpr1/ctrl
/wpr1/forearm_to_palm_position_controller/command
/wpr1/gazebo_ros_control/pid_gains/base_to_torso/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/base_to_torso/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_updates
/wpr1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_descriptions
/wpr1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_updates
/wpr1/joint_ctrl
/wpr1/joint_states
/wpr1/left_finger_tip_position_controller/command
/wpr1/palm_left_finger_position_controller/command
/wpr1/palm_right_finger_position_controller/command
/wpr1/pose_diff
/wpr1/right_finger_tip_position_controller/command
/wpr1/torso_to_upperarm_position_controller/command
/wpr1/upperarm_to_forearm_position_controller/command

3.2 添加group ns=robot1 后的主题

在这里插入图片描述

/clicked_point
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/kinect2/qhd/points
/map
/map_metadata
/map_updates
/move_base/GlobalPlanner/plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base_simple/goal
/odom
/particlecloud
/robot1/cmd_vel
/robot1/joint_states
/robot1/kinect2/hd/camera_info
/robot1/kinect2/hd/image_color_rect
/robot1/kinect2/hd/image_color_rect/compressed
/robot1/kinect2/hd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/hd/image_color_rect/compressedDepth
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/hd/image_color_rect/theora
/robot1/kinect2/hd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/theora/parameter_updates
/robot1/kinect2/hd/parameter_descriptions
/robot1/kinect2/hd/parameter_updates
/robot1/kinect2/qhd/camera_info
/robot1/kinect2/qhd/image_color_rect
/robot1/kinect2/qhd/image_color_rect/compressed
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/qhd/image_color_rect/compressedDepth
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/qhd/image_color_rect/theora
/robot1/kinect2/qhd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/theora/parameter_updates
/robot1/kinect2/qhd/parameter_descriptions
/robot1/kinect2/qhd/parameter_updates
/robot1/kinect2/sd/camera_info
/robot1/kinect2/sd/depth/camera_info
/robot1/kinect2/sd/image_depth_rect
/robot1/kinect2/sd/image_ir_rect
/robot1/kinect2/sd/image_ir_rect/compressed
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_updates
/robot1/kinect2/sd/image_ir_rect/compressedDepth
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_updates
/robot1/kinect2/sd/image_ir_rect/theora
/robot1/kinect2/sd/image_ir_rect/theora/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/theora/parameter_updates
/robot1/kinect2/sd/parameter_descriptions
/robot1/kinect2/sd/parameter_updates
/robot1/kinect2/sd/points
/robot1/odom
/robot1/scan
/rosout
/rosout_agg
/scan
/slam_gmapping/entropy
/tf
/tf_static
/visualization_marker
/visualization_marker_array
/waypoints_marker
/waypoints_marker_array
/wpr1/base_to_torso_position_controller/command
/wpr1/ctrl
/wpr1/forearm_to_palm_position_controller/command
/wpr1/joint_ctrl
/wpr1/left_finger_tip_position_controller/command
/wpr1/palm_left_finger_position_controller/command
/wpr1/palm_right_finger_position_controller/command
/wpr1/pose_diff
/wpr1/right_finger_tip_position_controller/command
/wpr1/torso_to_upperarm_position_controller/command
/wpr1/upperarm_to_forearm_position_controller/command

可以观察到gazebo_ros_control莫名消失,kinetic部分前面多了robot1。

3.3 修改controller_spawner的ns后的主题

/clicked_point
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/kinect2/qhd/points
/map
/map_metadata
/map_updates
/move_base/GlobalPlanner/plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base_simple/goal
/odom
/particlecloud
/robot1/cmd_vel
/robot1/joint_states
/robot1/kinect2/hd/camera_info
/robot1/kinect2/hd/image_color_rect
/robot1/kinect2/hd/image_color_rect/compressed
/robot1/kinect2/hd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/hd/image_color_rect/compressedDepth
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/hd/image_color_rect/theora
/robot1/kinect2/hd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/theora/parameter_updates
/robot1/kinect2/hd/parameter_descriptions
/robot1/kinect2/hd/parameter_updates
/robot1/kinect2/qhd/camera_info
/robot1/kinect2/qhd/image_color_rect
/robot1/kinect2/qhd/image_color_rect/compressed
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/qhd/image_color_rect/compressedDepth
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/qhd/image_color_rect/theora
/robot1/kinect2/qhd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/theora/parameter_updates
/robot1/kinect2/qhd/parameter_descriptions
/robot1/kinect2/qhd/parameter_updates
/robot1/kinect2/sd/camera_info
/robot1/kinect2/sd/depth/camera_info
/robot1/kinect2/sd/image_depth_rect
/robot1/kinect2/sd/image_ir_rect
/robot1/kinect2/sd/image_ir_rect/compressed
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_updates
/robot1/kinect2/sd/image_ir_rect/compressedDepth
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_updates
/robot1/kinect2/sd/image_ir_rect/theora
/robot1/kinect2/sd/image_ir_rect/theora/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/theora/parameter_updates
/robot1/kinect2/sd/parameter_descriptions
/robot1/kinect2/sd/parameter_updates
/robot1/kinect2/sd/points
/robot1/odom
/robot1/scan
/rosout
/rosout_agg
/scan
/slam_gmapping/entropy
/tf
/tf_static
/visualization_marker
/visualization_marker_array
/waypoints_marker
/waypoints_marker_array
/wpr1/base_to_torso_position_controller/command
/wpr1/ctrl
/wpr1/forearm_to_palm_position_controller/command
/wpr1/joint_ctrl
/wpr1/left_finger_tip_position_controller/command
/wpr1/palm_left_finger_position_controller/command
/wpr1/palm_right_finger_position_controller/command
/wpr1/pose_diff
/wpr1/right_finger_tip_position_controller/command
/wpr1/torso_to_upperarm_position_controller/command
/wpr1/upperarm_to_forearm_position_controller/command

观察到与3.2无差别

3.4修改wpr1_control.yaml的第一行,去掉wpr1后,主题一样无差别

3.5修改wpr1.model的最后一部分的robotnamespace

将其去掉后
在这里插入图片描述
惊奇地发现rviz出现了新的变化!
在这里插入图片描述
启明机器人有了颜色,意味着各部件加载成功?但是激光未加载啊!
且主题变化:

/clicked_point
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/kinect2/qhd/points
/map
/map_metadata
/map_updates
/move_base/GlobalPlanner/plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base_simple/goal
/odom
/particlecloud
/robot1/base_to_torso_position_controller/command
/robot1/cmd_vel
/robot1/forearm_to_palm_position_controller/command
/robot1/gazebo_ros_control/pid_gains/base_to_torso/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/base_to_torso/parameter_updates
/robot1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_updates
/robot1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_updates
/robot1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_updates
/robot1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_updates
/robot1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_updates
/robot1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_updates
/robot1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_updates
/robot1/joint_states
/robot1/kinect2/hd/camera_info
/robot1/kinect2/hd/image_color_rect
/robot1/kinect2/hd/image_color_rect/compressed
/robot1/kinect2/hd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/hd/image_color_rect/compressedDepth
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/hd/image_color_rect/theora
/robot1/kinect2/hd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/theora/parameter_updates
/robot1/kinect2/hd/parameter_descriptions
/robot1/kinect2/hd/parameter_updates
/robot1/kinect2/qhd/camera_info
/robot1/kinect2/qhd/image_color_rect
/robot1/kinect2/qhd/image_color_rect/compressed
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/qhd/image_color_rect/compressedDepth
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/qhd/image_color_rect/theora
/robot1/kinect2/qhd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/theora/parameter_updates
/robot1/kinect2/qhd/parameter_descriptions
/robot1/kinect2/qhd/parameter_updates
/robot1/kinect2/sd/camera_info
/robot1/kinect2/sd/depth/camera_info
/robot1/kinect2/sd/image_depth_rect
/robot1/kinect2/sd/image_ir_rect
/robot1/kinect2/sd/image_ir_rect/compressed
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_updates
/robot1/kinect2/sd/image_ir_rect/compressedDepth
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_updates
/robot1/kinect2/sd/image_ir_rect/theora
/robot1/kinect2/sd/image_ir_rect/theora/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/theora/parameter_updates
/robot1/kinect2/sd/parameter_descriptions
/robot1/kinect2/sd/parameter_updates
/robot1/kinect2/sd/points
/robot1/left_finger_tip_position_controller/command
/robot1/odom
/robot1/palm_left_finger_position_controller/command
/robot1/palm_right_finger_position_controller/command
/robot1/right_finger_tip_position_controller/command
/robot1/scan
/robot1/torso_to_upperarm_position_controller/command
/robot1/upperarm_to_forearm_position_controller/command
/rosout
/rosout_agg
/scan
/slam_gmapping/entropy
/tf
/tf_static
/visualization_marker
/visualization_marker_array
/waypoints_marker
/waypoints_marker_array
/wpr1/base_to_torso_position_controller/command
/wpr1/ctrl
/wpr1/forearm_to_palm_position_controller/command
/wpr1/joint_ctrl
/wpr1/left_finger_tip_position_controller/command
/wpr1/palm_left_finger_position_controller/command
/wpr1/palm_right_finger_position_controller/command
/wpr1/pose_diff
/wpr1/right_finger_tip_position_controller/command
/wpr1/torso_to_upperarm_position_controller/command
/wpr1/upperarm_to_forearm_position_controller/command

多出来了gazebo_control

3.6 给建图(gmapping)部分添加ns=/robot1

/clicked_point
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/kinect2/qhd/points
/map
/map_updates
/move_base/GlobalPlanner/plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base_simple/goal
/odom
/particlecloud
/robot1/base_to_torso_position_controller/command
/robot1/cmd_vel
/robot1/forearm_to_palm_position_controller/command
/robot1/gazebo_ros_control/pid_gains/base_to_torso/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/base_to_torso/parameter_updates
/robot1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_updates
/robot1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_updates
/robot1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_updates
/robot1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_updates
/robot1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_updates
/robot1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_updates
/robot1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_updates
/robot1/joint_states
/robot1/kinect2/hd/camera_info
/robot1/kinect2/hd/image_color_rect
/robot1/kinect2/hd/image_color_rect/compressed
/robot1/kinect2/hd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/hd/image_color_rect/compressedDepth
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/hd/image_color_rect/theora
/robot1/kinect2/hd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/theora/parameter_updates
/robot1/kinect2/hd/parameter_descriptions
/robot1/kinect2/hd/parameter_updates
/robot1/kinect2/qhd/camera_info
/robot1/kinect2/qhd/image_color_rect
/robot1/kinect2/qhd/image_color_rect/compressed
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/qhd/image_color_rect/compressedDepth
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/qhd/image_color_rect/theora
/robot1/kinect2/qhd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/theora/parameter_updates
/robot1/kinect2/qhd/parameter_descriptions
/robot1/kinect2/qhd/parameter_updates
/robot1/kinect2/sd/camera_info
/robot1/kinect2/sd/depth/camera_info
/robot1/kinect2/sd/image_depth_rect
/robot1/kinect2/sd/image_ir_rect
/robot1/kinect2/sd/image_ir_rect/compressed
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_updates
/robot1/kinect2/sd/image_ir_rect/compressedDepth
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_updates
/robot1/kinect2/sd/image_ir_rect/theora
/robot1/kinect2/sd/image_ir_rect/theora/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/theora/parameter_updates
/robot1/kinect2/sd/parameter_descriptions
/robot1/kinect2/sd/parameter_updates
/robot1/kinect2/sd/points
/robot1/left_finger_tip_position_controller/command
/robot1/map
/robot1/map_metadata
/robot1/odom
/robot1/palm_left_finger_position_controller/command
/robot1/palm_right_finger_position_controller/command
/robot1/right_finger_tip_position_controller/command
/robot1/scan
/robot1/slam_gmapping/entropy
/robot1/torso_to_upperarm_position_controller/command
/robot1/upperarm_to_forearm_position_controller/command
/rosout
/rosout_agg
/tf
/tf_static
/visualization_marker
/visualization_marker_array
/waypoints_marker
/waypoints_marker_array
/wpr1/base_to_torso_position_controller/command
/wpr1/ctrl
/wpr1/forearm_to_palm_position_controller/command
/wpr1/joint_ctrl
/wpr1/left_finger_tip_position_controller/command
/wpr1/palm_left_finger_position_controller/command
/wpr1/palm_right_finger_position_controller/command
/wpr1/pose_diff
/wpr1/right_finger_tip_position_controller/command
/wpr1/torso_to_upperarm_position_controller/command
/wpr1/upperarm_to_forearm_position_controller/command

主题拥有了robot1/scan
在这里插入图片描述

3.7 删除robot_state_publisher内的参数

删除之前:
在这里插入图片描述

在这里插入图片描述
主题没有报错!
在这里插入图片描述
且主题与删除后保持一致,这应该与rviz的tf相关!得保留这部分的映射。

删除后:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
主题:

/clicked_point
/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/performance_metrics
/gazebo/set_link_state
/gazebo/set_model_state
/initialpose
/kinect2/qhd/points
/move_base/GlobalPlanner/plan
/move_base/global_costmap/costmap
/move_base/global_costmap/costmap_updates
/move_base/global_costmap/footprint
/move_base/local_costmap/costmap
/move_base/local_costmap/costmap_updates
/move_base_simple/goal
/odom
/particlecloud
/robot1/base_to_torso_position_controller/command
/robot1/cmd_vel
/robot1/forearm_to_palm_position_controller/command
/robot1/gazebo_ros_control/pid_gains/base_to_torso/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/base_to_torso/parameter_updates
/robot1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/forearm_to_palm/parameter_updates
/robot1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/left_finger_tip/parameter_updates
/robot1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/palm_left_finger/parameter_updates
/robot1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/palm_right_finger/parameter_updates
/robot1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/right_finger_tip/parameter_updates
/robot1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/torso_to_upperarm/parameter_updates
/robot1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_descriptions
/robot1/gazebo_ros_control/pid_gains/upperarm_to_forearm/parameter_updates
/robot1/joint_states
/robot1/kinect2/hd/camera_info
/robot1/kinect2/hd/image_color_rect
/robot1/kinect2/hd/image_color_rect/compressed
/robot1/kinect2/hd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/hd/image_color_rect/compressedDepth
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/hd/image_color_rect/theora
/robot1/kinect2/hd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/hd/image_color_rect/theora/parameter_updates
/robot1/kinect2/hd/parameter_descriptions
/robot1/kinect2/hd/parameter_updates
/robot1/kinect2/qhd/camera_info
/robot1/kinect2/qhd/image_color_rect
/robot1/kinect2/qhd/image_color_rect/compressed
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressed/parameter_updates
/robot1/kinect2/qhd/image_color_rect/compressedDepth
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/compressedDepth/parameter_updates
/robot1/kinect2/qhd/image_color_rect/theora
/robot1/kinect2/qhd/image_color_rect/theora/parameter_descriptions
/robot1/kinect2/qhd/image_color_rect/theora/parameter_updates
/robot1/kinect2/qhd/parameter_descriptions
/robot1/kinect2/qhd/parameter_updates
/robot1/kinect2/sd/camera_info
/robot1/kinect2/sd/depth/camera_info
/robot1/kinect2/sd/image_depth_rect
/robot1/kinect2/sd/image_ir_rect
/robot1/kinect2/sd/image_ir_rect/compressed
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressed/parameter_updates
/robot1/kinect2/sd/image_ir_rect/compressedDepth
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/compressedDepth/parameter_updates
/robot1/kinect2/sd/image_ir_rect/theora
/robot1/kinect2/sd/image_ir_rect/theora/parameter_descriptions
/robot1/kinect2/sd/image_ir_rect/theora/parameter_updates
/robot1/kinect2/sd/parameter_descriptions
/robot1/kinect2/sd/parameter_updates
/robot1/kinect2/sd/points
/robot1/left_finger_tip_position_controller/command
/robot1/map
/robot1/map_metadata
/robot1/map_updates
/robot1/odom
/robot1/palm_left_finger_position_controller/command
/robot1/palm_right_finger_position_controller/command
/robot1/right_finger_tip_position_controller/command
/robot1/scan
/robot1/slam_gmapping/entropy
/robot1/torso_to_upperarm_position_controller/command
/robot1/upperarm_to_forearm_position_controller/command
/rosout
/rosout_agg
/scan
/tf
/tf_static
/visualization_marker
/visualization_marker_array
/waypoints_marker
/waypoints_marker_array
/wpr1/base_to_torso_position_controller/command
/wpr1/ctrl
/wpr1/forearm_to_palm_position_controller/command
/wpr1/joint_ctrl
/wpr1/left_finger_tip_position_controller/command
/wpr1/palm_left_finger_position_controller/command
/wpr1/palm_right_finger_position_controller/command
/wpr1/pose_diff
/wpr1/right_finger_tip_position_controller/command
/wpr1/torso_to_upperarm_position_controller/command
/wpr1/upperarm_to_forearm_position_controller/command

有问题:
在这里插入图片描述

3.8 调整controller_manager

根据https://answers.ros.org/question/233413/controller-manager-problem-for-multiple-robots-in-simulation/
增加了ns和namespace,然而经检测后,加不加的效果都一样…
还是加上吧
在这里插入图片描述

3.9 增加tf_prefix

增加后:
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
若没有tf_prefix:

在这里插入图片描述
rviz显示正常!
在这里插入图片描述
所以!问题在odom到base_footprint的过程!需要修改一个名称,
让map->robot_tf/odom即可!

3.10 修改gmapping部分,改变节点名称。

但是此部分是正确的!命名空间的名称就应该与tf_prefix一致。
在这里插入图片描述

在这里插入图片描述
但是rviz中机器人依旧显示不正常,且无法建图
在这里插入图片描述

3.11 设置加载机器人到tf的机器人描述的命名空间

  <!-- convert joint states to TF transforms for rviz, etc -->
  <param name="/robot1/wpr1_description" textfile="$(find wpr_simulation)/models/wpr1.model" />
  <!-- 参数设置命名空间前面一定要添加/ -->

之前一定要添加/

3.12设置rviz


在这里插入图片描述

4.机器人导航

catkin_create_pkg my_localizer_launcher
导入my_location.launch

<launch>


  <!-- start world -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find a309_room)/worlds/a.world"/>
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="true"/>
    <arg name="recording" value="false"/>
    <arg name="debug" value="false"/>
  </include>

  <!-- include our robots -->
  <include file="$(find multiple_turtlebots_sim)/launch/robots.launch"/> 
  


  <!-- load the controllers of WPR1 -->
   <include file="$(find wpr_simulation)/launch/wpr1_controllers.launch"/>

  <!-- Run the map server -->
  <node name="map_server" pkg="map_server" type="map_server" args="$(find wpr_simulation)/maps/309.yaml"/>

  <!--- Run AMCL -->
  <include file="$(find wpr1_tutorials)/nav_lidar/amcl_omni.launch" />


  <!-- Rviz -->
  <arg name="model" default="$(find wpr1_bringup)/urdf/wpr1.urdf"/>

  <param name="robot_description" command="$(find xacro)/xacro $(arg model)" />
  <arg name="rvizconfig" default="$(find wpr_simulation)/rviz/nav.rviz" />
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />


  <!--- Run Move_Base -->
  <node pkg="move_base" type="move_base" respawn="false" name="move_base"  output="screen">
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/costmap_common_params.yaml" command="load" ns="global_costmap" />
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/costmap_common_params.yaml" command="load" ns="local_costmap" />
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/local_costmap_params.yaml" command="load" />
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/global_costmap_params.yaml" command="load" />
    <param name="base_global_planner" value="global_planner/GlobalPlanner" /> 
    <param name="use_dijkstra" value="true"/>
    <param name="base_local_planner" value="wpr1_local_planner/Wpr1LocalPlanner" />
    <param name= "controller_frequency" value="30" type="double"/>
  </node>


</launch>

4.1 map_server

  <!-- Run the map server -->
  <node name="map_server" pkg="map_server" type="map_server" args="$(find wpr_simulation)/maps/309.yaml"/>

导入地图

4.2 AMCL

  <!--- Run AMCL -->
  <include file="$(find wpr1_tutorials)/nav_lidar/amcl_omni.launch" />

防碰撞

4.2.1 amcl_omni.launch

<launch>
<node pkg="amcl" type="amcl" name="amcl" output="screen">
  <!-- Publish scans from best pose at a max of 10 Hz -->
  <param name="odom_model_type" value="omni"/>
  <param name="odom_alpha5" value="0.1"/>
  <param name="transform_tolerance" value="0.2" />
  <param name="gui_publish_rate" value="10.0"/>
  <param name="laser_max_beams" value="30"/>
  <param name="min_particles" value="100"/>
  <param name="max_particles" value="1000"/>
  <param name="kld_err" value="0.05"/>
  <param name="kld_z" value="0.99"/>
  <param name="odom_alpha1" value="0.2"/>
  <param name="odom_alpha2" value="0.2"/>
  <!-- translation std dev, m -->
  <param name="odom_alpha3" value="0.8"/>
  <param name="odom_alpha4" value="0.2"/>
  <param name="laser_z_hit" value="0.5"/>
  <param name="laser_z_short" value="0.05"/>
  <param name="laser_z_max" value="0.05"/>
  <param name="laser_z_rand" value="0.5"/>
  <param name="laser_sigma_hit" value="0.2"/>
  <param name="laser_lambda_short" value="0.1"/>
  <param name="laser_lambda_short" value="0.1"/>
  <param name="laser_model_type" value="likelihood_field"/>
  <!-- <param name="laser_model_type" value="beam"/> -->
  <param name="laser_likelihood_max_dist" value="2.0"/>
  <param name="update_min_d" value="0.2"/>
  <param name="update_min_a" value="0.5"/>
  <param name="odom_frame_id" value="odom"/>
  <param name="resample_interval" value="1"/>
  <param name="transform_tolerance" value="0.1"/>
  <param name="recovery_alpha_slow" value="0.0"/>
  <param name="recovery_alpha_fast" value="0.0"/>
</node>
</launch>

一些参数的意义

Modify the content accordingly with your robot:
scan_topic (default: “kobuki/laser/scan”): indicates from which topic the laser data is obtained
base_frame_id (default: “base_link”): Indicates the name of the frame of the center of the mobile base.
odom_frame_id (default: “odom”): Indicates the name of the frame attached to the odometry system.
global_frame_id (default: “map”): Indicates the global frame of reference from which the robot will localize

4.3 move_base

  <!--- Run Move_Base -->
  <node pkg="move_base" type="move_base" respawn="false" name="move_base"  output="screen">
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/costmap_common_params.yaml" command="load" ns="global_costmap" />
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/costmap_common_params.yaml" command="load" ns="local_costmap" />
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/local_costmap_params.yaml" command="load" />
    <rosparam file="$(find wpr1_tutorials)/nav_lidar/global_costmap_params.yaml" command="load" />
    <param name="base_global_planner" value="global_planner/GlobalPlanner" /> 
    <param name="use_dijkstra" value="true"/>
    <param name="base_local_planner" value="wpr1_local_planner/Wpr1LocalPlanner" />
    <param name= "controller_frequency" value="30" type="double"/>
  </node>

4.4rviz界面

在这里插入图片描述

错误

1. gazebo就是加载不出来

命令行:
Waiting for service /gazebo/spawn_urdf_model
在这里插入图片描述
解决:尝试killall gzserver

2.启动后无法控制机器人

2.1

原来:

  <!-- start world -->
  <node name="gazebo" pkg="gazebo_ros" type="gazebo"
   args="$(find a309_room)/worlds/a.world" respawn="false" output="screen" />

仿真环境的问题,将gazebo导入世界的程序改为:

  <!-- start world -->
  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find a309_room)/worlds/a.world"/>
    <arg name="paused" value="false"/>
    <arg name="use_sim_time" value="true"/>
    <arg name="gui" value="true"/>
    <arg name="recording" value="false"/>
    <arg name="debug" value="false"/>
  </include>

就莫名其妙地可以了。hhhh,可能是有些参数,影响控制的部分。

2.2

原:在robots.launch中

  <group ns="wpr1">
    <!-- <param name="tf_prefix" value="robot1_tf" /> -->
    <include file="$(find multiple_turtlebots_sim)/launch/one_robot.launch" >
      <arg name="init_pose" value="-x 6.799 -y -6.955 -z 0" />
      <arg name="robot_name"  value="wpr1" />
    </include>
  </group>

group标签限制了工作空间,去掉group后,可以正常工作了,后期需要添加多机器人时,再填上即可。
在这里插入图片描述

现:

    <!-- <param name="tf_prefix" value="robot1_tf" /> -->
    <include file="$(find multiple_turtlebots_sim)/launch/one_robot.launch" >
      <arg name="init_pose" value="-x 6.799 -y -6.955 -z 0" />
      <arg name="robot_name"  value="wpr1" />
    </include>

在这里插入图片描述
修改前,控制的主题无法传送给gazebo,怀疑是控制的cpp文件的工作空间不同的问题。
keyboard_vel_ctrl.cpp是在默认的工作空间,而group后,修改了工作空间,后期控制多机器人再改,此处先留个尾巴。
修改后,即可控制机器人运动了。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值