ECE 304 Fall Semester

In this assignment, you will create an self driving self swimming autonomousturtle using the ROS turtlesim simulator.
The goal of the assignment is to understand:
– ROS nodes
– ROS topics
– ROS messages
– ROS parameters and services
– ROS launch files
And get familiar with:
– ROS workspace
– The catkin build system
– Creating your own ROS nodes.
To get started:
• Git pull to obtain the the autoturtle ROS package from: https://github.com/linklabuva/f1tenth-course-labs
• Link (or copy) the autoturtle package to the catkin workspace
• Cp -a ~/github/f1tenth-course-labs/autoturtle/ ~/catkin_ws/src/
• Run catkin_make in the catkin_ws folder. Source your environment.
• Ensure the python scripts are executable:
find . -name “*.py” -exec chmod +x {} \;
• The node turtlesim_move.py has been provided for reference.
• Make sure you can run the provided node successfully before attempting the
remaining assignment:
rosrun autoturtle turtlesim_move.py
[should move the turtle towards the x direction until it hits the wall]
Convert source files to Python 3 if using Noetic on ubuntu 20.04
Problem 1: Turtle Swim School
Problem 1a: swim_school.py
[20 points]
1. Using the turtlesim_move.py as reference, create a new ROS node called
swim_school.py
2. Modify the code to demo the following:
[1a demo:] Upon running the command rosrun autoturtle swim_school.py
• User can input a linear (x) velocity in the range [2,6] (floating point allowed)
• User can input an angular (z) velocity [1,3] (floating point allowed)
• The turtle then swims in a figure 8 shape, using the velocity and angular rate specified by the
user.
• There should be no other lines or traces in the ocean other than what has been asked in that
problem
Problem 1b
[20 points]
random_swim_school.py
1. Create a new ROS node random_swim_school.py
[1b demo:]
Upon running the command rosrun autoturtle random_swim_school.py
– A random figure 8 is drawn in the ocean:
– Turtle moves with a random linear velocity and a random angular velocity which is chosen
every time the node is run. Use the same input range as problem 1a.
– In addition, the figure 8 is drawn at a random position during each run. Its fine if the figure
8 hits the turtlesim ocean boundary.
– The center position (x,y) of the random figure 8 is displayed on the terminal.
– There should be no other lines or traces in the ocean other than what has been
asked in that problem
Problem 1c: back_to_square_one.py
1.
2.
[30 points]
Using the turtlesim_move.py as reference, create a new ROS node called back_to_square_one.py
Modify the code to demo the following:
1b demo: Upon running the command
rosrun autoturtle back_to_square_one.py
• User inputs the length of the side of the square (number between 1 and 5, any number including
floating points is allowed.)
• The ocean turns red
• A square is drawn with the length of the side of the square equal to the user input.
• Note the square must be traced/drawn as the turtle swims…DO NOT use teleport absolute or relative to draw
the square instantaneously.
• The bottom left corner of the square is always at (x,y) = (1,1), theta could be anything you want.
• You may use teleport relative to turn better.
• There should be no other lines or traces in the ocean other than what has been asked in that
problem
Problem 2: Swim to goal
Problem 2: swim_to_goal.py
[30 points]
1. Create a new ROS node called swim_to_goal.py
Demo the following:
– User inputs the x coordinate for the goal: (e.g. 1)
– User inputs the y coordinate for the goal: (e.g. 1)
– User inputs a ‘tolerance’ value (defined in subsequent slides): (e.g. 0.1)
– The turtle swims (not teleports) to the goal with a velocity and angular rate,
proportional to the distance between the current position and the goal.
– During the demo show and interpret the rqt_plot for the velocity and angular rate for
this system
Problem 2: What should node execution look like ?
User enters x, y, goal, and a tolerance value.
Problem 2: What should the output look like ?
Problem 2: swim_to_goal.py – Hints
What does proportional velocity and angular command mean ?
Proportional speed and turning:
Velocity x = V_gain * (Euclidean distance between position at any time and the goal)
Angular z = A_gain (atan2 (ratio of y component to x component))
The gains are constant but the velocity and angular rate will change as the turtle moves towards
the goal, since the distance between the position of the turtle and the goal is always decreasing.
Tolerance is a constant which dictates how close does the turtle need to be
to the (x,y) goal before it is considered that it has reached the goal.
The tolerance is needed since the pose messages that turtlesim echoes is
usually a floating point value.
A good value for the tolerance is between 0.1 and 1.
A useful command in python to use for dealing with pose data is:
round(number[, ndigits])
Useful declarations for these problems are:
import rospy
from geometry_msgs.msg import Twist
from turtlesim.msg import Pose
from math import pow, atan2,sqrt
What do I have to submit ?

All the ROS nodes you create should be inside the /autoturtle/scripts directory. (The same
as the turtlesim_move.py script).
Compress the entire /autoturtle folder.
Rename the compressed file to _.zip
and submit on Collab. Only submit a single zip file.
Example: mb2kg_melodic.zip
Ensure, the code you are submitting does not throw any errors during a catkin_make.
– We will un-compress your submitted folder inside the src folder of our
catkin workspace and run catkin_make.
– We will then test your code with the following commands and correct input
ranges:

rosrun autoturtle swim_school.py
rosrun autoturtle random_swim_school.py
rosrun autoturtle back_to_square_one.py
rosrun autoturtle swim_to_goal.py
Launch file for each problem.
There are 4 problems in this assignment:
For each problem, create and use a launch file to demonstrate that
problem (i.e. you create the appropriate node, but use a launch file for
each problem to launch the relevant nodes for that problem).
These files should be included in the autoturtle/launch subdirectory in
your submission. Each launch file is worth 10 points (bringing the total
points for this assignment to 140).

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed with your coursework?
Get quality coursework help from an expert!