Table of Contents

ROS

Introduction

Installation

sudo easy_install -U rosinstall
cd local/src
mkdir ros
rosinstall ros http://www.ros.org/rosinstalls/cturtle_base.rosinstall
export ROS_ROOT=${HOME}/local/src/ros/ros ; 
export PATH=${ROS_ROOT}/bin:${PATH} ; 
export PYTHONPATH=${ROS_ROOT}/core/roslib/src:${PYTHONPATH} ; 
export OCTAVE_PATH=${ROS_UP}/ros/core/experimental/rosoct/octave:${OCTAVE_PATH} ; 
#if [ ! "$ROS_MASTER_URI" ] ; then export ROS_MASTER_URI=http://leela:11311 ; fi ; 
if [ ! "$ROS_MASTER_URI" ] ; then export ROS_MASTER_URI=http://localhost:11311 ; fi ; 
export ROS_PACKAGE_PATH=${HOME}/local/src/ros/stacks:${HOME}/local/src/repositories/oid5;
#export ROS_STACK_PATH=${ROS_ROOT}:${ROS_UP}/ros-pkg ; 

#source `rosstack find ias_semantic_mapping`/setup.sh

NUM_CPUS=`cat /proc/cpuinfo |grep processor |wc -l`
let "PAR_JOBS=${NUM_CPUS}+2"
export ROS_PARALLEL_JOBS="-j${PAR_JOBS}"

export ROS_LANG_DISABLE=roslisp:rosjava

export ROS_IP=`ip addr show \`/sbin/route -n | awk '/UG/ {print $8}'\`| awk '/inet /{print $2}' |sed -e 's/\/.*//'`
#export ROS_IP=192.168.137.2
#HOSTNAME=`hostname`
#if [[ "${HOSTNAME}" == "leela" ]] ; then echo "Hola"; else echo "lala" ;fi

alias kcart_left="`rospack find kbd-cart-cmd`/kbd-cart-cmd -p kbd-left -c /lwr/left"
alias kcart_right="`rospack find kbd-cart-cmd`/kbd-cart-cmd -p kbd-right -c /lwr/right"

. ${ROS_ROOT}/tools/rosbash/rosbash 
alias env_ros='source ${HOME}/.bashrc.ros'

Installing extra ros packages

In the ros directory there is a subdirectory called stacks this is where you can put extra packages. You just have to download somehow this packages and put them there.

Example: Gstreamer video adquisition:

cd $ROS_ROOT
cd ../stacks
svn co http://brown-ros-pkg.googlecode.com/svn/tags/brown-ros-pkg
rosmake gscam

Gscam

Captures images from gstreamer video sources and sends them to a ros topic.

gst-launch --gst-debug=v4l2:2 v4l2src device=/dev/video1 ! video/x-raw-rgb,width=800,height=600,framerate=30/1 ! ffmpegcolorspace ! xvimagesink 
export GSCAM_CONFIG="v4l2src device=/dev/video0 ! video/x-raw-rgb,width=800,height=600,framerate=30/1 ! ffmpegcolorspace ! identity name=ros ! fakesink"
rosrun gscam gscam
rosmake image_view
rosrun image_view image_view image:=/gscam/image_raw

Improving image quality with some cameras

With a Logitech webcam C600 one can get better image quality (less noisy) setting the video mode to YUV. In gst-launch:

gst-launch --gst-debug=v4l2:5 v4l2src device=/dev/video1 ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=800,height=600,framerate=15/1 ! ffmpegcolorspace ! xvimagesink

For gscam:

export GSCAM_CONFIG="v4l2src device=/dev/video1 ! video/x-raw-yuv,width=800,height=600,framerate=15/1,format=(fourcc)YUY2 ! ffmpegcolorspace ! video/x-raw-rgb ! identity name=ros ! fakesink"

the last conversion is necessary because gscam only takes rgb images. Please carefully notice that for the gscam GSCAM_CONFIG export there are no back-slashes for the format “fourcc” part.

One can use gst-inspect to check the capabilities of the different gstreamer filters.

Camera calibration

rosmake camera_calibration
rosrun camera_calibration cameracalibrator.py --size 5x4 --square 0.02464 image:=/gscam/image_raw camera:=/gscam
export ROS_NAMESPACE=gscam
rosrun image_proc image_proc
rosrun image_view image_view image:=/gscam/image_rect_color

Calibration manually

The algorithm that selects the pictures in camera_calibration is not perfect, and it prefers to select blur images over sharp, also most of the times it doesn't use enough pictures. So here we explain how to use your own pictures to calibrate.

cd /tmp/
rosrun image_view image_view image:=/gscam/image

Images are store in the current directory.

rosrun camera_calibration camera_calibrate_from_disk.py --size 8x6 --square 0.0247881 /tmp/frame00*

Markers tracking

Artoolkit in ros

roscd; cd ../stacks
git clone http://robotics.ccny.cuny.edu/git/ccny-ros-pkg.git
rosmake artoolkit
rosmake ar_pose
4x4_23
data/4x4/4x4_23.patt
25.0
0.0 0.0

First is the name of the marker, second is the file of the marker, then the size in mm, then the relative position?

rosrun ar_pose ar_multi /usb_cam/camera_info:=/gscam/camera_info /usb_cam/image_raw:=/gscam/image_rect
rostopic echo /visualization_marker

Getting images from yarp to ros

roscd; cd ../stacks
svn co https://code.ros.org/svn/wg-ros-pkg/branches/trunk_cturtle/sandbox/yarp
rosmake yarp
roscd; cd ../stacks
git command that I still don't know
rosmake yarp2
rosmake yarp_to_ros_image
rosrun yarp_to_ros_image yarp_to_ros_image

iCub and all this

Calibrate the icub cameras

roscd yarp_to_ros_image
rosrun yarp_to_ros_image yarp_to_ros_image
yarp connect /icub/cam/left /yarp_to_ros_image
rosrun camera_calibration cameracalibrator.py --size 6x4 --square 0.040625 image:=/yarp_to_ros_image/image camera:=/yarp_to_ros_image

This is for our middle sized checker board.

Detecting markers

roscd yarp_to_ros_image
rosrun yarp_to_ros_image yarp_to_ros_image

This will use the camera_calibration.txt file that is in the yarp_to_ros_image directory.

yarp connect /icub/cam/left /yarp_to_ros_image
export ROS_NAMESPACE=yarp_to_ros_image
rosrun image_proc image_proc image_raw:=image
rosrun ar_pose ar_multi /usb_cam/camera_info:=/yarp_to_ros_image/camera_info /usb_cam/image_raw:=/yarp_to_ros_image/image_rect
rostopic echo /ar_multi/visualization_marker