Skip to content

4. ROS Noetic

sanket369 edited this page Sep 27, 2023 · 16 revisions

under devlopment

Under Development - you can refer to ros2 setup and demo

1. Wifi Setup

Setting up your wifi ssid and password in the image file

  1. Insert the SD card into your computer using a card reader.
  2. Navigate to the "writable" folder and then to "/etc/netplan/".
  3. Open the "50-cloud-init.yaml" file in a text editor.
  4. Look for the "wifis" section in the file.
  5. Add the following code under the "wifis" section, replacing "ssid_name" with your WiFi name and "psd" with your WiFi password:
wlan0:
  optional: true
  access-points:
    "ssid_name":
      password: "psd"
  dhcp4: true

TTB IRL TTB IRL

  • Example

TTB IRL

  1. Save the file and exit the text editor.
  2. Safely eject the SD card from your computer and insert it into the robot.
  • The above steps will add your WiFi network credentials to the robot's configuration file, allowing it to connect to your WiFi network.

1.2 Check for IP address of Raspberry pi


  • Use the Android App to Find IP Open the app and Scan the network; the app will capture all the registered devices with your Network

Look for the Raspberry IP address and use it to log into the VNC

2. Create ROS Workspace on pc

source /opt/ros/noetic/setup.bash
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make
~/catkin_ws/devel/setup.bash

3. Clone Repository on pc

cd ~/catkin_ws/src
git clone -b noetic https://github.com/rigbetellabs/tortoisebot.git
cd ~/catkin_ws/
catkin_make
source /opt/ros/noetic/setup.bash
source ~/catkin_ws/devel/setup.bash

4. Install Dependencies

4.1 Cartographer Installation

4.2 Other Dependencies

sudo apt-get install ros-noetic-joy ros-noetic-teleop-twist-joy ros-noetic-teleop-twist-keyboard ros-noetic-amcl ros-noetic-map-server ros-noetic-move-base ros-noetic-urdf ros-noetic-xacro ros-noetic-rqt-image-view ros-noetic-gmapping ros-noetic-navigation ros-noetic-joint-state-publisher ros-noetic-robot-state-publisher ros-noetic-slam-gmapping ros-noetic-dwa-local-planner ros-noetic-joint-state-publisher-gui

5. Configure Master-Slave Communication:

5.1 on raspberry pi side

Pre-requisites: Must have ROS installed!!

For communication with the TortoiseBot we need to establish a Master-Slave Communication. This can be done in either of the two ways, open .bashrc file manually using display with raspberry pi or do ssh into raspberry pi:

5.1.1 Opening the .bashrc file manually using display.

  • Open the home directory of your Raspberry Pi.
  • Press Ctrl + H to unhide the files as .bashrc is a hidden file
  • Add the below commands at the end of .bashrc
export ROS_MASTER_URI=http://{ip of TortoiseBot}:11311
export ROS_HOSTNAME={ip of TortoiseBot} 
  • Please change the {ip of TortoiseBot} section with the IP address of your TortoiseBot found earlier.
    • for checking the IP address you can use the below command
    hostname -I
    
  • Save and exit the file

5.1.2 Or by using a Terminal ssh

  • ssh into raspberry pi using the below command
ssh tortoisebot@ip_address
  • password - raspberry
  • Copy the following commands and paste them into the terminal.
  • Change the IP address section with your robot's IP and hit enter to execute them.
 echo "export ROS_MASTER_URI=http://{ip of TortoiseBot}":11311 >> ~/.bashrc
echo "export ROS_HOSTNAME={ip of TortoiseBot}" >> ~/.bashrc
source .bashrc

Once done restart your existing terminals


5.2 On Pc Side

Configure Master-Slave Communication on System (Laptop/PC):

Pre-requisites: Must have ROS installed!!

For communication with the TortoiseBot we need to establish a Master-Slave Communication between TortoiseBot and our system. We can do it using two ways using a GUI interface or using the terminal.

5.2.1 Using GUI interface

  • Open the home directory of your system (Laptop / PC / VM).
  • Press Ctrl + H to unhide the files as .bashrc is a hidden file
  • Add the below commands at the end of .bashrc
export ROS_MASTER_URI=http://{ip of TortoiseBot}:11311
export ROS_HOSTNAME={ip of System} 
  • Please change the {ip of TortoiseBot} section with the IP address of your TortoiseBot found earlier.
  • And please change the {ip of system} section with the IP address of your Laptop/PC.
  • Save and exit the file

5.2.2 Or By using a Terminal

  • Open a new terminal on your system (Laptop / PC / VM).
  • Copy the following commands and paste them into the terminal.
  • Change the IP address section with your robot and system's IP appropriately and hit enter to execute them.
 echo "export ROS_MASTER_URI=http://{ip of TortoiseBot}":11311 >> ~/.bashrc
echo "export ROS_HOSTNAME={ip of System}" >> ~/.bashrc

Once done restart your existing terminals

6. Running Demos

TortoiseBot DEMO Guide

Let us explore some applications of TortoiseBot and understand how to perform Mapping, SLAM, etc on it.

6.1 Simulation

Let's first start with setting up the Simulation and getting a gist of the surrounding. This is not a necessary step, but we recommend it so that you get a complete 3D View of the surroundings and understand it.

First, run roscore in the terminal of pi (the terminal you created by following the above step)

roscore

Then, open up a terminal in your Remote PC and type the following command:

roslaunch tortoisebot_gazebo tortoisebot_playground.launch

This will launch up the simulation in Gazebo and you can view it from all sides. To pan, the simulation world left-click and move the mouse around. And to orbit, either press the scroll button or else press Shift+LeftMouseButton and move around.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/001.png

If you now wish to move the robot around in the Simulation, you can open up a new terminal and type in:

rosrun tortoisebot_control tortoisebot_teleop_key.py

and then control the robot using the keys printed on the terminal to move the robot around.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/002.png

6.2 Real Robot

6.2.1 Connecting to Robot

The first thing you need to do is to access your robot through SSH.
This connects a specific terminal on your PC to the robot so that you can run commands in the robot's terminal.
To do that, open up a terminal on your PC, type the following command and replace the IP address section with your Raspberry Pi's IP.

And then when it prompts for the password, type -" raspberry " (if you have changed the password then type the respective password) and hit enter.
There you are inside the brain of the robot. You can check it with the name on the terminal as tortoisebot@ubuntu

Now, in this case, our Robot is our master. So you need to make sure that roscore or a roslaunch file is running on your pi before you run anything on the PC's terminal or else it won't work!

Firstly, you should initialize the robot and all its sensors. To do so, enter the following in the raspberry pi terminal.

roslaunch tortoisebot_firmware bringup.launch

Once the robot and all the sensors are brought online through bringup, you can see that the LiDAR at top start rotating. Then you need to bring the server online from your PC to control and send commands to the robot. For that, run the following command from your PC's terminal

roslaunch tortoisebot_firmware server_bringup.launch

There you have your Robot ready to go!!!

For using the Camera Node and its Visualisation in RQT Image View run the following command and then subscribe to /camera topic ****

6.2.2 Visualizing Sensor Data

Now that everything is set up, you can visualize data from various sensors on your robot like LiDAR and Camera. To visualize the data, we will be using RViz. To open up RViz, run the following command on your PC's terminal

roslaunch tortoisebot_slam view_sensors.launch

This will open up RViz with all the robot models, tf tree, laser scan data, and image view from the camera. If you wish, you can uncheck certain boxes to remove the visualization of certain sensors.

WARNING: Do not change the size of the image view in RViz.

Suggestion: Unchecking the image view will put less load on your Robot

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/003.png

If you wish to always see the camera view and be able to change the position and size of the window, then you can view it using Image View. To run that, open up a new terminal on your pc and type:

rosrun image_view image_view image:=/camera

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/004.png

This will open up a new camera window that shows a live feed from Robot's camera. You can make it to always view it on top by right-clicking on the Menu bar and then selecting the always on top option. You can now move your robot in real-world and explore through its camera view using the same teleoperation command as given above:

rosrun tortoisebot_control tortoisebot_teleop_key.py

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/005.png

7.5 Generating Map of the Surrounding

To generate a map of the surrounding, first, run the bringup.launch on Robot's terminal

roslaunch tortoisebot_firmware bringup.launch

Then run server_bringup.launch on the PC

roslaunch tortoisebot_firmware server_bringup.launch

Then in another terminal launch tortoisebot_slam.launch using:

roslaunch tortoisebot_slam tortoisebot_slam.launch

This will launch RViz which will be generating Map on the basis of the LiDAR scan that is been received.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/006.png

Now you can start the TortoiseBot teleoperation node in another terminal and move the robot around to make the complete map of the surrounding.

rosrun tortoisebot_control tortoisebot_teleop_key.py

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/007.png

Navigate to the tortoisebot_navigation package and open up the maps folder. Right-click and select an option to open a terminal in a specific location. Make sure you are inside the maps directory on your terminal. You can run the following command in that terminal to save the generated map inside the maps folder. You can replace the "my_map" with whatever name you want.

rosrun map_server map_saver -f my_map

Now a pgm and yml file of your map will be created in the maps folder

7.6 Heading towards Autonomous Navigation

Once we have generated our map, we are all set to automatically navigate our robot in the surrounding without any human intervention. To run the autonomous navigation script, first, make sure your robot is placed just on the central zebra crossing and then run the following command on the robot's terminal to start the robot.

roslaunch tortoisebot_firmware bringup.launch

Then run server_bringup.launch on the PC

roslaunch tortoisebot_firmware server_bringup.launch

Then in another terminal launch the autonomous navigation launch file using:

roslaunch tortoisebot_navigation tortoisebot_navigation.launch

If you wish to start navigation in a map file that you created, run the same launch file with a parameter giving the name of your map. For example, if the name of my map is "my_map" then I will run:

roslaunch tortoisebot_navigation tortoisebot_navigation.launch map_file:=my_map

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/008.png

Once the RViz is launched successfully, you can give navigation goals anywhere on the map using the 2D Nav Goal option that is displayed on the top.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/009.png

Once you give the goal, the robot automatically calculates the best route and starts navigating to the goal location autonomously. You can see the same in RViz as well as through the webcam.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/010.png

And once the goal is reached, the robot prints the message on the Terminal that the goal is reached.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/011.png

Similarly, you can give the navigation goal somewhere behind any obstacle and the robot will try to avoid all the obstacles and navigate to the goal location.

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/012.png

https://github.com/rigbetellabs/tortoisebot_docs/blob/master/imgs/tortoiseBot_demo/013.png

Similarly, you can give the navigation goal somewhere behind any obstacle and the robot will try to avoid all the obstacles and navigate to the goal location.


Clone this wiki locally