Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MEC3331

Unmanned Systems

AY 2021 / 22

Lab 1 :  Mapping, Localization and Navigation using TurtleBot

Learning Objectives:

Upon completion of this laboratory exercise, students should be able to :

1.    Explain ROS platform use in TurtleBot

2.   Apply visualization and creation of a customize map of an environment with the TurtleBot. This is also known as SLAM (Simultaneous Localization and Mapping)

3.   To localize and navigate the TurtleBot in the pre-built map

ROS based SLAM implementation for Autonomous Localisation and Navigation using Turtlebot

With the use of TurtleBot Burger, we will explore SLAM (Simultaneous localization and mapping) and Navigation operations using ROS platform.

TurtleBot Burger :

 

1.    ROS (Robotic Operating System)

ROS create a network where different components (sensors and motors) called nodes are         interconnected. ROS is used to publish message in the form of topics between different nodes. This network is used to publish/subscribes messages in the form of topics between the nodes. The messages can be odometry information, control command, video streams or any type of

information. ROS provide a wealth of plugin libraries to provide different parts of robotics functionality which include localization, perception, and navigation techniques.

 

ROS Network

 

 

Robotic Control and Data Flow

2.   Network Configuration for TurtleBot 3 and the Remote computer

The TurtleBot 3 and remote computer must be configured to set up communication on the same network. Each computer’s IP address should be identified and used to establish the   ROS environment variable for the communication system.

Ubuntu has been pre-installed in both laptop and Turtlebot.

The following figure shows how these variables are identified:

 

Figure 3:  Network Configuration

Note that the turtleBot and the remote computer identify the remote computer IP address as the ROS_MASTER_URI variable.

 

2.1       Remote Computer Network setup

Determine the remote computer’s IP address on the network by

 

Look for the IP address of this computer on the wireless network:

 

Open the .bashrc script file for the remote computer to update the ROS IP settings

 

Press “Ctrl+ENDto move the cursor to the end of line

Ctrl 

END

with the IP address acquired from the 

Press Ctrl+X” to save the modified file, then Y” for Yes, the “Enter to exit

Source the bashrc with below command.

To check that the ROS environment variables are set correctly, type:

 

2.2       Turtlebot Network Setup

Connect microSD card using SD card reader to remote computer.

In remote computer, open a terminal window and go to the netplan directory in the microSD card. Start editing the 50-cloud-init.yaml file with a superuser permission sudo.

 

*Remember to replace $USER with your username of the remote computer.

When the editor is opened, replace the WIFI_SSID and WIFI_PASSWORD with your wifi SSID and password. (Likely you will be using your own hotspot name and password.)

 

Save the file with Ctrl+S and exit with Ctrl+X.

Boot Up the Raspberry Pi

a. Connect the HDMI cable of the monitor screen to the HDMI port of Raspberry Pi.

b. Connect input devices to the USB port of Raspberry Pi.

c. Insert the microSD card.

d. Connect the power (either with USB or OpenCR) to turn on the Raspberry Pi.

e. Login with ID ubuntu and PASSWORD turtlebot.

Confirm the WiFi IP address.

 

Edit the .bashrc file.

 

Find the ROS_MASTER_URI and ROS_HOSTNAME setting section, then modify the IP adddresses accordingly.

Save the file with Ctrl + S and exit the nano editor with Ctrl + X.

Apply changes with the command below.

 

2.3       Bringup

Run roscore from PC.

 

From the remote PC, try to connect to turtleBots with the IP address using SSH The default password is turtlebot

Bring up basic packages to start TurtleBot3 applications.

The terminal will print the following message:

PARAMETERS

* /rosdistro: noetic

* /rosversion: 1.15.8

* /turtlebot3_core/baud: 115200

* /turtlebot3_core/port: /dev/ttyACM0

* /turtlebot3_core/tf_prefix:

* /turtlebot3_lds/frame_id: base_scan

* /turtlebot3_lds/port: /dev/ttyUSB0

NODES

/

turtlebot3_core (rosserial_python/serial_node.py)                  turtlebot3_diagnostics (turtlebot3_bringup/turtlebot3_diagnostics) turtlebot3_lds (hls_lfcd_lds_driver/hlds_laser_publisher)

ROS_MASTER_URI=http://192.168.1.2:11311

process[turtlebot3_core-1]: started with pid [14198]

process[turtlebot3_lds-2]: started with pid [14199]

process[turtlebot3_diagnostics-3]: started with pid [14200]

[INFO] [1531306690.947198]: ROS Serial Python Node

[INFO] [1531306691.000143]: Connecting to /dev/ttyACM0 at 115200 baud

[INFO] [1531306693.522019]: Note: publish buffer size is 1024 bytes

[INFO] [1531306693.525615]: Setup publisher on sensor_state

[turtlebot3_msgs/SensorState]

[INFO] [1531306693.544159]: Setup publisher on version_info

[turtlebot3_msgs/VersionInfo]

[INFO] [1531306693.620722]: Setup publisher on imu [sensor_msgs/Imu]

[INFO] [1531306693.642319]: Setup publisher on cmd_vel_rc100 [geometry_msgs/Twist]

[INFO] [1531306693.687786]: Setup publisher on odom [nav_msgs/Odometry] [INFO] [1531306693.706260]: Setup publisher on joint_states

[sensor_msgs/JointState]

[INFO] [1531306693.722754]: Setup [sensor_msgs/BatteryState]

[INFO] [1531306693.759059]: Setup [sensor_msgs/MagneticField]

publisher on battery_state

publisher on magnetic_field

[INFO] [1531306695.979057]: Setup publisher on /tf [tf/tfMessage]

[INFO] [1531306696.007135]: Note: subscribe buffer size is 1024 bytes

[INFO] [1531306696.009083]: Setup subscriber on cmd_vel

[geometry_msgs/Twist]

[INFO] [1531306696.040047]: Setup subscriber on sound

[turtlebot3_msgs/Sound]

[INFO] [1531306696.069571]: Setup subscriber on motor_power

[std_msgs/Bool]

[INFO] [1531306696.096364]: Setup subscriber on reset [std_msgs/Empty] [INFO] [1531306696.390979]: Setup TF on Odometry [odom]

[INFO] [1531306696.394314]: Setup TF on IMU [imu_link]

[INFO] [1531306696.397498]: Setup TF on MagneticField [mag_link] [INFO] [1531306696.400537]: Setup TF on JointState [base_link]

[INFO] [1531306696.407813]: --------------------------

[INFO] [1531306696.411412]: Connected to OpenCR board!

[INFO] [1531306696.415140]: This core (v1.2.1) is compatible with TB3

Burger

[INFO] [1531306696.418398]: --------------------------

[INFO] [1531306696.421749]: Start Calibration of Gyro

[INFO] [1531306698.953226]: Calibration End

3.0       SLAM (Simultaneous Localization and Mapping) and Navigation

The SLAM (Simultaneous Localization and Mapping) is a technique to draw a map by estimating current location in an arbitrary space.

 

 

SLAM Operation

The first two steps can be skipped if you have already run in Section 2.

1.   Run roscore from Remote PC.

2.   Launch the Bringup.

3.   Open a new terminal from Remote PC with Ctrl + Alt + T and launch the SLAM node. The Gmapping is used as a default SLAM method.

Once SLAM node is successfully up and running, TurtleBot3 will be exploring unknown area of the map using teleoperation. It is important to avoid vigorous movements such as

changing the linear and angular speed too quickly. When building a map using the TurtleBot3, it is a good practice to scan every corner of the map.

4.   Open a new terminal and run the teleoperation node from the Remote PC.

The map is drawn based on the robot’sodometry,tfand scan information. These map data is drawn in the RViz window as the TurtleBot3 was traveling. After creating a complete        map of desired area, save the map data to the local drive for the later use.

Launch the map_saver node in the map_server package to create map files .           The map file is saved in the directory where the map_saver node is launched at .    Unless a specific file name is provided, map will be used as a default file name and create map.pgm and map.yaml.

The -f option specifies a folder location and a file name where files to be saved . With the above command, map.pgm and map.yaml will be saved in the home   folder ~/(/home/${username}).

Gmapping has many parameters to change performances for different environments. You can get an information about whole parameters inROS WiKior refer to the Chapter 11     ofROS Robot Programming. This tuning guide provides tips when configuring gmapping    parameters.

Below parameters are defined                                                                                     in /opt/ros/noetic/share/turtlebot3_slam/config/gmapping_params.yaml file.

1.   maxUrange

This parameter is set the maximum usable range of the lidar sensor.

2.   map_update_interval

This parameter defines time between updating the map .

The smaller the value, the more frequent the map is updated .

However, setting this too small will be require more processing power for the map    calculation. Set this parameter depending on the map environment. For smaller area used in this lab, you may try smaller value for map_update_interval.

3.   minimumScore

This parameter sets the minimum score value that determines the success or failure of the sensor’s scan data matching test. This can reduce errors in the expected position of the robot in a large area. If the parameter is set properly, you will see information         similar to one shown below.

If set too high, you might see below warnings.                                     Scan Matching Failed, using odometry. Likelihood=0                           lp:-0.0306155 5.75314e-06 -3.14151                                            op:-0.0306156 5.90277e-06 -3.14151                        

4.0       Navigtaion

In a new terminal of remote PC, launch the Navigation.

 

Initial Pose Estimation must be performed before running the Navigation as this process initializes the AMCL parameters that are critical in Navigation. TurtleBot3 has to be          correctly located on the map with the LDS sensor data that neatly overlaps the displayed map.

1.  Click the 2D Pose Estimate button in the RViz menu.

 

2.   Click on the map where the actual robot is located and drag the large green arrow toward the direction where the robot is facing.

3.   Repeat step 1 and 2 until the LDS sensor data is overlayed on the saved map.

4.   Launch keyboard teleoperation node to precisely locate the robot on the map.

5.  Move the robot back and forth a bit to collect the surrounding environment    information and narrow down the estimated location of the TurtleBot3 on the which is displayed with tiny green arrows.

map

 

6.   Terminate the keyboard teleoperation node by entering Ctrl + C to the teleop node terminal in order to prevent different cmd_vel values are published from multiple  nodes during Navigation.

Set Navigation Goal

1. Click the 2D Nav Goal button in the RViz menu.

 

2.  Click on the map to set the destination of the robot and drag the green arrow toward the direction where the robot will be facing.

o  This green arrow is a marker that can specify the destination of the robot.

o  The root of the arrow is x, y coordinate of the destination, and the angle θ is determined by the orientation of the arrow.

o  As soon as x, y, θ are set, TurtleBot3 will start moving to the destination immediately.

 

This picture was taken during the trial run in SR4E. You can see there are a lot of fine-tuning that need to be done.

Navigation stack has many parameters to change performances for different robots.   You can get more information about Navigation tuning fromBasic Navigation Tuning   Guide,ROS Navigation Tuning Guide by Kaiyu Zheng, and the chapter 11 ofROS Robot Programmingbook. All these parameters are defined in

/opt/ros/noetic/share/turtlebot3_navigation/param/costmap_common_param_burger.yaml.

1.   inflation_radius

This parameter makes inflation area from the obstacle. Path would be planned in order that it don’t across this area. It is safe that to set this to be bigger than robot radius. For more information, please refer to thecostmap_2d wiki.

2.   cost_scaling_factor

This factor is multiplied by cost value. Because it is a reciprocal proportion, this parameter is increased, the cost is decreased.

The best path is for the robot to pass through a center of between obstacles. Set this factor to be smaller in order to far from obstacles.

3.   max_vel_x

This factor is set the maximum value of translational velocity.

4.   min_vel_x

This factor is set the minimum value of translational velocity. If set this negative, the robot can move backwards.

5.   max_trans_vel

Actual value of the maximum translational velocity. The robot can not be faster than this.

6.   min_trans_vel

Actual value of the minimum translational velocity. The robot can not be slower than this.

7.   max_rot_vel

Actual value of the maximum rotational velocity. The robot can not be faster than this.

8.   min_rot_vel

Actual value of the minimum rotational velocity. The robot can not be slower than this.

9.   acc_lim_x

Actual value of the translational acceleration limit.

10. acc_lim_theta

Actual value of the rotational acceleration limit.

11. xy_goal_tolerance

The x,y distance allowed when the robot reaches its goal pose.

12. yaw_goal_tolerance

The yaw angle allowed when the robot reaches its goal pose.

13. sim_time

This factor is set forward simulation in seconds. Too low value is in sufficient time to pass    narrow area and too high value is not allowed rapidly rotates. You can watch differences of length of the yellow line in below image.

 

Task for this lab:

You need to capture the map and navigation path and try to use different parameters to finetune the map and how your turtlebot moves in the presence of obstacles. You only need to submit a    group report after Lab 2, but please remember to save some results from Lab 1.