PR2 Optical (IR) Beam Sensor
This is an instruction of setting up the optical (IR) beam sensor, for both hardware and software, on an actual PR2 robot.
Attach the sensor according to the following photo:
Several important things:
- When the LED on the gripper is facing up, the emitter (with 4 transparent diodes) should be installed on the left finger, and the receiver (with 4 black diodes) is on the right finger.
- The emitter should be installed before the receiver on each gripper. This is to make sure the emitter can draw enough power from the motor control board. If later on you found the sensors are not working correctly, you may want to try doing this in the correct order again.
- Remember to insert the FFC cable into the connector on the sensor.
Software Setup (Fuerte)
cd ~ rosinstall optical_ws /opt/ros/fuerte/ https://bitbucket.org/uwsensors/pr2_pretouch_sensor_optical/raw/fuerte-dev/pr2_sensor_optical.rosinstall source optical_ws/setup.bash rosmake pr2_robot rosmake pr2_ethercat_drivers rosmake pr2_pretouch_sensor_optical
Overlay this workspace on top of your environment automatically on new terminals by adding this to your .bashrc:
Software Setup (Hydro)
cd ~ mkdir optical_ws && cd optical_ws wstool init src https://bitbucket.org/uwsensors/pr2_pretouch_sensor_optical/raw/hydro-dev/pr2_sensor_optical.rosinstall cd src && wstool update -j8 cd .. && rosdep install --from-paths src -i -y catkin_make
Overlay this workspace on top of your environment or add this to your .bashrc file:
Upgrade the gripper (WG006) firmware (Do it only once)
Important: this step only needs to be done once on each PR2 robot. The upgrade will be persistent. Please make sure the robot is not running (robot stop), and the robot's power cable is plugged into the outlet. Otherwise this firmware upgrade may brick the gripper's motor control board.
Power cycle the PR2 to make this upgrade effective.
Upload the Picoblaze firmware for the gripper’s FPGA (Do it everytime the robot is power-cycled)
If this is the first time you do this, you need to compile the picoasm binary:
cd pr2_ethercat_drivers/wg006_fingertip_dev/picoasm make
Run this bash script to upload the firmware for the standard pressure sensors which came with the PR2:
The firmware is not persistent, and will be lost if the robot is power-cycled. To make it persistent, one way is to call the above script into the system startup script.
Start the Optical Sensor Publisher
Start the Robot, and verify the raw data is published.
robot start rostopic list | grep raw_pressure
Start the optical sensor publisher:
roslaunch pr2_pretouch_sensor_optical optical_pretouch_both_gripper.launch
rostopic echo /optical/right
header: seq: 809 stamp: secs: 1396376917 nsecs: 471429109 frame_id: '' data: [768, 780, 744, 792] broken: [False, False, False, False]
Verify the sensor data for the left gripper in the same way:
rostopic echo /optical/left
Visualize the sensor readings
Run a realtime visualization of the sensor readings for verifying the sensor. The photo below shows the suitable configuration for testing. You may want to run this program on a workstation other than the robot and set the ROS_MASTER_URI to the robot. Alternatively you can run it in a
ssh -X session.
rosrun pr2_pretouch_sensor_optical visualizer.py
How to use the sensor data
The sensor data is published to the
/optical/left topics as a OpticalBeams message.
Header header uint16 data bool broken
You can simply subscribe to the topics to receive the data. The data rate is 500 Hz.