Homework 2 will test your ability to create ROS packages, create a ROS node, and integrate your code into existing infrastructure.
In Homework 1, you sent and received messages to a ROS node manually, using rostopic. In this homework, you will create a new node to send messages to the homework 1 turtlesim node as described below. You can follow the instructions below to do this or do it your own way, as long as the objectives are met. All messages should be sent through nodes in this homework, there should be no need to send anything using rostopic when it is graded.
This homework requires that you create:
Your package will depend on rospy, roscpp, std_msgs, and geometry_msgs. You may name it whatever you like.
This node should publish to the topic that turtlesim subscribes to. You should have found this topic in HW1. If not, see the instructor. This node should publish velocities to make the turtle move in a square at least 2 units (as output from the pose topic) in each dimension. Note that periodically, ROS nodes will start at different times, so consider adding a slight delay before publishing commands.
Your launch file should start everything needed to demonstrate your code. Specifically, it should include the launch file used in Homework 1 to start turtlesim/sim and start your node. The instructor should be able to start this launch file and then grade your homework based solely on the nodes launched.
Edit the file in <your_repo>/launchers/launch-hw2.sh so that it starts your code when run. Refer to lecture slides and this page if you have any questions.
Submit to Qualtrics:
roslaunch <package> <launch_file>
6 points – Publisher node meets objectives
6 points – Package creation meets objectives
6 points – Launch file/launcher meets objectives
4 points – Tag applied in git
18 points – Answers given
If you like, you can use these detailed instructions to complete this assignment. In general, you may find the instructions for developing homework assignments helpful.
$ dts devel run -M -X --cmd bash
$ catkin_create_pkg learning_ros std_msgs rospy roscpp geometry_msgs
Reference slides and http://wiki.ros.org/ROS/Tutorials/CreatingPackage for help.
$ chmod -R a+rw <package_folder>
$ catkin build $ source /code/catkin_ws/devel/setup.bash
$ gedit <node_name>.py
You should replace <node_name> with whatever you want to call the node.
$ ls /code/catkin_ws/src/<your_repo>/packages/<hw2 package>/src
To make this file executable, run:
$ chmod +x /code/catkin_ws/src/<your_repo>/packages/<hw2 package>/src/<file_name>
$ dts devel run attach
$ roscore
$ rosrun <package> <node>
$ rostopic echo <topic>
$ mkdir <your_repo>/packages/<hw2 package>/launch
but then you can edit the file just like you edit node files:
$ gedit <your_repo>/packages/<hw2 package>/launch/<launch_file>.launch
HW_PACKAGE=<your package name> HW_LAUNCH=<your launch file name>
$ dts devel build $ dts devel run -X -L launch-hw2
$ git status
$ git add <files>
$ git commit -m <message>
$ git push
$ git tag <tag_name>
$ git push origin <tag_name>