Create a launch file for Task 2
In order to run your Task 2, we need you to have your Task 2 launch file to use a common structure. This page give some insight into how to do that.
What is a launch file?
Launch files are a standard in ROS, which permits you to have a single command that might start any number of nodes at once. You are already using this when you type something like:
roslaunch catvehicle catvehicle_neighborhood.launch
That launches gazebo server, as well as a bunch of drivers that convert gazebo data into ROS topics. You might want to check out that launch file to see the kinds of things inside of it.
How do I create a launch file?
Using any text editor, you create a file using the standard XML syntax for ROS Indigo. Really, though, it's easier to look at a bunch of examples. Let's create one that launches the task1.py as part of a launch file, instead of using rosrun.
Example: Convert Task1's Python script to run through a launch file
When running Task 1, we provided task1.py which is a python implementation of an orbiting point which is mapped into a grid. This is duplicated in the Task2 see, and to run this, you can type:
rosrun cvchallenge_task2 task1.py
One neat thing about ROS is its ability to permit you to develop publish/subscribe in any language you like: what if you liked to use Python? This syntax is find then. What about C++ though? Someone else would need to know what your preference was, to guess how to run your code. Or more complicated: if you prototype it in Python and want to do a final implementation in C++, you would need to change all your instructions everywhere. Disaster!
ROS launch to the rescue.
<!-- in cvchallenge_task2/launch/task2.launch --> <launch> <node name="task1" pkg="cvchallenge_task2" type="task1.py"/> </launch>
With this file, running the launch file will start up task1.py, from the package cvchallenge_task2, and call it task1. You can run it like:
roslaunch cvchallenge_task2 task2.launch
How will this affect my Task 2 submission?
You might have more than one node to run, in order to solve the Task 2 problem of generating detections from objects you see along the catvehicle's path. For example, you might be using generated Simulink code to do some tasks, and those nodes/tasks publish and subscribe to other nodes you create. You can have your Task 2 submission use packages and nodes that are included in your submission, just make sure your launch file starts them up and connects them together. For example:
<!-- example team's cvchallenge_task2/launch/task2.launch --> <launch> <!-- publishes the detections --> <node name="detectionPublisher" pkg="cvchallenge_task2" type="task2.py"/> <!-- consumes data from the laser and the optical flow node, and publishes a subset of those data for detectionPublisher --> <node name="laserreader" pkg="cvchallenge_task2" type="laserreader.py"/> <!-- generated simulink code that estimates optical flow --> <node name="flowestimator" pkg="opticalflow" type="opticalflow_node"/> </launch>
What limitations are there on what we can put in the launch file?
Only what ROS limits, though we don't recommend to put rosbag record in here, since you won't be able to get any of the data. You'll be submitting all the code you need (except the catvehicle and its standard package obstaclestopper) as part of your submission in a single zip, so any package you have in your task2.launch file should also be included in either the catvehicle or obstaclestopper package, or be included in your own zip.
Questions? Head on over to the forums and we'd love to tackle them!