This assignment consists of activities and exercises.
- For the activities there is nothing to submit, but they are preparation for the exercises.
- The numbered exercises include instructions for submitting your results.
- For this lab you will be operating the Pioneers outside. This is typically a two person job (one at the computer, one to help manage the robot). You may share the data you collect with your partner, but each person should do the processing/analysis individually.
- Be safe. There is some foot and vehicle traffic in the firelane outside the lab.
- The Pioneer batteries do not last too long (~30 min) when running the shuttle PC, so it is good practice to plug them into the charger while preparing to deploy and debugging.
Git Repository / ROS Package
As in the last few assignments, your submission for this assignment will be a Git repository that contains a ROS package. The name of the repository on the gitlab.nps.edu server should be mrc_hw7 and it should be a ROS package (catkin_crate_pkg).
GPS: Bench Test
The first step in integrating a new sensor is to test it on its own. You will establish a serial connection between the GPS receiver and your desktop/laptop.
Follow the instructions here - Garmin GPS18x - to start a ROS node that communicates with a GPS receiver.
- Note that you will need to do some wiring to make the connection to a 5 V supply.
- Also note that a single power supply can be used for multiple receivers, so please share.
GPS: Robot Integration
Once you have the GPS working on the bench, integrate it onto your Pioneer.
- Connect the power to the 5 V power from the robot. We have connectors and supplies to make that connection.
- Connect the serial to the shuttle PC. Use the hardware serial port on the machine - not a USB to serial adapter.
Once you have things connected you should be able to test that it is working by running the ROS master your desktop/laptop and the GPS driver on the shuttle.
Terminal 1: Roscore on the Desktop/Laptop
You should be able to copy and paste the following commands to set the appropriate environmental variables and start the ROS master.
Terminal 2: GPS Driver on Shuttle
Using the coconut wirless, ssh into the shuttle PC on your
To use the following commands you will need to substitute the IP address of your desktop/laptop for the BASE_IP variable below.
Exercise 1: GPS Static Test
Now we'll characterize the error in the GPS positioning by logging a bag file with the robot in one place. As we did in the last assignment we'll want to be able to drive the robot via joystick, so we'll need to start the joystick drivers on the desktop/laptop and the Rosaria drivers on the shuttle.
Terminal 3: Joystick on Desktop/Laptop
Terminal 4: Rosaria on Shuttle
Again, make sure to substitute the IP address of your desktop/laptop for the BASE_IP value below!
Now you should be able to drive the P3AT with the joystick.
Drive outside and put the robot in a safe location where it can remain still for a few minutes.
Terminal 5: Rosbag Record on Desktop/Laptop
In a new terminal record a ROS bag file named "fix_static.bag". This bag file should be in your mrc_hw7 repository in a directory named "data". The bag file should subscribes to the "/fix" topic being published by the GPS node.
Without moving the robot, let the log file record for at least 5 minutes. You can use rostopic or rqt_topic to make sure that lat/lon data is being published.
Once you stop recording, commit and push the mrc_hw7/data/fix_static.bag file.
Exercise 2: Assessing GPS Data
Now we'll use MATLAB to process your fix_static.bag file.
Create a new MATLAB script in your mrc_hw7/data directory named fix_static.m.
Use the script to read the log file like so...
Create a plot of the latitude and longitude reported by the GPS. Use MATLAB to annotate the plot with the mean of the lat/lon.
Save your figure window in the mrch_hw7/data directory as fix_static.png
Your figure should look something like this...
Optionally, you can annotate your figure with the standard deviation in latitude and longitude (there are approximately 111,000 m per degree latitude and 90,600 m per degree longitude here in Monterey.)
When you are done, commit and push the two files: fix_static.m and fix_static.png.
IMU: Bench Test
Next we will work toward integrating an IMU onto our Pioneer robots.
Work through the instructions here (UM7 IMU) to get an IMU working with ROS on your desktop/laptop.
Exercise 3: IMU Integration and Test
Since the UM7 has both power and comms through USB, integration is a matter of physically mounting the device and connecting the USB to the shuttle. You will want to mount the UM7 as far from any electromagnetic interference as possible. An example and 80/20 parts will be provided.
Terminal 1: ROS Master and Joystick on Desktop/Laptop
Terminal 2: Rosaria, UM7, GPS and State Publisher on Shuttle
Ssh into the shuttle on your robot and execute the folowing. AGAIN, make sure to substitute the IP address for your desktop/laptop for the BASE_IP value.
The shuttle.launch file starts three things: the Rosaria driver, the GPS driver and the IMU driver.
Terminal 3: rqt_plot of yaw on Desktop/Laptop
Drive your Pioneer outside
- Align your robot so that is facing due east (the x-direction) and leave the robot stationary.
In a terminal (on the desktop/laptop) execute the following command to sets the magnetic reference (so that 0 yaw is east), set zero for the gyros and reset the onboard EKF.
NOTE: if this command (rosservice call) failes, that is acceptable. Just keep in mind that east will not be zero in your data.
- Start a log file called mrc_hw7/data/imu.bag
- Point the robot east for 10 seconds
- Turn north and hold for 10 seconds
- Turn west and hold for 10 seconds
- Turn south and hold for 10 seconds.
Generate a figure that shows the time series of the yaw angle (in degrees). Save this figure as mrc_hw7/data/imu.png, add to your git repository, commit and push.
Towards GPS/IMU/Odometry Localization - Playback
Attached to this page is a ROS bag file named p3at_gps_imu_odom.bag. Download this log file.
To see what the robot thinks it did you can playback the logfile and watch it using rviz
Terminal 1: RVIZ
Terminal 2: ROS bag player
You should see the Pioneer drive up and down, returning to approximately the same location. Here is a video illustrating what it should look like: vimeo link
Exercise 4: Comparing Localization Inputs
Create Matlab script called mrc_hw7/matlab/p3at_gps_imu.m. This script should read the p3at_gps_imu_odom.bag file and generate the following graphs:
- A plot of the path of the robot as reported by the odometry (topic = /my_p3at/pose). Save as mrc_hw7/matlab/odom.png.
- A plot of the path of the robot as reported by the GPS receiver (topic = /fix). Save as mrc_hw7/matlab/gps.png
- A plot plot of the robot yaw from both the odometry and imu (topic = /imu/rpy) on the same graph. Save as mrc_hw7/matlab/yaw.png
- Hint - you will likely need to sue the quat2eul function. Pay attention to the order of the arguments for quat2eul(w,x,y,z).
- A quiver plot (see the quiver function in Matlab) to illustrate the GPS position and the Imu heading information. Save as mrc_hw7/matlab/quiver.png
Hint - Since you are plotting the GPS messages from one topic with the IMU messages from another topic, you will need to put them on the same time basis. The Matlab timeseries objects have a function to do that called resample. You will want to resample the yaw messages using the time vector from the GPS messages. Assuming you have tsFix as the GPS timeseries and tsIMU as the IMU time series, this might look like...
Add your script and four figures to your git repository, commit and push.
When you are done, your git repository should look like this...