ROS

From irlab
Jump to: navigation, search

General information about ROS can be found at the ROS website.


Contents

Installing ROS

Instructions for installation can be found at the installation page.

ROS Java

To allow the current rosjava run framework to use a classpath beyond the precompiled rosjava.jar file, I made the following changes to my rosjava install.

Edited the run script using:

rosed rosjava run

and changed the exec line to be the following:

exec java -classpath $ROS_CLASSPATH:`rospack find rosjava`/dist/rosjava.jar org.ros.RosRun $@

I then added this to the end of ~/ros/setup.sh:

export ROS_CLASSPATH=/Users/nah/Documents/workspace/ros-tutorials/bin

You should edit the above to point to where you want to save your classes for compiled ROS nodes etc.

ROS Problems

control_toolbox

There have been problems found when attempting to follow the tutorial on simulating a robot using player and rviz.

An error may occur when running the command

rosmake teleop_base

If this happens, a possible solution is to make the command_toolbox directly from source.

First, go to the ROS root directory

roscd

Then, get the package from source with

svn co https://code.ros.org/svn/wg-ros-pkg/stacks/pr2_controllers/branches/pr2_controllers-1.2/control_toolbox

This should download the command_toolbox package to the ROS root directory. You can now make the toolbox with

rosmake control_toolbox

Running rosmake on teleop_base should now work without any problems.

overcoming problems installing rosjava

Maven (used to install dependencies) requires to be configured to use the school's proxy if connected to one of the school networks (e.g. ccarobot). You need to create a file ~/.m2/settings.xml with the following content:

<settings>
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>webcache</host>
      <port>3128</port>
    </proxy>
  </proxies>
</settings>

Cannot Verify OS durng rosdep

Someone find a solution to this.

ROS tips

Shutting down nodes from within ROS

To shutdown a single node, call rospy's shutdown routine from the desired node.

rospy.signal_shutdown(reason) #where 'reason' is an optional human-readable string

You can customise the behaviour of the node on shutting down by defining your own shutdown hook:

rospy.on_shutdown(shutdown_func) 
#where shutdown_func is the name of the function to be called when the node shuts down.

Shutting down ROScore from within ROS

To shutdown ROScore (i.e. all nodes and /rosout) from within ROS you need to set a node as 'required'. This is done within the <node> tag of a roslaunch file.

Roslaunch allows you to start ROScore, initialise multiple nodes and to set parameters on the ROS parameter server. A short example of the syntax is shown below:

<launch>
 
<group ns="groupName">
<include file="$(find pkgname)/launch/filename1.launch"/>
<include file="$(find pkgname)/launch/filename2.launch"/>
...
</group>
 
<param name="gain" value="3.0" />
...
 
<node name="node1" pkg="pkgname" type="talker.py"/>
<node name="node2" pkg="pkgname" type="listener.py" required="true"/>
...
 
</launch>

This file can then be launched using:

roslaunch pkgname filename.launch

This starts ROScore, launches the contents of filename1.launch and filename2.launch, defines a parameter and initialises two nodes. 'node2' is labelled as 'required' which means that calling rospy.signal_shutdown from this node will shutdown everything launched from this launch file (including ROScore itself).

More information about roslaunch files can be found here: http://www.ros.org/wiki/roslaunch/XML

Note that making changes to roslaunch files will require you to rosmake the package.

Launch File for pioneer

You'll need the following stacks:

http://www.ros.org/wiki/laser_drivers
http://www.ros.org/wiki/p2os

And a launch file (for roslaunch) called pioneer.launch containing:

<launch>
  <node pkg="hokuyo_node" type="hokuyo_node" name="hokuyo" output="screen">
  </node>  

  <node pkg="p2os_driver" type="p2os" name="odom_node" output="screen">
    <param name="port" value="/dev/ttyUSB0" />
  </node>

  <node pkg="tf" type="static_transform_publisher" name="stp_laser" output="screen" args="0.145 0.0 0.05 0 0 0 base_link laser 100">
  </node>
</launch>


You can then run the system with

roslaunch pioneer.launch

map building with B21

inspired by http://www.ros.org/wiki/slam_gmapping/Tutorials/MappingFromLoggedData

  1. recording
    1. run b21 launch from https://codex.cs.bham.ac.uk/svn/nah/robotclub/trunk/b21r/b21.launch: roslaunch b21.launch
    2. record a bag of data: rosbag record -O mylaserdata /scan /tf /odom
    3. switch to joystick control on the B21 and joystick it around
    4. Ctrl-C everything once you have recorded enough
  2. mapping
    1. enable simulation time to map from recorded data rosparam set use_sim_time true
    2. run gmapping: rosrun gmapping slam_gmapping scan:=/scan _base_frame:=base
    3. replay the data bag: rosbag play mylaserdata.bag
    4. save the map to a file: rosrun map_server map_saver
    5. check the map and store it somehwere: eog map.pgm

See Also

ROS Commands

Personal tools