You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
4.2 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. ## Navigation Stack with Actual robot
  2. stretch_navigation provides the standard ROS navigation stack as two launch files. This package utilizes gmapping, move_base, and AMCL to drive Stretch around a mapped space. Running this code will require the robot to be [untethered](https://docs.hello-robot.com/0.2/stretch-tutorials/getting_started/untethered_operation/).
  3. Then run the following commands to map the space that the robot will navigate in.
  4. ```{.bash .shell-prompt}
  5. roslaunch stretch_navigation mapping.launch
  6. ```
  7. Rviz will show the robot and the map that is being constructed. With the terminal open, use the instructions printed by the teleop package to teleoperate the robot around the room. Avoid sharp turns and revisit previously visited spots to form loop closures.
  8. <p align="center">
  9. <img src="https://raw.githubusercontent.com/hello-robot/stretch_tutorials/noetic/images/mapping.gif"/>
  10. </p>
  11. In Rviz, once you see a map that has reconstructed the space well enough, you can run the following commands to save the map to `stretch_user/`.
  12. ```{.bash .shell-prompt}
  13. mkdir -p ~/stretch_user/maps
  14. rosrun map_server map_saver -f ${HELLO_FLEET_PATH}/maps/<map_name>
  15. ```
  16. !!! note
  17. The `<map_name>` does not include an extension. Map_saver will save two files as `<map_name>.pgm` and `<map_name>.yaml`.
  18. Next, with `<map_name>.yaml`, we can navigate the robot around the mapped space. Run:
  19. ```{.bash .shell-prompt}
  20. roslaunch stretch_navigation navigation.launch map_yaml:=${HELLO_FLEET_PATH}/maps/<map_name>.yaml
  21. ```
  22. Rviz will show the robot in the previously mapped space; however, the robot's location on the map does not match the robot's location in the real space. In the top bar of Rviz, use 2D Pose Estimate to lay an arrow down roughly where the robot is located in real space. AMCL, the localization package, will better localize our pose once we give the robot a 2D Nav Goal. In the top bar of Rviz, use 2D Nav Goal to lay down an arrow where you'd like the robot to go. In the terminal, you'll see move_base go through the planning phases and then navigate the robot to the goal. If planning fails, the robot will begin a recovery behavior: spinning around 360 degrees in place.
  23. It is also possible to send 2D Pose Estimates and Nav Goals programmatically. In your launch file, you may include `navigation.launch` to bring up the navigation stack. Then, you can send *move_base_msgs::MoveBaseGoal* messages to navigate the robot programmatically.
  24. ## Running in Simulation
  25. To perform mapping and navigation in the Gazebo simulation of Stretch, substitute the `mapping_gazebo.launch` and `navigation_gazebo.launch` files into the commands above. The default Gazebo environment is the Willow Garage HQ. Use the "world" ROS argument to specify the Gazebo world within which to spawn Stretch.
  26. ```{.bash .shell-prompt}
  27. roslaunch stretch_navigation mapping_gazebo.launch gazebo_world:=worlds/willowgarage.world
  28. ```
  29. ### Teleop using a Joystick Controller
  30. The mapping launch files, `mapping.launch` and `mapping_gazebo.launch`, expose the ROS argument `teleop_type`. By default, this ROS argument is set to `keyboard`, which launches keyboard teleop in the terminal. If the Xbox controller that ships with Stretch is plugged into your computer, the following command will launch mapping with joystick teleop:
  31. ```{.bash .shell-prompt}
  32. roslaunch stretch_navigation mapping.launch teleop_type:=joystick
  33. ```
  34. <p align="center">
  35. <img src="https://raw.githubusercontent.com/hello-robot/stretch_tutorials/noetic/images/gazebo_mapping.gif"/>
  36. </p>
  37. ### Using ROS Remote Master
  38. If you have set up [ROS Remote Master](https://docs.hello-robot.com/0.2/stretch-tutorials/getting_started/untethered_operation/#ros-remote-master) for [untethered operation](https://docs.hello-robot.com/0.2/stretch-tutorials/getting_started/untethered_operation/), you can use Rviz and teleop locally with the following commands:
  39. On the robot, execute:
  40. ```{.bash .shell-prompt}
  41. roslaunch stretch_navigation mapping.launch rviz:=false teleop_type:=none
  42. ```
  43. On your machine, execute:
  44. ```{.bash .shell-prompt}
  45. rviz -d `rospack find stretch_navigation`/rviz/mapping.launch
  46. ```
  47. In a separate terminal on your machine, execute:
  48. ```{.bash .shell-prompt}
  49. roslaunch stretch_core teleop_twist.launch teleop_type:=keyboard
  50. ```