###### tags: `ROS1` `Jetson nano` # Jetfalcon and SLAM Before the SLAM, you need to calibrate the Jetfalcon. If you had not done the step, please go to the last unit: [1. Jetfalcon and teleoperation](https://hackmd.io/@weichih-lin/jetfalcon_and_setup_environment). ## Hardware you need to prepare A mobile platform with differential drive configuration. If you don't have any idea, please check more information from [Jetfalcon](https://hackmd.io/@weichih-lin/jetfalcon). [![Jetfalcon](https://i.imgur.com/heaSful.jpg)](https://www.icshop.com.tw/product-page.php?27398) Also, recommand using host machine to launch the SLAM. If can, please prepare another host machine with ROS-Melodic. You can check this see how to install ROS on the host machine: [ROS Installation](http://wiki.ros.org/melodic/Installation/Ubuntu). Next, build the workspace for project jetfalcon. You can check it to see how to build: [0. Jetfalcon and setup environment](https://hackmd.io/@weichih-lin/jetfalcon_and_setup_environment). OK! Let's use SLAM with the Jetfalcon! ## 1. Prepare the ground for SLAM Because of the Lidar's specification, we must have an enclosed space for SLAM. Please make sure the Jetfalcon put in the enclosed space. Also, we use lidar to sacn the environment, recommand you put obstacle beside the starting point and the destination. Here is an example: ![Prepare the ground for SLAM](https://i.imgur.com/8qAnrHF.jpg) In this example, there is a box behind the Jetfalcon and also is the starting point. Another box far away from the Jetfalcon is the destination. Sure, the actual destination is the point in fron of the box, not the box's location. If you have done it, then we can go to the next step. ## 2. Bringup the Jetfalcon The motion "bringup" is activating all sensors and motors on the Jetfalcon. After the motion bringup, means that the Jetfalcon is ready to publish datas form sensors and subscribe datas from others' topic amd more about communication of ROS. Please type the command below on the Jetfalcon ```bash= roslaunch jetfalcon_bringup bringup.launch ``` ![Bringup the Jetfalcon](https://i.imgur.com/4rAYGXX.png) And then you can see the lidar rotating. **Notice! Don't move the Jetfalcon manually or the odometry will be out of action while lidar rotating!** ## 3. Launch the node gmapping through the launch file Now the Jetfalcon is publishing topics from sensors. Please type the command below on the host machine: ```bash= roslaunch jetfalcon_slam gmapping.launch open_rviz:=true ``` ![Launch the gmapping launch file](https://i.imgur.com/ypp5thc.png) You will see the rviz with default setting: ![Rviz with defaule setting](https://i.imgur.com/H9k3Z4V.png) ## 4. Teleop the Jetfalcon to make a map If you can see the map, next you can teleop the Jetfalcon to make a map. Please open another terminal and type the code below: ```bash= rosrun teleop_twist_keyboard teleop_twist_keyboard.py ``` And then lower the Jetfalcon's speed. Because of high speed result in out of action of odometry. ![Lower the speed of the Jetfalcon](https://i.imgur.com/5HwjBIx.png) **Notice! Please lower the speed depend on your Jetfalcon. The speed of this example maybe not pwoer your Jetfalcon.** Now please teleop the Jetfalcon to make a map. ![Teleop and make a map](https://i.imgur.com/G1xWfYy.png) ## 5. Save the map through package map_server This is the final step. We must save the map in specific folder: **../jetfalcon_slam/map.** There is a launch file can help you do it. Please type the code below to launch the file and save the map in specific folder: ```bash= roslaunch jetfalcon_slam save_map.launch map_name:=$map_name ``` Variable "$map_name" must be typed by the name you want. For this example, using the name "test" to save the map: ![Save map](https://i.imgur.com/GoqyMXB.png) Awesome! Now you can check the map file in the specific folder on the host machine: ![Map file on the host machine](https://i.imgur.com/PR6Y6ET.png) You can find two files in the folder: "\$map_name.yaml" and "\$map_name.pgm". If not, please relaunch the launch file to save the map again. ## 6. Shutdwon all the ROS programmings After checking the map file, we can shutdown all the ROS programming on the host machine and the Jetfalcon. Please press **[ctrl] + [c]** in the terminal on the host machine and the Jetfalcon. ![Shutdown all the ROs programmings](https://i.imgur.com/mwobn4i.png) Great! Now we can go to the next unit: [Jetfaclon and Navigation](https://hackmd.io/@weichih-lin/jetfalcon_nav)