Page tree
Skip to end of metadata
Go to start of metadata

References and Prerequisites

ROS

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_hw6 and it should be a ROS package (catkin_crate_pkg).  

Pioneer Setup

For the following exercises we will use two computers:

  1. desktop/laptop for running the ROS master, visualization, etc.
  2. a "shuttle" PC mounted on the Pioneer robot which will run the Rosaria node to communicate with the robot

More information will be provided during lab, but work with a partner to select one Pioneer robot and set it up as follows:

  • Mount the shuttle PC to the 80/20 rails (you may need to switch out the shuttle PC for one of them with a label such as shuttle0, shuttle1, etc.)
  • Secure the PC power supply and inverter to the top of the shuttle PC, making sure that the cooling fans are unobstructed.
  • Connect the inverter to the 12V power coming from the Pioneer (this may involve some crimping of wire and connectors!)
  • Connect the shuttle PC to the inverter for AC power.
  • Connect the serial port of the shuttle PC to the Pioneer

Now you should be able to power on the Pioneer and the shuttle PC.

Network Setup

Next you will want to configure your desktop/laptop computer that you will use to communicate with the robot.  You will want the computer to be connected to both the wired NPS network (the internet) and the wireless network (the robots).  The Desktops in the lab should be setup to access both network, but instructions are on Robotics Computation Lab page.

Desktop/Laptop Network Setup

Determine the wireless IP address for the computer your working on.  If you are on one of the lab desktops it should be listed in the Robotics Computation Lab.  You should double check this by using the command "ifconfig" at the command line.  The example below has an entry for "wlan0" which is the wireless interface which has the IP address 192.168.11.100 (your IP address will be different).

Shuttle PC Setup

Turn on your Pioneer robot and turn on the shuttle PC mounted on the robot.  Note the name of the shuttle and the associated IP address listed here: Robotics Computation Lab

If all goes well, the shuttle PC should connect to the network and you should be able to ssh from your desktop/laptop to the shuttle.  For example, if I am using "shuttle0", then I know from  Robotics Computation Lab that this is IP address 192.168.11.50, so I can ssh like so...

ssh frl@192.168.11.50

Again - you will need to adjust the IP address for the shuttle you are trying to connect to.

Tutorial

Now see if you can go through the Running ROS across multiple machines tutorial using your desktop/laptop and the shuttle PC.  For example, if I am on the desktop "poke" with IP address 192.168.11.100 and working with "shuttle0" with IP address 192.168.11.50, then I could try running roscore and the listner on poke while running the talker on shuttle 0.  It might look like this...

Open a new terminal on your desktop/laptop and start rocore.

Open another terminal and run these command to setup the listener.

# Run this on the desktop with IP=192.168.11.100
export ROS_MASTER_URI=http://192.168.11.100:11311
export ROS_IP=192.168.11.100
export ROS_HOSTNAME=192.168.11.100
rosrun rospy_tutorials listener.py 

Open a third terminal, ssh onto the shuttle and run the talker...

ssh frl@192.168.11.50
export ROS_MASTER_URI=http://192.168.11.100:11311
export ROS_IP=192.168.11.50
export ROS_HOSTNAME=192.168.11.50
rosrun rospy_tutorials talker.py 

And you should see that your listener node is receiving messages. 

The rqt_graph looks like this...

where the nodes are distributed across two machines on the network.

Exercise 1: Wired Joystick Control

Follow the tutorial Joystick Control: Wired Control of Pioneer P3AT 
You will install the nre_joy package and then be able to drive your robot with a gamepad/joystick. 

Once you have this completed, you should see a view like this in rviz

and you should be able to drive the robot using the joystick (it is still up on blocks, but it will think it is moving).

Open a new terminal. In your mrc_hw6 directory, make a "data" directory and start recording a rosbag file called joypoints.bag.  Doing so will look something like this...

cd ~/catkin_ws/src/mrc_hw6
mkdir data
cd data
rosbag record --all --output-name=joypoints.bag

Using the joystick, manually drive your robot to all for red waypoints - in any order.  Accuracy is not important - just get close.

When you have visited all the waypoints, stop the rosbag recording using Cntrl-C.  

Add the joypoint.bag file to your git repository, commit and push.

Exercise 2: Post-Processing Wired Joystick Control

In MATLAB, create a new scipt file in the mrc_hw6/data directory.  Name the file joyplot.m

This script will process the joypoint.bag file from the last exercise, extracting the pose (position and velocity) and command data.  Below is the first part of such a script which illustrates how to extract the data from the ros messages.  You should be able to use this as-is and fill in the MATLAB plotting commands at the end of the file.

% joyplot.m
% Post processing P3AT data.


% Load the data file
bag = rosbag('joypoints.bag');
bag.AvailableTopics    % Prints the list of topics


% Extract pose data
bagPose = select(bag,'Topic','/my_p3at/pose')
%msg = readMessages(bagPose);
tsPose = timeseries(bagPose,'Pose.Pose.Position.X', ...
    'Pose.Pose.Position.Y', ...
    'Twist.Twist.Linear.X', ...
    'Twist.Twist.Angular.Z');


% Extract command data
bagCmd = select(bag,'Topic','/my_p3at/cmd_vel')
%msg = readMessages(bagCmd);
tsCmd = timeseries(bagCmd,'Linear.X', ...
    'Angular.Z');


% Plotting...

 

Complete the script so that it generates two plots that similar to the two figures below.

Figure 1: Plot of Pioneer Position

Figure 2: Pioneer velocity.  The "cmd vel" is the velocity published by the joystick to the robot.  The "pose" is the estimated velocity published by the robot, based on the encoders.  Why are these velocities different?

Save these two figures to your mrc_hw6/data directory as position.png and velocity.png respectively.

Add the files (joyplot.m, position.png and velocity.png) to your git repository, commit and push.

Exercise 3: Wireless Joystick Control

Follow the tutorial Pioneer P3AT Wireless Joystick Control.  After completing the tutorial you should be able to drive your Pioneer around the lab wirelessly. (Note: Now you can take the robot off its stand and drive around!)

Now repeat Exercise 3, but using wireless control.  Record another bag file on your computer (in the mrc_hw6/data directory) called wirelesspoitns.bag.
You can use the rviz visualization and watch the robot to dry and manually drive a rough 4 m x 4 m box.

You should be able to use the same plotting script (joyplot.m) to post-process the data and generate the same two figures above.  Save these files in the mrc_hw6 directory as position2.png and velocity2.png respectively.

When you are done add, commit and push the three files: wirelesspoints.bag, position2.png and velocity2.png.

Summary

When you have finished the assignment your mrc_hw6 your directory tree should look like this...

 

 

  • No labels