Skip to content
Marc Hanheide edited this page Jan 31, 2019 · 22 revisions

Week 2: First steps with ROS Programming

Today, your team will also be starting with the real robot, in addition to the simulation. To work with the real robot, please follow the following steps. While you are waiting to get your robot, make sure to work in simulation as detailed below.

Preparation

Remember, you are a group, so you may decide who is going to focus on real robot and who on simulation! Both are attract marks for the mini task outlined below. So, you may designate a subteam to work on the real robot and read the following in detail and then report back to the whole group, while the other group members already focus on the solution for the simulation.

Recordings of the relevant parts of the lecture are on Blackboard in the Panopto folders, but also some recordings are on youtube from previous lectures (but will be slightly outdated!):

  1. Use of the commandline tools: https://youtu.be/_2VmTefxCBk
  2. Python Programming: https://youtu.be/nHPDBJZWZqo

Your Real Robot (handling and programming)

  1. Get your turtlebot from the demonstrators!
  2. Read (all team members, please!) Turtlebots and particularly familiarise yourself with the handling of the robots!
  3. In this workshop, we will be connecting to the turtlebots from our own desktop machines via the wireless network. Your turtlebots have an IP address assigned which you will be using to talk to them through ROS. So, find out the IP address of your robot after booting it up and try to connect to it in your browser.
  4. Start the main drivers of the robot as described in here.
  5. You have two options to run code and commands on the robot, make sure you read about these two options.

On the simulated robot (gazebo)

Mini Tasks of week 2:

Task 1: Make your robot move using the command line (both, in simulation and real robot, see above):

  1. Run rostopic list and discuss with your team members what you see. Also try rostopic echo /odom and push the robot about if you're working on the real robot or make it move in simulation using the keyop from last week. What do you see?

  2. use rostopic pub to make the robot move! Try to develop the following command using the Tab key for auto-completion (do not directly copy this, as it will not work):

    rostopic pub /mobile_base/commands/velocity geometry_msgs/Twist "
    linear:
      x: 0.0
      y: 0.0
      z: 0.0
    angular:
      x: 0.0
      y: 0.0
      z: 0.5" -r 1 
    

    (You can stop this command by hitting [Ctrl]-C on your keyboard!)

    • In simulation, you already know how to do this
    • On the real robot, you may choose between running it on the robot in Jupyter or via the VPN setup. For this task, simply using the terminal in Jupyter is by far the easiest.
  3. Watch your turtlebot move (try simulation first). Explain (to your team and a demonstrator) what is happening. Try to make it go around in a circle (with about 0.5m radius) smoothly by modifying the above command.

  4. Optional, but very relevant: run roslaunch turtlebot_rviz_launchers view_robot.launch again (you did last week?!) and in particular inspect the output of the real robot's sensors (for this to work you need to connect form your PC to the real robot via VPN!. Find out how to display different sensory information of the robots: Pointcloud, "laserscans" (discuss what this actually is, as there is no laser sensor on the robot!), and images. Show the demonstrator how your turtlebot sees the world.

Task 2: Python programming

  1. Read this tutorial on how to create a publisher in python. Remember that we want to publish a geometry_msgs/Twist to /mobile_base/commands/velocity!
  2. To create a workspace and package and start spyder correctly, please have a look at First Turtlebot coding
  3. Time to code our first Python program using ROS: The goal is (again) to have the turtlebot first go around in a circle, this time from the Python program!
  • In simulation, you just run the simulation as before, and then your code in Spyder or from the command line
  • On the real robot, you may choose between running it on the robot in Jupyter or via the VPN setup
  1. Optional: When you have accomplished this, the next challenge for you is to make it go in the shape of a square of 1m length each side.

Summarised Assessment requirements for Minitask Week 2:

The following needs to be accomplished to get full marks for this workshop. Remember, you can also still show the outcome of week 1 workshops and get full marks. Last chance in this second week!

  • For full marks your group needs to show your accomplishment in both tasks in simulation and on the robot
  • You need to show that you can make your robot move (in simulation and reality), both, via the rostopic command line tool, and from your Python code.

Background that may help you

What to sent to the robot?*

A Twist message has two parts that are important:

  • Twist.linear: this has x,y,z components for which you can specify the speed in m/s. Please don't go beyond 0.6

  • Twist.angular: this also has x,y,z components and determines how quick the robot should rotate around one of the axes in radians/s. Please don't go beyond PI. To determine which axis you want to move along and turn around, please have a look at the picture below:

    Turtlebot axes

Red: x, green: y, blue: z

Clone this wiki locally