You can find a set of basics ROS C++ tutorials. In this tutorials, a gazebo simulation is used to work with the turtlebot robot.
You need to install ROS Melodic , wich you can find in the offical page. Aditionally, you need the turtlebot 3 simulator, that will be covered in the video tutorial. By now, I put the installation links.
- Ubuntu 18
- ROS Melodic -
- Turtlebot 3 simulator -
You need to download the repository and paste the requiered package in your workspace, depending on the tutorial you are working.
- Create a catkin workspace
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/
$ catkin_make
- Download the repository insider the /src file of the workspace
$ cd /src
$ git clone https://github.com/aflores-c/ROSCPP.git
- Make again and check all compiles correctly.
$ cd ..
$ catkin_make
We create a node that subscribes to the /scan topic to read the distances from the robot to the obstacles. Then, the node uses this data to avoid obstacles by publishing velocity commands to the /cmd_vel topic to move the robot.
- Source your environment
$ cd catkin_ws
$ cd source devel/setup.bash
- Launch the simulator. We need to choose the robot. In this case, we use the waffle turtlebot robot.
$ export TURTLEBOT3_MODEL=waffle
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
- In another terminal, run the "avoid_obstacle" node
$ rosrun turtlebot_obstacles turtlebot_obstacles_node
We modified the previous turtlebot controller class and we add a service member function. This server function will allow to move the robot randomly, as we've seen in the previous tutorial. Now, the robot just use the callback to get the distance and you can call the service to move the robot. You request to move a robot for a certain duration and when the duration finishes, the service returns a response of success.
- Source your environment
$ cd catkin_ws
$ cd source devel/setup.bash
- Launch the simulator
$ export TURTLEBOT3_MODEL=waffle
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch
- In another terminal, run the "avoid_obstacle" node
$ rosrun turtlebot_services turtlebot_services_node
- You can see the available services and then you can call that services.
$ rosservice list
$ rosservice call /move_robot "duration:
secs: 15
nsecs: 0"
- There is another way to call the services. It is done by running a service client.
$ rosrun turtlebot_services turtlebot_services_client
We use OPENCV to detect the lane in the Autorace world. Furthermore, a basic proportional controller is implemented, to move the robot.
0.First, paste the turtlebot3_autorace2.launch inside src/turtlebot3_simulations/turtlebot3_gazebo/launch/.
- Source your environment
$ cd catkin_ws
$ cd source devel/setup.bash
- Launch the simulator
$ export TURTLEBOT3_MODEL=waffle
$ roslaunch turtlebot3_gazebo turtlebot3_autorace2.launch
- In another terminal, run the "turtlebot_vision" node. This node subscribes to the /camera_callback topic and process the images to detect the lanes.
$ rosrun turtlebot_vision turtlebot_vision_node