UP | HOME

Launchfile and Names Activity

Setup

  1. Create a new workspace and clone the demonstration code

    # Create a new workspace
    mkdir -p ws/src
    
    # clone the demonstration code
    cd ws/src
    git clone https://github.com/m-elwin/me495_counter.git counter
    
    # return to ws root
    cd ../
    
  2. Build the workspace and activate it

    • For each new terminal window that you open you will need to re-source the workspace
    catkin_make
    source devel/setup.bash
    

Exploring Names

The counter package provides several nodes (count_up, count_down, count_steady and accumulator). The nodes that start with count_ publish on the count topic. The accumulator subscribes to count and logs information.

  1. Run roscore
  2. Run rqt_graph after each node that you run, refresh rqt_graph to see the changes to the ROS graph
    • I recommend selecting Nodes/Topics (all) and un-checking Dead Sinks and Leaf topics
  3. Use rosrun to start an accumulator node and a count_up node
    • What behavior do you see?
  4. Run a count_down node along with the count_up node that is already running
    • What behavior do you see?
  5. Use rosnode kill to kill the count_up node
    • What behavior do you see
  6. Try to running another count_down node. What happens?
  7. Use the __name and remapping to run two count_down nodes simultaneously
    • What happens?
  8. Kill all the nodes that are running
  9. Use namespaces by setting the ROS_NAMESPACE environment variable to run two sets of nodes:
    1. An accumulator subscribed to a count_up in the up namespace
    2. An accumulator subscribed to a count_down in the down namespace
    3. You can do ROS_NAMESPACE=name rosrun <...> to set ROS_NAMESPACE just for a single rosrun command
    4. You can export ROS_NAMESPACE=name to set it permanently for a given terminal
  10. Run a count_steady node by specifying it's private parameter ~val to be 1 at the command line.
    • Run it in the global namespace
    • Have it publish to the accumulator node running in the down namespace.
    • Note, the ~ in a private parameter is represented as an _ on the commandline
    • You will need to remap the count topic
  11. Kill all nodes.
  12. Use rosparam to set the count_steady/val parameter to 2
  13. Run a count_steady node and note what value it is publishing
  14. Use rosparam to change the count_steady/val parameter to 5
    • Does the value published by count_steady change?
  15. Kill and re-run the count_steady node. What value is it publishing now?
  16. Close all terminal windows to kill everything

Exploring Launchfiles

I'm sure you're tired of running all these nodes… Launchfiles to the rescue!

  1. Run roslaunch counter count_nodes.launch
    • Note, roslaunch starts roscore automatically if it is not yet running
  2. Run rqt_graph to see what nodes are running and how they are connected
    • What topics are being published and subscribed to
  3. Examine the source code for count_steady node and see if you can tell where the publishing happens.
  4. Examine count_nodes.launch
    • How does the code in count_nodes.launch result in the graph that you see in rqt_graph?
    • You can see what nodes a launchfile runs without actually running them by executing roslaunch --nodes counter count_nodes.launch (notice the --nodes flag)
  5. After listing the nodes, you can use this information to see the exact command that will be run to start a node:
    • roslaunch --args=/basic/accum1 counter count_nodes.launch
    • Useful for debugging Launch files
  6. Explore all.launch to see how launchfiles can include other launchfiles
  7. Explore three_maybe.launch to see the use of namespaces and conditional tags

Author: Matthew Elwin