The purpose of this programming assignment is to work through all of the steps of creating a ROS package using Python. This project will not require the use of the Turtlebots, so you should be able to complete it outside of the robotics lab.
The goal of your project will be to create a Python node that is able to navigate a simulated 2D turtle to a designated goal location.
Follow the steps from the ROS
Packages Lab to create a repository and package for this
assignment. Your package should be named turtle_nav
and
it should depend
on geometry_msgs
, turtlesim
, rospy
and std_msgs
.
Create a Python file named turtle_nav_node.py
that moves the turtle in a
smooth trajectory to a designated goal location. Ultimately, the goal
location will be provided through the mechanism of ROS services, but
to get started you can just hard-code a goal location in your Python
code. You should be able to test your node by starting
the turtlesim
node, then
running turtle_nav_node.py
.
If your code is correct, and your package is configured correctly, you should be able to type:
rosrun turtle_nav turtle_nav_node.pyand watch your turtle merrily navigate to the goal.
Warning! The logic involved in smoothly moving the turtle to a target location is trickier than you might expect. You may find it helpful to transform the goal location into turtle-centric coordinates. The Python module turtle_pos.py provides code for accomplishing this.
The next step is to provide a mechanism for communicating goal
locations to the turtle_nav
node. We will accomplish
this by converting the node you developed above into
a ROS service provider.
Your modified node must meet the following requirements:
move_turtle_to_goal
.
TurtleGoal.srv
.
True
. False
. Locations are
unreachable in the turtle simulation if they have x or y coordinates
less than zero or greater than 11.0.The following tutorials will be helpful in completing this portion of the assignment:
Once your service is running, you should be able to test it by making calls from the terminal:
$ rosservice call /move_turtle_to_goal "goal_x: 3.0 goal_y: 5.0" success: True $ rosservice call /move_turtle_to_goal "goal_x: 3.0 goal_y: 25.0" success: False
I've also written a mouse-based ROS service client that you can use for testing: mouse_teleop.py.
Create a launch file named turtle_nav.launch
that handles starting
the turtlsim node and the navigation service node. I should be able
to test your code by typing:
roslaunch turtle_nav turtle_nav.launchin the terminal, and than making service requests.
Submit by tagging the final version of your code as "submit" and pushing the result to stu:
hg tag submit --user YOUR_EID hg commit . -m 'Tagged as submission.' --user YOUR_EID hg pushI'll grade your work by cloning this tagged version of the repository. Your submission will be graded on the basis of functionality, code-quality, documentatation, and adherence to ROS packaging standards.