PA Basic Control slides |

Demonstrate basic control of the robot

Purpose

This assignment is an will introduce you to creating a basic ROS program. It is the foundation of everything that follows. It is also a lot of fun!

Skills that you will practice

  • Motion: Control motion with cmd_vel
  • Pubsub: publish and subscribe
  • sensing: sensing with lidar and odom
  • calc: Algorithms, calculations and state management
  • Debug: *Finish, debug, and get an app to work”

Expectations

  • Be comfortable with python programming, linux shell
  • Know the basics of the ROS distributed messaging architecture
  • Understand the relationship between time, velocity, and distance
  • Understand nodes, topics, publish, subscribe and messages
  • You should have studied Chapter 2, Chatper 6 and Chapter 7

Resources and Tips

Assignment Specifics

Here is what you are asked to do (Sample Solution

  • Drive the robot 1 Meter out and 180 degree turn in place and try to get back to the same spot
  • Drive robot in an exact 1 Meter square
  • Drive robot in a circle with a radius of 1 Meter
  • Demonstrate this in sim

How to run the starter code

  1. roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
  2. rosrun basic_mover my_odom.py
  3. Comment in or out lines under if __name__=='__main__': in basic_mover_answer.py for desired behavior.
  4. rosrun basic_mover basic_mover.py

Sample Code

You will find the starter code package in catkin_ws/src/cosi119_src/basic_mover

  • src/basic_mover.py - Basic Mover Node
  • src/my_odom.py - Odometry node (start with this one)
  • src/my_odom_alt.py - Alternative Odometry node (look this one over and understand the difference)

Tips and thought process

  • Baseline
    • Note: this PA is done in simuilation
    • Launch the provided gazebo environment and play with gazebo to get the hang of it
    • You are not required to follow the starter code if you have a better idea
  • Drive 1 meter out
    • Consider what it means to drive out 1 meter and stop
    • Use cmd_vel to move the robot forward
    • Collect location and orientation information ion from my_odom subscription
    • Monitor my_odom until it tells you that you’ve gone 1 meter
  • 180 degree turn and return
    • How do you use cmd_vel to rotate in place
    • Again use my_odom, this time to monitor the orientation
    • Rotate until you see 180 degrees ( = 1*math.pi)

Deliverables

  • The starter code is meant as a guide. Unlike other courses, you are not required to use it as is.
  • The resultant shapes driven don’t have to be exact. The square doesn’t have to be perfectly square
  • We want to see good clean Python code that reflects a good understanding of ROS, robot motion, and sensing
  • The video can go 3 minutes and must include both a video of the demo running IRL or in sim, as well as a tour of some key parts of the code.

Filled in by Ephraim (ezimmerman@brandeis.edu for questions) Please follow the following steps for a successful submission:

Video submission:

  1. Record your video submission.
  2. Upload the video file to Google Drive and ensure that “Anyone with the link” is selected on the sharing tab.
  3. Copy/paste this link as an inline comment below the import statements in the basic_mover.py file. DO NOT remove the #!/usr/bin/env python3 present on the first line of the code.

Code submission:

  1. Navigate to /my_ros_data/catkin_ws/src/cosi119_src/basic_mover/src in your cluster account VSCode view.
  2. Compress the files: zip basic_mover_<brandeis email prefix>.zip my_odom.py basic_mover.py. Replace with your email prefix. For example, ezimmerman. >An obvious question is: Why not just download the files and zip them on your machine? While that is an option, if you need to repeat the process when fixing a mistake in your code, keeping track of which file is the most recent can become difficult. Simply downloading the zip file removes some room for error. There will be no leniency for uploading the incorrect files.
  3. The previous step will generate a .zip file. Right click it, then press download. This will download the files onto your machine.
  4. Upload the zip file, named, for example, basic_mover_ezimmerman.zip, to the Moodle submission.