Embedded Motion Control 2013

From Control Systems Technology Group
Revision as of 09:45, 2 September 2013 by Jlunenburg (talk | contribs)
Jump to navigation Jump to search

Guide towards the assignment
'A-MAZE-ING JAZZ'

Gostai-Jazz-500x500.jpg

Introduction

This course is about software design and how to apply this in the context of autonomous robots. The accompanying assignment is about applying this knowledge to a real-life robotics task in which ROS will be the standard software framework.

Course Schedule

Lectures will be given on Mondays from 10.45 - 12.30 in Gemini-Zuid 3A12. The course schedule is as follows:

September, 4th Introduction Assignment and basic computer setup
September, 11th Localization C++ and ROS Concepts
September, 18th Navigation Software design
September 25th Corridor competition
October, 2nd Separation of Concerns: the 5 C's
October 9th State estimation Whole-body motion planning and control
October 16th Intelligent agents
October 23th Final competition

Pico test schedule, maze

In order to test your software on the Pico robot, each group has one one hour time slot a week available, on either Wednesday or Thursday. You can reserve your test slot in the table below. Make sure to keep at least one hour in between you slot and the previous and next ones, since Pico needs some time to recharge in between the time slots!

Date Time Group
Wednesday June, 13th 09:00 - 10:00 Group 9

Slides

The slides of the various lectures will be available a.s.a.p.

Goal

The goal of the assignment is to get the real-time concepts in embedded software design operational.

The concrete task that has to be solved is to let the PICO robot find his way out of a maze. The final demonstration by each participating group of 4-5 students will be performed during a contest, the winner of which is the group that exits the maze in the shortest amount of time. To prepare for this competition the following guidelines have to be considered:

  • to test with PICO and to prepare for the final contest, a simulator will be made available that mimics the in and outputs to the real robot. Specifics of this simulator will be presented in the first lecture on September 4th
  • the maze of the final competition will be constructed just before the competition. The maze presented in the simulator is therefore different from the real one used in the final contest.
  • both on the real and simulated PICO robot, three sources of sensor information will be available to perceive the environment and to derive the state of the robot:
    • laserdata provided by the forward pointing laser scanner,
    • images captured by the monocular camera,
    • odometry provided by the base controller
  • the robot can be actuated by sending information to the base controller
  • during the final contest, it is highly imperative that the PICO robot refrains from colliding with the walls in the maze. Colliding with the walls will result in severe time-penalties.
  • the walls of the maze will contain several types of pointers to the exit, which can potentially help PICO to speed up execution of the task Click here for a pdf file containing the arrow we will use. We also captured PICO's camera topics in a bag file while the robot was looking at the arrow. You can play this bag file as follows:
    rosbag play 2013-10-08-15-35-04.bag
    The topics /pico/camera and /pico/camera_info should then become available. For example, while playing the bag file, use
    rosrun image_view image_view image:=/pico/camera
    to view the camera images.


Corridor Competition

An intermediate review will be held on May 16th, during the corridor competition. During this challenge the students have to let the robot drive through a corridor and then take the first exit. The precise location of this exit will not be given in advance. Some facts:

Corridor example.jpg
  • The exit can be either left or right
  • It is not known beforehand how far the exit is located from the start (somewhere between 1 and 10 meters)
  • It is not known beforehand if the opposing end wall (on the far end) will be open or closed
  • The walls are approximately parallel to each other
    • Note: the walls might not be perfectly straight
  • The distance between the walls is not known in advance, but will be reasonable (somewhere between 0.5 and 1.5 meters).
    • The distance between the walls will be fairly constant throughout the corridor, 'fairly' meaning that we build the corridor by hand, and the distance may change a little along the corridor.
  • PICO will start with its laser range finder between the walls
  • PICO will be approximately facing the end of the corridor. (Notice: approximately, so don't just drive forward for n seconds!)
  • At the exit, the finish line is located approximately 30 cm from the side of the corridor (Notice: approximately, so don't just drive forward for 30 cm!). The walls that can be used to align PICO will be a little bit longer.
  • You have finished the assignment if PICO did not drive into walls, took the correct turn, the castor wheels are across the finish line.
  • Hitting the wall will result in 0 points!

During the final contest, the groups are expected to give a short (5 minute) presentation about their progress and design decisions. During the corridor competition no presentation is expected.

Hardware

The moving Jazz robot with monocular camera and laser range finder with a working ROS interface. In addition, we provide a Jazz simulator for offline testing.

Installation

This manual describes how to the install the necessary and sufficient software to start programming the Jazz robot.

Simulator

Installation

If you followed all steps specified on the installation page , you will already have downloaded the simulator Gazebo and our specific Jazz simulator. To be able to use the Jazz simulator, you first have to compile the downloaded ROS packages:

  1. Open a terminal (ctrl-alt-t)
  2. Make sure rosdep is initialized and up to date:
    sudo rosdep init
    rosdep update
  3. Build and compile the jazz simulator and other necessary packages:
    rosmake jazz_gazebo gazebo_map_spawner

Furthermore, Gazebo needs to know where to find the robot description (located in jazz_description) which includes its meshes, textures, kinematic chain, etc, and where to find the plugins for the controllers and sensors. This information can be set in the environment variables GAZEBO_PLUGIN_PATH and GAZEBO_MODEL_PATH:

  1. Open a terminal (ctrl-alt-t)
  2. Open .bashrc:
    gedit ~/.bashrc
  3. Add the following lines:
    export GAZEBO_PLUGIN_PATH=~/ros/emc/general/jazz_gazebo/lib:~/ros/emc/general/tue_gazebo_plugins/lib:$GAZEBO_PLUGIN_PATH
    export GAZEBO_MODEL_PATH=~/ros/emc/general/jazz_description:$GAZEBO_MODEL_PATH
  4. and source your .bashrc:
    source ~/.bashrc
    or start a new terminal.

Starting the Simulator

  1. Start Gazebo:
    gazebo
  2. Start another terminal and spawn the maze:
    rosrun gazebo_map_spawner spawn_maze
  3. Spawn PICO:
    roslaunch pico_gazebo pico.launch

Notice that the Jazz robot is spawned in the Gazebo world. The Gazebo GUI shows how the world actually is. We can also visualize how the robot perceives it through its sensors, by using the ROS tool Rviz. You can start RViz with a pre-defined config showing most of Jazz' sensors using:

rosrun jazz_visualization rviz

In fact, this simply runs the following command:

rosrun rviz rviz -d ~/ros/general/jazz_visualization/rviz/jazz.vcg

If you are running the Gazebo simulation, you will see the Jazz robot model and white dots which represent the sensor data originating from the (simulated) laser range finder. RViz allows you to visualize many more things. For example, to show the data from the camera:

  1. Click on the Add button in the lower left
  2. Select Camera and click OK. A Camera item will pop up in the Displays view on the left.
  3. Click in the field right next to Image Topic and click the ... button. Now you can select the camera topic (/pico/camera/image)

You will see the camera images visualized in the lower left of your screen.

Examples

Here are some examples on how to use the simulator and how to practice the corridor competition in simulation.

Jazz Driving Example

  1. Have a look at the file jazz_node.cpp in the src folder of the jazz_example package. You should be able to understand what the program will do.
  2. Build the package:
    rosmake jazz_example
  3. Run the node (make sure the simulator is still running):
    rosrun jazz_example jazz_node
    Check the result in both Gazebo and RViz.
  4. Feel free to use this example as a start for your project

Jazz Safe Driving Example

  1. First of all, make sure you have the latest version of the jazz_example package:
    1. roscd jazz_example
    2. svn up
  2. Take some time to have a good look at the file safe_drive.cpp in the src folder of the jazz_example package. It contains a quite elaborate explanation of what is going on in the code, which will hopefully clarify quite some things.
  3. Build the package:
    rosmake jazz_example
  4. Run the node (make sure the simulator is still running):
    rosrun jazz_example safe_drive
    Check the result in both Gazebo and RViz.
  5. Feel free to use this example as a start for your project


Troubleshoot

Gazebo does not stop gracefully upon exit or interrupt (ctrl-c)

You may get the warning:

Warning [gazebo_main.cc:59] escalating to SIGKILL on server

when stopping Gazebo. This is a known bug and has no consequences, other than that it takes a bit longer to kill Gazebo.

Getting Started

To get started, please do the following tutorials:

FAQ

Ubuntu

I try connect to the svn but I need the GNOME keyring password.

  1. Go to console
    cd ~/.subversion
    nano config
  2. Go to [auth] and enter below [auth] the following "password-stores =".
  3. Press ctrl+x and save the file with the same name (config).
  4. Open a new console and now it works fine.

I start the jazz_simulator but my maze is blinking very fast (HP Elitebook 8540w).

  1. Go to "System" --> "Administration" --> "Hardware Drivers".
  2. Remove the "ATI/AMD proprietary FGLRX graphics driver" (Ubuntu recommended to install this)
  3. Restart Ubuntu

Gazebo

Gazebo keeps crashing

  1. Try to run it in gdb: enter
    gdb gzserver
    to start gdb and enter
    run
    to actually start the server. The same holds for the client (visualization):
    gdb gzclient
    and again type
    run
    to start it.

PICO does not drive and does not publish any odometry

  1. Try rosmaking pico-gazebo with pre-cleaning:
    rosmake pico_gazebo --pre-clean

RViz

RViz gives a segmentation fault and crashes

Try to run RViz in gdb:

gdb /opt/ros/groovy/lib/rviz/rviz

And then type

run

You can load an RViz configuration using File -> Open Config and then navigating to the correct file, e.g. in pico_visualization.

I cannot display odometry information in RViz

In order to visualize the odometry information, RViz needs a tf (transform) from /odom to /base_footprint which is not published by the simulated controller. Since this tf is not available on the real robot either, we will not add it to the simulator. If you really want to visualize the information, or need the transform for some other reason, you will have to publish the tf yourself. See http://ros.org/wiki/tf for more info.

I've got an error with RViz and it doesn't start

If the error looks like this:

  The program 'rviz' received an X Window System error.
  This probably reflects a bug in the program.
  The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
 (Details: serial 22 error_code 9 request_code 136 minor_code 3)
 (Note to programmers: normally, X errors are reported asynchronously;
  that is, you will receive the error a while after causing it.
  To debug your program, run it with the --sync command line
  option to change this behavior. You can then get a meaningful
  backtrace from your debugger if you break on the gdk_x_error() function.)
  [rviz-6] process has died [pid 1978, exit code 1].

The following solutions can be tried:

In section 3.4 Segfault during startup from RViz troubleshooting page.

Open a terminal without Gazebo running and just type:

  export OGRE_RTT_MODE=Copy   


If this does not work, just follow the next steps:

1 rosrun rviz rviz --sync ( add the --sync it even says in the error message)
2 don't give up even with sync it will fail,maybe...try it 2-3 times
3 if it still fails do rosmake rviz rviz and repeat step 1

Graphics drivers issues

Using the wrong graphics drivers may cause Gazebo and/or rviz to crash. To solve this problem, please follow the following steps:

  • First try installing/updating the graphics driver using Hardware Drivers (System->Administration->Hardware Drivers)

You can test the driver from working properly by launching AMIGO in Gazebo and looking at the pointcloud data. This data should be refreshed when AMIGO for instance drives around or if you draw a big block in front of AMIGO.

Global Q&A

Group 2
Q: Can it be assumed that all corners are 90 degrees?
A: Yes, it can (but be aware that in practice it may be 88 or 92 degrees as well...).
Q: Do arrows insinuate driving direction only or do they provide information on next crossroads as well?
A: The camera can only look in front of the robot meaning that arrows to the left or right in a corridor are hard to recognize. They will be placed in spots where you drive towards them. They only give information about the driving direction at the location of the arrow.

Group 1 - Wouter
Q: There was a ubuntu update (2013-10-11) which also updated gazebo, now my I cannot spawn any maps anymore.
A: To be certain; first remove all folders from ~/ros/emc/general/. Then do svn update. Now make all the nodes rosmake jazz_description jazz_gazebo jazz_visualization tue_gazebo_plugins gazebo_map_spawner. You should be able to spawn mazes again by now. However when you start rviz you will see that pico has errors regarding the RobotModel and the LaserScan, to fix this set the fixed frame in Global Options to /pico/base instead of /pico/odom


Image_view

Q: When trying the command :rosrun image_view image_view image:=/pico/asusxtion/rgb/image_color
i get the following response:
[rospack] Error: stack/package image_view not found

A: You need to install image_view:
sudo apt-get install ros-groovy-image-view