Homework 1 will introduce you to the tools we will use in this course. Most of the commands are specified for you in the linked instructions or below. At the end of this assignment, you should have a working system for future assignments and a basic understanding of ROS topics and nodes.
$ dts devel build --pull
This command will build your Dockerfile into an image that you can run as needed. It needs to be run when there are big changes, like when you update the template to your repo or when some Duckietown images are changed. We will discuss this more as the semester progresses. The “pull” option tells dts to check for any updates to other dependency images when it runs.
NOTE: This command may take several minutes, especially at step 10/57, the first time it runs. If you worry that it is not working, you can first download the biggest pre-requisite docker image by running the command below.
!!!Optional command below!!!
$ docker pull duckietown/dt-core:daffy-amd64
$ dts devel run -M -X --cmd bash
Let’s take a deeper look at this command:
$ cd /code/catkin_ws/ $ source /code/catkin_ws/devel/setup.bash $ catkin build $ source /code/catkin_ws/devel/setup.bash
These commands allow you to use the correct environment for ROS and build everything in that environment. You will have to run these commands every time you create a new package. For this assignment, once is enough.
$ roscore
$ dts devel run attach
This will give you a new command line interface to your running docker container.
$ source /code/catkin_ws/devel/setup.bash
$ rosrun turtlesim turtlesim_node
$ rosnode list
You should see “/turtlesim/sim” here.
$ roslaunch turtlesim_helper turtlesim.launch
This will print some debug text to the screen and then stop printing information. The same blue window should pop up, although a different turtle may appear.
$ rosnode list
This shows all of the nodes that are currently running. You should see the same node you saw before as well as one more.
$ rostopic list
This shows all active topics. Two topics, “/rosout” and “/rosout_agg” are almost always shown and we can ignore them for this assignment. We will focus on the topics that are part of this mystery node. These topics should have the prefix “/turtlesim/turtle1/”. This tells us that the developer of the code thinks they are in the same group.
$ rostopic echo <topic>
For one of the topics that you think is being sent by /turtlesim/sim node. Leave this command running.
$ rostopic pub -1 /turtlesim/turtle1/cmd_vel geometry_msgs/Twist '{linear: {x: 1, y: 2.0, z: 0.0}, angular: {x: 0.0,y: 0.0,z: 3.0}}'
NOTE: that is a “dash one” (1) after the command. Some fonts are clearer than others. It makes rostopic pub send the message exactly once and exit.
Let’s look at this command a bit: rostopic pub tells ROS that we are going to send a message on the specified topic, of the specified type. You learned the topic name and type in the rostopic info step. The complicated text afterwards tells ROS what the contents of the message are. Each set of brackets indicates a message or submessage. Think of these as classes in Python or structs in C. This uses the JSON format, another format is displayed if you use tab complete (press tab) after entering the type. Try this instead and experiment with different values.
$ git status
And confirm that it says “nothing to commit”. If there is anything to commit, refer to the commit and push commands in the setup instructions.
$ git tag hw1 $ git push origin hw1
Remember to do this for each assignment you turn in!
To complete this assignment, submit the HW1 survey on blackboard with the following information: