Difference between revisions of "RSDK Shell"

From sdk-wiki
Jump to: navigation, search
Line 3: Line 3:
  
 
The SDK provides a convenient script, baxter.sh, which helps foster the quickest and easiest ROS environment setup to get communicating with Baxter. This script should have been installed/configured during [[Workstation_Setup | Getting Started - Workstation Setup Tutorial]], and the [[Hello_Baxter | Getting Started - Hello Baxter! Tutorial]]
 
The SDK provides a convenient script, baxter.sh, which helps foster the quickest and easiest ROS environment setup to get communicating with Baxter. This script should have been installed/configured during [[Workstation_Setup | Getting Started - Workstation Setup Tutorial]], and the [[Hello_Baxter | Getting Started - Hello Baxter! Tutorial]]
 +
 +
=== Quick Environment Setup Via Baxter.sh ===
 +
$ cd ~/ros_ws
 +
$ ./baxter.sh
 +
</syntaxhighlight>
  
  

Revision as of 19:00, 9 May 2014

To communicate with and command Baxter, we must establish the connection between your development PC and the robot and vice versa. Assuming proper network setup, the RSDK shell refers to the a configuration of your ROS environment which points your PC to the ROS Master, while registering your IP or Hostname allowing other processes to find you.


The SDK provides a convenient script, baxter.sh, which helps foster the quickest and easiest ROS environment setup to get communicating with Baxter. This script should have been installed/configured during Getting Started - Workstation Setup Tutorial, and the Getting Started - Hello Baxter! Tutorial

Quick Environment Setup Via Baxter.sh

$ cd ~/ros_ws $ ./baxter.sh </syntaxhighlight>


The current recommended environment setup: Baxter.sh ROS Environment Setup

    The baxter.sh script is a convenient script which allows for intuitive modification of the core ROS environment components. This user edited script will allow for the quickest and easiest ROS setup.

    Checkout Convenient baxter.sh script

    $ cd ~/ros_ws
    $ wget https://raw.github.com/RethinkRobotics/baxter/master/baxter.sh
    $ chmod +x baxter.sh

    Customize the baxter.sh script

    Please edit the baxter.sh shell script making the necessary modifications to describe your development PC.

    Using your favorite editor (gedit used for example)

    $ cd ~/ros_ws
    $ gedit baxter.sh


    Edit the 'baxter_hostname' field

    Please edit the 'baxter_hostname' field:

    # Specify Baxter's hostname
    **baxter_hostname="baxter_hostname.local"**

    Modifying where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]

    Edit 'your_ip' OR 'your_hostname' field

    Please edit the 'your_ip' field (only if not using 'your_hostname'):

    **your_ip="192.168.XXX.XXX"**

    Modifying where 'your_ip' is the IP address of your PC.

    Useful command for identifying your IP address:

    $ ifconfig
    # Result will be contained in the 'inet addr' field (Ubuntu) or 'inet' field (Gentoo Robot PC).

    Important: Only set either ROS_IP *OR* ROS_HOSTNAME.

    Setting of both ROS_IP and ROS_HOSTNAME will result in ROS_HOSTNAME taking priority, resulting in confusing environment setups. Comment out the unused method using the '#' as leading character.

    Alternatively, you may choose to use the hostname of your development PC.

    Please edit the 'your_hostname' field (only if not using 'your_ip'):

    ***your_hostname="my_computer.local***

    Modifying where 'your_hostname' is the hostname of your PC.

    Important: This hostname must be resolvable to Baxter. To test if your hostname is resolvable to Baxter, please visit the development PC Hostname Validation page.

    Edit 'ros_version' field

    Please edit the 'ros_version' field:

    ***ros_version="groovy"***

    Modifying where 'ros_version' is the your chosen ROS release.

    Save and Close baxter.sh script

    Please save and close the baxter.sh script.

    Initialize your SDK environment

    From this point forward, your ROS environment setup should be as simple as running the baxter.sh script from the root of your Catkin workspace:

    $ cd ~/ros_ws
    $ ./baxter.sh


    It will be necessary to enable communication between the development PC and the robot and vice versa. This section largely follows ros.org's Installation and Configuration of ROS Environment page.

    To do so, we will edit our ~/.bashrc script which is evoked with new shell instances.

    Customize your ~/.bashrc

    Please edit the ~/.bashrc to set the ROS environment variables necessary for communication with Baxter.

    Using your favorite editor (gedit used for example)

    $ gedit ~/.bashrc

    At the bottom of your ~/.bashrc script add the following:

    Source ROS setup.bash

    A ROS environment script is packages will all standard ROS installation. This script will set the standard basic ROS environment variables.

    Please add the following to the bottom of your ~/.bashrc script.

    If using ROS Groovy:

    source /opt/ros/groovy/setup.bash

    If using ROS Hydro:

    source /opt/ros/hydro/setup.bash

    Set ROS_MASTER_URI

    ROS_MASTER_URI - Allows the development PC to locate the master. This will typically be the hostname of the robot.

    Please add the following to the bottom of your ~/.bashrc script.

    export ROS_MASTER_URI=http://baxter_hostname:11311

    Where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]

    Set ROS_MASTER_URI

    ROS_MASTER_URI - Allows the development PC to locate the master. This will typically be the hostname of the robot.

    Please add the following to the bottom of your ~/.bashrc script.

    export ROS_MASTER_URI=http://baxter_hostname:11311

    Where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]

    Set ROS_IP *OR* ROS_HOSTNAME

    It will be necessary for other processes to be able to communicate to and from your development PC. For this reason, setting ROS_IP or ROS_HOSTNAME advertises your node for networked communication.

    Please add the ROS_IP (only if not using ROS_HOSTNAME):

    export ROS_IP='192.168.XXX.XXX'

    Modifying where 'your_ip' is the IP address of your PC.

    Useful command for identifying your IP address:

    $ ifconfig
    # Result will be contained in the 'inet addr' field (Ubuntu) or 'inet' field (Gentoo Robot PC).

    Important: Only set either ROS_IP *OR* ROS_HOSTNAME.

    Alternatively, you may choose to use the hostname of your development PC.

    Please edit the ROS_HOSTNAME field (only if not using ROS_IP):

    export ROS_HOSTNAME='your_hostname'

    Modifying where 'your_hostname' is the hostname of your PC.

    Important: This hostname must be resolvable to Baxter. To test if your hostname is resolvable to Baxter, please visit the development PC Hostname Validation page.

    Save and Close ~/.bashrc

    Please save and close your ~/.bashrc

    Initialize your SDK environment

    From this point forward, your ROS environment setup should be preconfigured upon startup of all new terminals (shells). Important: You will still need to source your development workspace (~/ros_ws/devel/setup.bash) setup script when compiling code from source in your Catkin workspace - following our setup this will be ~/ros_ws.

    Please close your current terminal, and reopen a new terminal instance.


    Checkout Convenient Baxter Environment Setup Script

    $ wget https://raw.github.com/RethinkRobotics/baxter/master/baxter.sh
    $ chmod +x baxter.sh

    <<


    Description: The baxter.sh script creates a heredoc which verifies all environment variables expected are provided. This subshell creates displays custom prompt modifications (with color) for quick visual checks. Handy arguments are available to access particular ROS setups quickly (simulation, and local). ]


    To do so, we will edit our ~/.bashrc script which is evoked with new shell instances.

    Customize your ~/.bashrc

    Please edit the ~/.bashrc to set the ROS environment variables necessary for communication with Baxter.

    Using your favorite editor (gedit used for example)

    $ gedit ~/.bashrc

    At the bottom of your ~/.bashrc script add the following:

    Source ROS setup.bash

    A ROS environment script is packages will all standard ROS installation. This script will set the standard basic ROS environment variables.

    Please add the following to the bottom of your ~/.bashrc script.

    If using ROS Groovy:

    source /opt/ros/groovy/setup.bash

    If using ROS Hydro:

    source /opt/ros/hydro/setup.bash

    Set ROS_MASTER_URI

    ROS_MASTER_URI - Allows the development PC to locate the master. This will typically be the hostname of the robot.

    Please add the following to the bottom of your ~/.bashrc script.

    export ROS_MASTER_URI=http://baxter_hostname:11311

    Where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]

    Set ROS_MASTER_URI

    ROS_MASTER_URI - Allows the development PC to locate the master. This will typically be the hostname of the robot.

    Please add the following to the bottom of your ~/.bashrc script.

    export ROS_MASTER_URI=http://baxter_hostname:11311

    Where 'baxter_hostname' is the [[Robot_Hostname hostname of your robot]

    Set ROS_IP *OR* ROS_HOSTNAME

    It will be necessary for other processes to be able to communicate to and from your development PC. For this reason, setting ROS_IP or ROS_HOSTNAME advertises your node for networked communication.

    Please add the ROS_IP (only if not using ROS_HOSTNAME):

    export ROS_IP='192.168.XXX.XXX'

    Modifying where 'your_ip' is the IP address of your PC.

    Useful command for identifying your IP address:

    $ ifconfig
    # Result will be contained in the 'inet addr' field (Ubuntu) or 'inet' field (Gentoo Robot PC).

    Important: Only set either ROS_IP *OR* ROS_HOSTNAME.

    Alternatively, you may choose to use the hostname of your development PC.

    Please edit the ROS_HOSTNAME field (only if not using ROS_IP):

    export ROS_HOSTNAME='your_hostname'

    Modifying where 'your_hostname' is the hostname of your PC.

    Important: This hostname must be resolvable to Baxter. To test if your hostname is resolvable to Baxter, please visit the development PC Hostname Validation page.

    Save and Close ~/.bashrc

    Please save and close your ~/.bashrc

    Initialize your SDK environment

    From this point forward, your ROS environment setup should be preconfigured upon startup of all new terminals (shells). Important: You will still need to source your development workspace (~/ros_ws/devel/setup.bash) setup script when compiling code from source in your Catkin workspace - following our setup this will be ~/ros_ws.

    Please close your current terminal, and reopen a new terminal instance.

    </tab> </tabs>

    A useful command for viewing and validating your ROS environment setup:

    $ env | grep ROS

    The important fields at this point:

    ROS_MASTER_URI - This should now contain your robot's hostname.

    ROS_IP *OR* ROS_HOSTNAME - This should contain either your IP address or hostname which is resolvable to Baxter.

    We will verify your network setup in the Next Step: Hello Baxter!


    Prerequisites

    Outcome of this step

    • You have successfully initialized a shell giving you the ability to enable/disable Baxter.

    Overview

    To properly communicate with Baxter two way communication must occur between the robot and the development workstation. This requires correctly setting the development workstation's ROS Environment Variable. A convenience script, init.sh, has been created to properly set majority of the required environment variables. With proper usage, running init.sh will be the only step required to communicate with Baxter from any new shell instance.

    Initialize

    1. Initialize your environment: For each new Terminal, substitute your robot's hostname or IP address for <robot_hostname>:

        $ cd ~/ros_ws
        $ ./init.sh <robot_hostname>

    You will see that your current shell prompt will be prefixed with:

        [ros - http://<robot_hostname>:11311]username@machine$

    This allows you to quickly view if you shell has been init'd or not, and to which robot you are currently addressing (<robot_hostname>)

    2. Export your ROS_HOSTNAME or ROS_IP: For each new terminal, substitute your development workstation's hostname or IP address for <workstation_hostname>

        $ export ROS_HOSTNAME=<workstation_hostname>

    Alternatively if your workstation_hostname is not resolvable to Baxter, you will be required to set your ROS_IP environment variable explicitly to your development workstation IP address.

        $ export ROS_IP=<workstation_ip_address>

    Important ROS_HOSTNAME will take precedence over ROS_IP. If you choose to explicitly set your ROS_IP you must unset your ROS_HOSTNAME.

        $ unset ROS_HOSTNAME

    For more information visit ROS_IP/ROS_HOSTNAME

    3. Optional (Recommended) export ROS_HOSTNAME/ROS_IP to be persistent when starting a new shell (eliminates step 2, exporting ROS_IP/ROS_HOSTNAME for every new shell).

        $ echo "export ROS_HOSTNAME=<workstation_hostname>" >> ~/.bashrc
        = OR =
        $ echo "export ROS_IP=<workstation_ip_address>" >> ~/.bashrc
        $ source ~/.bashrc

    Test your ability to command the robot

    1. Build all the example code (only need to do this once):

        $ rosmake baxter --pre-clean

    2. Enable the robot

        $ rosrun tools enable_robot.py -e

    The robot is now active. You may now grasp Baxter's arms freely by grasping the cuffs at the hands.

    2. Disable the robot

        $ rosrun tools enable_robot.py -d

    You should visibly see Baxter's arms gently fall and will no longer have the ability to move the arms freely.

    Troubleshooting

    Verify ability to ping robot.

    Ping what you have previously set as your robot_hostname.

        $ ping <robot_hostname>
        # ex.
        $ ping 011304P0026

    If unable to ping the robot visit this page.

    Timeout observed when trying to enable the robot.

    Assuming that you are able to $rostopic echo /rosout during these prerequisite instructions. This error is a sign of the inability to make commands to the robot. This is due to your ROS_HOSTNAME/ROS_IP being set incorrectly.

    View the ROS_ENVIRONMENT set for your current shell.

        $ env | grep ROS

    Verify that either the ROS_HOSTNAME or ROS_IP is set for your development workstation.

    If unsuccessful and the ROS_HOSTNAME is set, please unset this variable and use ROS_IP.

        $ unset ROS_HOSTNAME
        $ export ROS_IP=<your_development_workstation_ip>

    Note: You can always view your current development workstation IP address using

        $ ifconfig

    If unsuccessful and the ROS_IP is set, verify that this is describes your ip address and not the robot ip address.

        # Verify ROS_HOSTNAME is unset
        $ unset ROS_HOSTNAME
        # Take note of your IP address
        $ ifconfig
        # Export this as your ROS_IP
        $ export ROS_IP=<your_development_workstation_ip>