ahpr2

ahpr2

Robot status page: http://wgsf1.willowgarage.com/robot_status/
Robot scheduling:  https://home.willowgarage.com/wgwiki/PR2%20Scheduling%20page

OBSOLETE: To setup ssh and mybin on a new robot run:  pr2-setup <robotname>
         SEE BELOW FOR NEWER

===============================================
SCRIPT
===============================================
TO RUN IT ALL WITH A SCRIPT:

local
    przis <name of robot -- e.g. prk>
    przis prk
    przis pr1041

UNTUCK ARMS (use runstop)

sshz
    robot start

local
    pr2_demo1
    in commander window:  d4

===============================================
CONDENSED
===============================================
local
    przis <name of robot -- e.g. prk>
    przis prk
    przis pr1041

sshz
    robot claim
    robot stop
    robot start
    name OPENNI
    roslaunch openni_launch openni.launch camera:=head_mount_kinect depth_frame_id:=head_mount_kinect_ir_optical_frame publish_tf:=false depth_registration:=true

local
    prz
    name `przname` RQT
    rosrun rqt_pr2_dashboard rqt_pr2_dashboard

sshz2
    name XSERVER
    sudo /usr/bin/X :0

sshz2
    name MOVEGROUP
    unset DISPLAY
    roscd pr2_moveit_config
    # FOR SUATs NEW ADVANCED UPDATER THAT USES GL
    roslaunch pr2_advanced_config move_group.launch
    # FOR THE OLD SLOW PUBLIC UPDATER:
    roslaunch pr2_moveit_config move_group.launch

local
    sr6
    prz
    name `przname` RVIZ
    roslaunch pr2_moveit_config moveit_rviz.launch command_args:="-d $HOME/.rviz/prk_moveit.rviz"

sshz
    name COMMANDER
    roscd moveit_commander
    bin/moveit_commander_cmdline.py 
    d4
    stop with CTRL- (ctrl-backslash)

sshz
    name KEY TELEOP
    roslaunch pr2_teleop_general pr2_teleop_general_keyboard.launch

sshz
    name JOY TELEOP
    roslaunch pr2_teleop_general pr2_teleop_general_joystick.launch

    joystick controls:
    TO TUCK EVERYTHING:
        R1+L to turn off laser scanner
        R1+R to turn off projector
        R2+L2+SQUARE to close gripper
        R2+L2+R to fold arms
        L1+X to lower torso

    BODY (L1)
        TRI/X - torso up/down
    HEAD (R1)
        U -- toggle head mode: left, right, mannequin, joystick
        L - toggle lazer scanner slow/fast/off
        R - toggle projector
        D - togle prosilica poll (?)
    ARM (L2/R2)
        ljoy - up/down (x)
        rjoy - move (x/y)
        CIRCLE/SQUARE - open/close gripper
        TRI/X - rotate wrist
        U - 
        L - unfold both arms
        R - unfold arms into start position
        D - 
    BOTHARM (L2+R2)
        R - fold arms (close gripper first for best results)
        L - unfold both arms
        U - arm mode: manequin->drift->controlled

Mannequin mode -- This will mess up the controllers and you will have to reset them by running KEY TELEOP
sshz
    name MANNEQUIN
    roslaunch pr2_mannequin_mode pr2_mannequin_mode.launch

================================================
NEW PR2 SETUP  (also works for desktops/laptops)
================================================
ssh root@robotname
    adduser acorn
    edit /etc/group and add acorn to admin and sudo
    exit
ssh acorn@robotname
    when prompted about ssh keys answer Y

cd
wget http://www.rawbw.com/~acorn/bootstrap.bash
bash ./bootstrap.bash

cd
rm setup.bash
echo 'export ROS_ENV_LOADER=/etc/ros/groovy/env.sh' >> setup.bash
echo 'source /opt/ros/groovy/setup.bash' >> setup.bash
echo 'source $HOME/l/ros6/devel/setup.bash' >> setup.bash
rm .local_bashrc
echo 'source $HOME/setup.bash' >> .local_bashrc

source /opt/ros/groovy/setup.bash
sudo apt-get update
sudo apt-get install python-wstool ros-groovy-moveit-source-build-deps ros-groovy-pr2-mechanism libglew1.6-dev ros-groovy-rqt-pr2-dashboard ros-groovy-pr2-apps
mkdir -p l/ros6/src
ln -s l/ros6 .ros6
cd l/ros6/src
wstool init .
wstool merge https://raw.github.com/ros-planning/moveit_docs/groovy-devel/moveit.rosinstall
wstool update
cd ..
catkin_make
# NOTE: need to build above stuff BEFORE cloning moveit_advanced
cd src
cat ~/.ssh/id_rsa.pub
copy paste key to https://github.com/settings/ssh
git clone git@github.com:willowgarage/moveit_advanced.git
cd ..
catkin_make
source $HOME/setup.bash
sudo rosdep init
rosdep update

cd $HOME/l/ros6/src
mkdir -p moveit_commander/cmd
cp $HOME/mybin/settings/pr2/moveit_commander/cmd/[a-z]* moveit_commander/cmd

================================================
Other crap follows
================================================


XXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXX

==========================================
==== Simple robot startup (no moveit) ====
==========================================
Use a robot with groovy.  See status page.

Logon to robot:  ssh acorn@prk  (replace prk with name of robot)

On robot run:
    robot claim    # claim robot for my use & check no one else is using it

When done run:
    robot stop     # kills all processes
    robot release  # let others use it

See my password page for passwords.


On LOCAL MACHINE (not robot) run:
    source /opt/ros/groovy/setup.bash
    export ROS_MASTER_URI=http://prk1:11311       # use name of robot
    rosrun rqt_pr2_dashboard rqt_pr2_dashboard

To set up robot to run (turn everything on) run (on the robot) 'robot start' or
    source /opt/ros/groovy/setup.bash
    export ROS_ENV_LOADER=/etc/ros/groovy/env.sh
    rosdep update
    roslaunch /etc/ros/groovy/robot.launch

Teleop: (arms, body, head) run this on the robot:
    source /opt/ros/groovy/setup.bash
    roslaunch pr2_teleop_general pr2_teleop_general_joystick.launch
      or
    roslaunch pr2_teleop_general pr2_teleop_general_keyboard.launch

    Use joystick (or keyboard) to drive robot and move arms.


    
MOVEIT
    on robot:
    source /home/acorn/ros5/devel/setup.bash
    roscd pr2_moveit_config
    roslaunch launch/move_group.launch

    on robot:
    source /home/acorn/ros5/devel/setup.bash
    /home/acorn/ros5/devel/lib/python2.7/dist-packages/moveit_ros_planning_interface:$PYTHONPATH
    cd /home/acorn/ros5/src/moveit_commander
    ./bin/moveit_commander_cmdline.py
    





On robot prk (or any other) there are 2 computers
    prk  - alias to prk1
    prk1 - first computer
    prk2 - second computer
On every robot c1 and c2 are local alias of the first & second computer


To create an account on a new robot:
   ssh root@robotname
   adduser acorn
   exit
   ssh acorn@robotname
     when prompted about ssh keys answer Y


==================================
==== Robot startup and moveit ====
==================================

========================
Turning on perception:
ONE TIME SETUP
--------------
ONLY ONCE per robot on computer2:
    ssh root@prk2
    password is willow
    add "acorn" to /etc/group to admin group

in bashrc:
    export ROS_ENV_LOADER=/etc/ros/groovy/env.sh

PER DEMO
--------
do this to set up groovy and my workspace:
on prk1:
    sr6
    robot start

on local machine:
    sr6
    export ROS_MASTER_URI=http://prk1:11311
    rosrun rqt_pr2_dashboard rqt_pr2_dashboard
    click first 2 icons
    if necessary:
        unpush red stop button on robot
        push red then green button on yellow estop
        may need to replace estop battery (AA rechargeanle)
        gear->reset
        L->enable all breakers
        B->enable all breakers
        R->enable all breakers

on prk1:
    roslaunch openni_launch openni.launch camera:=head_mount_kinect depth_frame_id:=head_mount_kinect_ir_optical_frame publish_tf:=false depth_registration:=true
    # This starts the primesense openni (kinect) driver and published depth images
    # ask John  Binney if problems


Start X server on prk2
on prk2:
    sudo /usr/bin/X :0



start movegroup on prk2:
    sr6
    unset DISPLAY (or set it to :0)
    roscd pr2_moveit_config
    roslaunch launch/move_group.launch

TODO: update acornwg_moveit_init to use moveit_ros and moveit_core from proper repo
TODO: use advanced repo for moveit_core
TODO: use wg_pvt repo for moveit_ros

LOCAL MACHINE: SETUP ALIAS
    alias prk='export ROS_MASTER_URI=http://prk1:11311'

Local machine: start rviz and/or moveit_commander
    To start rviz on local machine:
        sr6
        export ROS_MASTER_URI=http://prk1:11311
        roscd pr2_moveit_config
        roslaunch launch/moveit_rviz.launch command_args:="-d $HOME/.rviz/prk_moveit.rviz"
        Add a MotionPlanning display
        set GlobalOptions->FixedFrame = /odom_combined
        set MotionPlanning->PlanningRequest->PlanningGroup = arms
        set MotionPlanning->PlanningSceneTopic = /move_group/monitored_planning_scene
        uncheck MotionPlanning->PlanningRequest->QueryStartState
        check MotionPlanning->PlanningRequest->QueryGoalState
        in MotionPlanning frame click planning tab
            in Query choose SelectStartState, set spinner to <current> and click Update
            


on prk1
    sr6
    roscd moveit_commander
    bin/moveit_commander_cmdline.py 


on prk1
    sr6
    roscd pr2_teleop_general
    roslaunch pr2_teleop_general pr2_teleop_general_joystick.launch


========================================================
PR2 networking
========================================================
pr2 service port allows access from any computer with ethernet.  Connect ethernet cable (no crossover cable required).  ssh to the pr2 by name.  (If you do not know the name try
    10.68.0.1  - c1 lan0
    10.68.0.11 - c1 lan1
    10.68.0.2  - c2 lan0
    10.68.0.12 - c2 lan1

A PR2 named prx generally has a ssid of prxlan.
Usually no password.
Configure this by getting onto pr2 (e.g. through service port) and point web browser at
    10.68.0.250
    password: willow
Set up router to allow access.  c0 acts as dhcp server, so keep DHCP server DISABLED on the router.

To allow pr2 to connect to internet (or other external wifi network), connect (e.g. via serviceport) to robot and point browser at
    10.68.0.5
    user: root
    password: willow
configure one of the 2 radios (usually the one on top) to point to the wireless network you want the PR2 to connect to.  Now PR2 can get to internet.

IMPORTANT: if you do this, disable multi-interface roaming via
    sudo /etc/init.d/multi_interface_roam stop
Otherwise all traffic will be routed to (nonexistant) basestation and will silently disappear).


========================================================
PR2 Controllers
========================================================
rosrun pr2_controller_manager pr2_controller_manager -h

allows listing, loading, starting, stopping controllers


========================================================
PR2 Calibration
========================================================
http://www.ros.org/wiki/pr2_calibration/Tutorials/Calibrating%20the%20PR2
http://ros.org/wiki/pr2_calibration/Tutorials/Calibrating%20the%20PR2%27s%20Cameras
http://ros.org/wiki/camera_calibration/Tutorials/StereoCalibration
http://ros.org/wiki/camera_calibration/Tutorials/MonocularCalibration
http://ros.org/wiki/pr2_bringup_tests/calibration_bringup


sudo apt-get install ros-groovy-pr2-calibration

Use size appropriate for checkerboard you use.  size is number of internal corners (number of squares minus 1)

Run one of these to move the head:
sshz
    name JOY TELEOP
    roslaunch pr2_teleop_general pr2_teleop_general_joystick.launch
    roslaunch pr2_mannequin_mode pr2_mannequin_mode.launch

--------------
STEREO CAMERAS
--------------
narrow stereo camera calibration:
sshz
    rosrun camera_calibration cameracalibrator.py --size=8x6 --square=0.108 left:=narrow_stereo/left/image_raw right:=narrow_stereo/right/image_raw left_camera:=narrow_stereo/left right_camera:=narrow_stereo/right __name:=calibration_gui

    move checkerboard to various locations.  Color circles will appear when it is recognized.
    when enough samples have been taken "CALIBRATE" button lights
    press CALIBRATE to calibrate (see results in terminal)
    press COMMIT to save results to camera

repeat for wide stereo calibration:
    rosrun camera_calibration cameracalibrator.py --size=8x6 --square=0.108 left:=wide_stereo/left/image_raw right:=wide_stereo/right/image_raw left_camera:=wide_stereo/left right_camera:=wide_stereo/right __name:=calibration_gui


place checkerboard 2-3m from cameras and test calibrarion:

    rosrun camera_calibration cameracheck.py stereo:=wide_stereo --size=8x6 --square=0.108
    rosrun camera_calibration cameracheck.py stereo:=narrow_stereo --size=8x6 --square=0.108
or with small checkerboard:
    rosrun camera_calibration cameracheck.py stereo:=narrow_stereo --size=5x4 --square=0.025

------------
MONO CAMERAS
------------
    rosrun camera_calibration cameracalibrator.py --size=8x6 --square=0.108 --size=5x4 --square=0.25 image:=/l_forearm_cam/image_raw camera:=/l_forearm_cam

    rosrun camera_calibration cameracalibrator.py --size=8x6 --square=0.108 --size=5x4 --square=0.25 image:=/r_forearm_cam/image_raw camera:=/r_forearm_cam

    rosrun camera_calibration cameracheck.py monocular:=r_forearm_cam --size=5x4


---------------
ARM CALIBRATION
---------------

sshz
    robot start
    name OPENNI
    roslaunch /etc/ros/openni_head.launch

prz
    name RQT
    pr2_rqt_dashboard

sshz
    name CALIBRATION
    roslaunch pr2_calibration_launch capture_data.launch

    Follow instructions.
    DO NOT RUN TELEOP.  Joystick teleop is run by capture_data.launch.  Use left 2 triggers to move head.
    Place large grid in 4 places: to left, to right, in front, and on ground.
    Best: find one place that works for checkboard and then rotate robot (do not move board).
    If floor does not work after a few tries, skip it.

    When it says it is done, hit ^C

sshz  (can use openni window -- ^C it)
    robot stop
    roscore

sshz
    cd
    rm -rf pr2_calibration_new
    mkdir pr2_calibration_new
    cd pr2_calibration_new
    rosrun pr2_calibration_launch estimate_pr2_beta_urdf.sh


To test the calibration:
sshz
    rosrun pr2_calibration_launch view_head_laser_scatter.sh
    rosrun pr2_calibration_launch view_head_arm_scatter.sh
    rosrun pr2_calibration_launch view_forearm_scatter.sh


To use the newly generated urdf:
    Name of generated file will be robot_calibrated_[DATE]_[VERSION].xml
    as root:
        cd ~acorn/pr2_calibration_new
        export urdfname=robot_calibrated_[DATE]_[VERSION].xml
        cp $urdfname /etc/ros/groovy/urdf/$urdfname
        cd /etc/ros/groovy/urdf
        ln -fs $urdfname robot.xml

sshz
    robot start
    rosrun pr2_calibration_launch write_pr2_cam_intrinsics.sh

    rm /etc/ros/plugs/calibration.yaml
        
    robot stop
    robot start

    # Robot is now using calibrated settings

    test calibration:
    http://ros.org/wiki/pr2_bringup_tests/calibration_bringup