(!) It is appreciated that problems/questions regarding this tutorial are asked on answers.ros.org. Don't forget to include in your question the link to this page, versions of your OS & ROS, and also add appropriate tags.

Getting start with ROS for the Nao, including NAOqi and rviz

Description: This tutorial will guide the beginner through installing ROS and NAOqi, and issuing basic commands to a simulated model in rviz.

Tutorial Level: BEGINNER

This guide is aimed at researchers or students who have a Nao robot but are unfamiliar with Linux or ROS.


Requirements

This tutorial will use the following software:

  • Ubuntu 12.04 32-bit (Precise)
  • ROS Fuerte
  • NAOqi SDK 1.12.3

All software is installed on a local PC, so a Nao robot is not required for this tutorial. We will connect ROS to NAOqi to run an open-loop simulation of the robot (no sensor feedback).

Ubuntu was installed directly on the PC, and some of the following software may not work under a virtual environment like VMware.

A Dell Alienware M11x R2 laptop was used for testing, which required the Linux Bumblebee driver for the NVidia Optimus Hybrid Graphics system. To execute an application like rviz using the 3D graphics card, run:

$ optirun rviz [parameters]


Installing Ubuntu

To install Ubuntu 12.04 (Precise) on your PC you can follow this guide:
https://help.ubuntu.com/community/Installation

The most time-effective method is:


Installing ROS

To install ROS Fuerte on Ubuntu 12.04, follow this guide:
http://www.ros.org/wiki/fuerte/Installation/Ubuntu

You need to be connected to the Internet.

Follow all the steps and install a Desktop-Full install of ROS.

You also need to install the Python tools and standalone ROS tools.

You should complete at least the first nine tutorials here:
http://www.ros.org/wiki/ROS/Tutorials
so you will understand the basics behind ROS.


Installing ROS Stacks

We will install all the required ROS Stacks for the Nao under a new directory of your ROS Workspace. e.g.

$ mkdir ~/ros_workspace/nao

In that directory, create a new file using your favorite editor. e.g.

$ cd ~/ros_workspace/nao
$ pico rosinstall.txt

Add the SVN information as per section 1.2 on installation page: http://www.ros.org/wiki/nao/Installation

Check out the code using rosinstall. e.g.

$ rosinstall . /opt/ros/fuerte rosinstall.txt

The new stacks will be installed in the following structure:

  • ~/ros_workspace/nao/stacks/humanoid_msgs
                               nao_common
                               nao_robot

Add this new path to ROS_PACKAGE_PATH. e.g.

$ export ROS_PACKAGE_PATH=~/ros_workspace/nao:$ROS_PACKAGE_PATH

So this won't be lost when you reboot, edit ROS_PACKAGE_PATH in your .bashrc file too. e.g.

$ pico ~/.bashrc

Compile the packages:

$ rosdep install humanoid_msgs nao_robot nao_common
$ rosmake humanoid_msgs nao_robot nao_common


Installing NAOqi

To install the Aldebaran NAOqi SDK, you need to be a registered NAO user.
Login and download it from here: http://users.aldebaran-robotics.com

However, a precompiled NAOqi binary is now included with the Webots 6.4.4 simulation software, so this will be covered in a different tutorial.

This section covers installing NAOqi on your local PC, to remotely control the Nao, however if you want to install NAOqi on the robot itself then you need to investigate cross-compiling ROS for the Nao.

Create a new directory. e.g.

$ mkdir ~/naoqi

Extract the NAOqi SDK to a suitable location, such as the directory:

~/naoqi/naoqi-sdk-1.12.3-linux32

Add the NAOqi library path to PYTHONPATH. e.g.

$ export PYTHONPATH=~/naoqi/naoqi-sdk-1.12.3-linux32/lib:$PYTHONPATH

So this won't be lost when you reboot, edit PYTHONPATH in your bashrc file too. e.g.

$ pico ~/.bashrc

Check the installation by executing NAOqi:

$ ~/naoqi/naoqi-sdk-1.12.3-linux32/naoqi

You should see an output similar to:

  • Starting NAOqi version 1.12.3
    .
    NAOqi is listening on 0.0.0.0:9559
    .
    .
    NAOqi is ready...

Press CTRL-C to exit.


Launching ROS and NAOqi

To start ROS, run in a new terminal:

$ roscore

To launch NAOqi on your local PC, to simulate the robot, run in a new terminal:

$ ~/naoqi/naoqi-sdk-1.12.3-linux32/naoqi --verbose --broker-ip 127.0.0.1

broker-ip address 127.0.0.1 is loopback address to connect to your own PC. So, only a local ROS install can connect to NAOqi. The NAOqi API would be accessible via broker-ip address and nao_driver acts as wrapper for NAOqi API.

Then start the ros_driver package, connecting to the simulated Nao on the local PC. Run in a new terminal:

$ LD_LIBRARY_PATH=~/naoqi/naoqi-sdk-1.12.3-linux32/lib:$LD_LIBRARY_PATH NAO_IP=127.0.0.1 roslaunch nao_driver nao_driver_sim.launch

Do not add this path to your global LD_LIBRARY_PATH in ~/.bashrc because other things will break. eg. rviz will fail to run with the error:

  • Config file '/home/USERNAME/.rviz/config' could not be opened for reading.
    /opt/ros/fuerte/stacks/visualization/rviz/bin/rviz: symbol lookup error: /opt/ros/fuerte/stacks/visualization/rviz/lib/librviz.so: undefined symbol: _ZN9QListData11detach_growEPii

The nao_driver_sim.launch file sets use_joint_sensors=false and then calls nao_driver.launch
If this is set to true during a simulation, the ROS topic /joint_states will not be updated and things will not work.

If you want to connect ROS to the real robot, you would use the nao_driver.launch launch file instead.
There is also nao_driver_2.launch which also sets use_joint_sensors=false and tries to load the nao_footsteps package. If connecting to real robot, ensure that version of NaoQi installed on robot is compatible with nao_driver.

  • If successful, you should see an output similar to:
    
    Walker online...
    .
    nao_controller running...


Controlling the simulated Nao robot

To can check which ROS nodes are running, run in a new terminal:

$ rosnode list

You should see:

  • /nao_controller
    /nao_sensors
    /nao_walker
    /rosout

By running:

$ rosnode info /nao_sensors

we can see that this node is publishing the /joint_states topic.

The ROS packages robot_state_pubisher and tf subscribe to the /joint_states topic and calculate the current pose of the robot.

To test the robot controller, issue a command to the nao_walker node in a new terminal:

$ rostopic pub -1 /cmd_vel geometry_msgs/Twist '{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'

This will start the robot walking in the x-direction.

Note:: If you are using real robot, before issuing walking command you need to enable the stiffness (if the joints are already not stiff). To do so, use:

$ rosservice call /body_stiffness/enable "{}"

This will make all the joints stiff, i.e. you won't be able to move the robot joints by force of your hands.

To check the simulated robot is actually moving, run:

$ rostopic echo /torso_odometry

And also check that the joint states are changing:

$ rostopic echo /joint_states

Similarly, to stop the robot, run:

$ rostopic pub -1 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'


Viewing the simulated Nao robot in rviz

Exit all the previously running terminal applications.

Firstly, install rospack:

$ sudo apt-get install ros-fuerte-rospack

Then install the visualization tools for ROS, including rviz:

$ sudo apt-get install ros-fuerte-visualization

Re-start roscore, naoqi and nao_driver as in the previous section.

To test the installation of rviz, run:

$ rosrun rviz rviz

If all is well, the GUI should load. You can close rviz.

Note the first time running rviz you might get an error:

  • Config file '/home/USERNAME/.rviz/config' could not be opened for reading.

Once you have saved the configuration file while exiting rviz, it won't complain about that again.

Now we need to start robot_state_publisher and tell it load the URDF model of the Nao robot:

$ roslaunch nao_description nao_state_publisher.launch

Then run viz again:

$ rosrun rviz rviz

In the top-left "Displays" window, change "Fixed Frame" to "/base_link"
If only the "/map" option is available, then the URDF model wasn't loaded from the previous step.
The "Target Frame" should be "<Fixed Frame>"

Global Status should change to "OK".
If it's red and "error" then that probably means that the topic /joint_states is not being updated.

Click on the "Add" button and add a grid.
Click on the "Add" button and add RobotModel
If everything is okay, you will see a robot model made of cylinders and the legs will be bent, with one foot in front of the other.
You will need to zoom-in to see it properly.
If there's a problem, the arms/legs will be hanging straight.

This time when you publish a control command, you should see the robot start walking in rviz:

$ rostopic pub -1 /cmd_vel geometry_msgs/Twist '{linear: {x: 1.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'

And to stop the robot, run:

$ rostopic pub -1 /cmd_vel geometry_msgs/Twist '{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.0}}'

The robot model in rviz is described using a .xacro file for the structure, and another for the visual appearance.
To create a more visually appealing model, you will need to edit visuals.xacro located in the directory:

~/ros_workspace/nao/stacks/nao_common/nao_description/urdf/

http://img.acianetmedia.com/i/6rUJi.jpg

If you have any corrections or comments about this tutorial, please contact the author listed below.


Wiki: nao/Tutorials/Getting-Started (last edited 2013-01-30 10:12:04 by nehchal)