Lab 02. Motion

From Introduction to Robotics (CS460)
Jump to: navigation, search

Lab 02. Cleaning application with Turtlesim

Lab Objectives

The objective of this lab is to practice on the motion concepts in ROS and localization in 2D space by developing a ROS node that a turtlesim behaves like a roomba cleaning robot. Follow the three first tutorials in Gaitech EDU Tutorial on Turtlesim Cleaning Application.

  • Lecture 1: Introducing the Cleaning Application
  • Lecture 2: Moving in a Straight Line
  • Lecture 3: Rotating Left and Right

The total lecture time of the three lectures is around 60 minutes. It will explain you the objectives of the application and will show you how to implement it step by step using ROS in C++.
The code is available in gaitech_edu package in your virtual machine in the folder src/turtlesim/cleaning_app/robot_cleaner.cpp. It also available on GitHub on this link.

You task will be to understand the concept of the code in ROS C++ and write the same in Python.

The videos

  • Lecture 1: Introducing the Cleaning Application

  • Lecture 2: Moving in a Straight Line

  • Lecture 3: Rotating Left and Right

Testing the program on your machine (OPTIONAL - CAN BE SKIPPED)

It is easy to first test the execution of the program on your machine.

Compilation

First, you need to compile the code written in C++. You will go through all the hassle of compiling and executing a C++ in ROS. If you are not that curious, and do not have time, skip this testing step.

The process is explained in the video, but you can follow these steps:

  • In a terminal, write:
roscd gaitech_edu/

This will take you to the gaitech_edu directory.

  • Then open CMakeLists.txt to edit as follows:
gedit CMakeLists.txt
  • Then, add these two lines at the very end of the file CMakeLists.txt
add_executable(cleaning_node src/turtlesim/cleaning_app/robot_cleaner.cpp)
target_link_libraries(cleaning_node ${catkin_LIBRARIES})

Pay attention not to make any random modification of that file, otherwise, it will not compile.

  • Then, close the CMakeLists.txt file, and close the terminal.
  • Open another terminal and write:
cd catkin_ws
  • Then, compile using the command:
catkin_make

wait until the program is compiled and if all is fine you will as at the end something like

...
[ 98%] Built target ardronelib
[100%] Built target ardrone_driver
Linking CXX executable /home/ros/catkin_ws/devel/lib/gaitech_edu/cleaning_node
[100%] Built target cleaning_node

NOTE: In case of any problem in compilation here, send me an email and I will send you the correct CMakeLists.txt file to work with.

Testing

Now, after compilation you can run as follow: In a first terminal, start roscore:

roscire

In a second terminal, start turtlesim simulator as follows:

rosrun turtlesim turtlesim_node

In a third terminal, start the cleaning application already written in c++ and also compiled as follows:

 rosrun gaitech_edu cleaning_node

You will see the Turtlesim moving as in the video. Now, this testing step is DONE.

Your Task

  • After understanding the application development process in C++ (no problem is some of syntax in C++ is not clear), develop the move and rotation function in Python and test that they work as expected.
  • Make a function called square, which takes a parameter side, when it is called the turtlesim draws a square with the specified value of the side.
  • Make a function called triangle, which takes a parameter length, and when it is called it the turtlesim draws a equilateral triangle.

Your program should providing a testing of all these functions with a menu.