1 執行過程
- 1.運行仿真機器人fake_turtlebot.launch:加載機器人模型——啟動機器人仿真器——發布機器人狀態
- 2.運行amcl節點fake_amcl.launch:加載地圖節點map_server——加載move_base節點——加載fake_localization節點(AMCL)
- 3.運行rviz
2 機器人仿真
//fake_turtlebot.launch <launch> <param name="/use_sim_time" value="false" /> <!-- Load the URDF/Xacro model of our robot --> <arg name="urdf_file" default="$(find xacro)/xacro.py '$(find rbx1_description)/urdf/turtlebot.urdf.xacro'" /> <param name="robot_description" command="$(arg urdf_file)" /> <node name="arbotix" pkg="arbotix_python" type="arbotix_driver" output="screen" clear_params="true"> <rosparam file="$(find rbx1_bringup)/config/fake_turtlebot_arbotix.yaml" command="load" /> <param name="sim" value="true"/> </node> <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"> <param name="publish_frequency" type="double" value="20.0" /> </node> </launch>
-
2.1加載機器人模型turtlebot.urdf.xacro,包括:
1.硬件模型turtlebot_hardware.urdf.xacro
2.機器人本體模型turtlebot_body.urdf.xacro
3.標定參數turtlebot_calibration.xacro
4.運動學模型turtlebot_kinect.urdf.xacro
-
2.2 加載arbotix模擬器,即arbotix節點(加載配置文件:fake_turtlebot_arbotix.yaml)
port: /dev/ttyUSB0 baud: 115200 rate: 20 sync_write: True sync_read: True read_rate: 20 write_rate: 20 controllers: { # Pololu motors: 1856 cpr = 0.3888105m travel = 4773 ticks per meter (empirical: 4100) base_controller: {type: diff_controller, base_frame_id: base_footprint, base_width: 0.26, ticks_meter: 4100, Kp: 12, Kd: 12, Ki: 0, Ko: 50, accel_limit: 1.0 } }
-
2.3 加載robot_state_publisher節點(設置頻率publish_frequency:20)
3 機器人控制
//fake_amcl.launch <launch> <param name="use_sim_time" value="false" /> <!-- Set the name of the map yaml file: can be overridden on the command line. --> <arg name="map" default="test_map.yaml" /> <!-- Run the map server with the desired map --> <node name="map_server" pkg="map_server" type="map_server" args="$(find rbx1_nav)/maps/$(arg map)"/> <!-- The move_base node --> <include file="$(find rbx1_nav)/launch/fake_move_base_amcl.launch" /> <!-- Run fake localization compatible with AMCL output --> <node pkg="fake_localization" type="fake_localization" name="fake_localization" clear_params="true" output="screen"> <remap from="base_pose_ground_truth" to="odom" /> <param name="global_frame_id" value="map" /> <param name="base_frame_id" value="base_footprint" /> </node> </launch>
- 3.1加載地圖服務器節點map_server,配置地圖文件:test_map.yaml
image: test_map.pgm //包含占用數據的圖像文件的路徑; 可以是絕對的,或相對於YAML文件的位置 resolution: 0.050000 //地圖的分辨率,米/像素 origin: [-13.800000, -12.200000, 0.000000] //地圖中左下像素的2-D姿態為(x,y,yaw),偏航為逆時針旋轉(yaw = 0表示無旋轉)。系統的許多部分目前忽略偏航。 negate: 0 //白/黑自由/占用語義是否應該被反轉(閾值的解釋不受影響) occupied_thresh: 0.9 //占據概率大於該閾值的像素被認為完全占用 free_thresh: 0.196 //占有概率小於該閾值的像素被認為是完全自由的
- 3.2加載movebase節點:fake_move_base_amcl.launch——>運行成本、機器人半徑、到達目標位置的距離,機器人移動的速度
1.costmap_common_params.yaml:配置基本的參數,這些參數會被用於local_costmap和global_costmap.
obstacle_range: 2.5 //障礙物探測,引入地圖 raytrace_range: 3.0 //用於機器人運動過程中,實時清除代價地圖中的障礙物 #footprint: [[0.175, 0.175], [0.175, -0.175], [-0.175, -0.175], [-0.175, 0.175]] //將機器人的幾何參數告訴導航功能包集,機器人和障礙物之間保持一個合理的距離 #footprint_inflation: 0.01 robot_radius: 0.175 inflation_radius: 0.2 //機器人與障礙物之間必須要保持的最小距離 max_obstacle_height: 0.6 min_obstacle_height: 0.0 observation_sources: scan //設定導航包所使用的傳感器 scan: {data_type: LaserScan, topic: /scan, marking: true, clearing: true, expected_update_rate: 0}
2.local_costmap_params.yaml;
local_costmap: global_frame: map robot_base_frame: base_footprint update_frequency: 3.0 //發布信息的頻率,也就是costmap可視化信息發布的頻率 publish_frequency: 1.0 static_map: true rolling_window: false //true:在機器人運動過程中,代價地圖始終以機器人為中心 width: 6.0 height: 6.0 resolution: 0.01 //這三個是代價地圖的的尺寸和分辨率,單位都是m transform_tolerance: 1.0
3.global_costmap_params.yaml;
global_costmap: global_frame: map //定義機器人和地圖之間的坐標變換,建立全局代價地圖必須使用這個變換。 robot_base_frame: base_footprint update_frequency: 1.0 //地圖更新的頻率 publish_frequency: 1.0 static_map: true //是否使用一個地圖或者地圖服務器來初始化全局代價地圖 rolling_window: false resolution: 0.01 transform_tolerance: 1.0 map_type: costmap
4.base_local_planner_params.yaml;
controller_frequency: 3.0 recovery_behavior_enabled: false clearing_rotation_allowed: false TrajectoryPlannerROS: //機器人的最大和最小速度限制值,也設定了加速度的限值 max_vel_x: 0.5 min_vel_x: 0.1 max_vel_y: 0.0 # zero for a differential drive robot min_vel_y: 0.0 max_vel_theta: 1.0 min_vel_theta: -1.0 min_in_place_vel_theta: 0.4 escape_vel: -0.1 acc_lim_x: 1.5 acc_lim_y: 0.0 # zero for a differential drive robot acc_lim_theta: 1.2 holonomic_robot: false //全向移動機器人那么此值為true yaw_goal_tolerance: 0.1 # about 6 degrees xy_goal_tolerance: 0.05 # 5 cm latch_xy_goal_tolerance: false pdist_scale: 0.4 gdist_scale: 0.8 meter_scoring: true heading_lookahead: 0.325 heading_scoring: false heading_scoring_timestep: 0.8 occdist_scale: 0.05 oscillation_reset_dist: 0.05 publish_cost_grid_pc: false prune_plan: true sim_time: 1.0 sim_granularity: 0.05 angular_sim_granularity: 0.1 vx_samples: 8 vy_samples: 0 # zero for a differential drive robot vtheta_samples: 20 dwa: true simple_attractor: false
5.nav_test_params.yaml
TrajectoryPlannerROS: yaw_goal_tolerance: 6.28 # We don't care about orientation xy_goal_tolerance: 0.1 # 10 cm pdist_scale: 0.8 gdist_scale: 0.4 occdist_scale: 0.1
- 3.3加載fake_localization節點:ACML
3 Rviz顯示