The application uses ros2 and nav2 to simulate a common scene in a factory.
First we need to create the map using and turtlebot and cartographer node. The cartographer node will receive /scan topic from turtlebot sensor and then creat the map.
We need to launch the following nodes by order:
-
ros2 launch factory_env factory.launch.pyLaunch gazebo with pre-created world file. -
ros2 run robot_spawner spawner -n robot -x -1.0 -y 2.5Spawn a turtlebot at the factory world -
ros2 launch robot_spawner state_publisher.launch.pyLaunch robot_state_publisher to publish the transforms corresponding to the movable joints of the robot. -
ros2 launch robot_slam slam.launch.pyLaunch cartographer nodes to create map -
export TURTLEBOT3_MODEL=waffel_piSet robot model for keyboard control interface -
ros2 run turtlebot3_teleop teleop_keyboardLauch turtlebot keyboarder control interface -
ros2 run nav2_map_server map_saver_cli -f factoryCall save map command. This map will be used in the following Localization step.
In the localization step, we will provide the map file we just created at Mapping stage to nav2_nav_server node. This map and sensor data will be used to calculated robot's position using amcl algorithm.
- Run step 1~3 at Mapping stage
ros2 launch robot_navigation localization.launch.pyLaunch nav2 related nodes and rviz.ros2 service call /reinitialize_global_localization std_srvs/srv/Empty "{}"We call the/reinitialize_global_localizationto reset probability(amcl particle cloud) at every position.export TURTLEBOT3_MODEL=waffel_piSet robot model for keyboard control interfaceros2 run turtlebot3_teleop teleop_keyboardLauch turtlebot keyboarder control interface- Observe the how the amcl particle cloud changes when moving the robot aroung. The amcl particle cloud will eventually gather around the robot, which means that the localization node believes its calculated position is around the robot.
ros2 launch factory_env factory.launch.pyLaunch gazebo with pre-created world file.ros2 launch robot_navigation localization.launch.pyLaunch nav2 related nodes and rviz.ros2 run robot_spawner spawner -n robot -x -1.0 -y 2.5 -pub TrueSpawn a turtlebot at the factory world and publish initial positionros2 launch robot_spawner state_publisher.launch.pyLaunch robot_state_publisher to publish the transforms corresponding to the movable joints of the robot.ros2 launch robot_navigation navigation.launch.pyLaunch nav2 navigation stack- Use the "Navigation2 Goal" button on Rviz interface to set goal pose. The nav2 stacks will plan a shortest path using local and global costmap shown on Rviz.
ros2 run robot_spawner spawner -n robot -x -2.0 -y 2.5