We will first start with a very simple program to make the robot move around
- First, make sure to install Turtlebot 3 Robot, as shown in the Section "Getting Started with Turtlebot3". It is recommended to use the latest version of ROS, which is ROS Noetic, although it should work on any version.
- Start the Turtlebot3 Robot in the maze environment
roslaunch turtlebot3_gazebo turtlebot3_world.launch
- Start RVIZ for Visualization
roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch
- Observe the laser scanner in red dots in RVIZ. You can check the thickness of the laser scanner by changing the Size (m) attribute in rviz to 0.04 instead of 0.01. This will provide better visualization of the laser scanner topic.
- Run the
teleop
noderoslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
. Make the robot move and observe how the laser scanner layout is changing inrviz
. - Now, develop a ROS program in Python AND in C++ to make the robot move in a straight line, and stop when the closest obstacle gets closer than 0.6 meters. Use a laser beam around the center of [-5,+5] degrees.
- Then, develop another function that makes the robot rotate until the straight distance to obstacles in the same beam aperture is greater than 3 meters.
- Make a loop to repeat these two functions and observe if the robot succeeds in moving without hitting the obstacle forever or not.
- Try the same program in the house environment
roslaunch turtlebot3_gazebo turtlebot3_house.launch
. What are your observations?
The motion behavior in the previous solution is not smooth as there are several motions interrupted by a stop.
The objective of this second assignment is to develop a Proportional controller that regulates the angular speed and the linear speed such as the robot moves smoothly without hitting obstacles.
-
The linear velocity can be adjusted to be proportional to the distance (similar to what we did in Go-to-Goal Behavior)
-
The angular velocity can be adjusted based on the distance to the obstacles on the left side and the distance to obstacles on the right side.
-
If the distance to the left side obstacle is much closer than the right side obstacles, then make the robot rotate smoothly to the right.
-
If the distance to the right side obstacle is much closer than the left side obstacles, then make the robot rotate smoothly to the left.
-
Test the code on Turtlebot3 in the maze environment and house environment.
-
Test it on a real robot if you have one (any kind of real robot).
- create
bumper.launch
to launch environment:turtlebot3
,rviz
,teleop
, andscan_subscriber
- fix
scan_subscriber.py
: sort data to plot/scan
in -180 180 degree range and fix bug with shallow copy ofclean_ydata
- add
bumper_add.py
to implement the Move-Stop-Rotate Behavior for Obstacle Avoidance - subscribe to
/odom
to get robot pose - subscribe to
/scan
get distance to object in beam +/-5 degrees, dealing with NaN -global fwd_clearance
- publish
cmd_vel
commands to move the robotglobal x, y, yaw
- Loop:
- behavior 1 - move straight to goal until obstacle closer than 0.6m
- behavior 2 - rotate until direction with clearance >3m found
- test and fine-tune
bumper_app.py
in maze and house environments
- Add
smooth_bumper_app.py
with first implementation of the PID controller based on go-to-goal behavior
- Update and rename
bumper_app.py
torobot_bouncy.py
- Update and rename
smooth_bumper_app.py
torobot_marauder.py
- Eliminate
smooth_bumper.launch
- Rename
bumper.launch
torobot.launch
and modify to take parameters:robot_behavior:= <bouncy>, marauder, instructor, student1, student2
world:= <world>, house
open_rviz:= true , <false>
plot_laser:= true , <false>
$ roslaunch mhered robot.launch robot_behavior:=instructor plot_laser:=true
-
update this .md file
-
test alternative implementations:
- instructor solution: robot_instructor.py - ok but got stuck
- PID implementation by student 1 (Mohammed Zia Ahmed Khan) : robot_student1.py - behaves as a slow bouncy, quite good, no collision
- PID implementation by student 2 (Wellington Noberto) : robot_student2.py - ok but skids and got stuck