Difference between pages "Workstation Setup" and "Head Display Image Example"

(Difference between pages)
Jump to: navigation , search
(Edit the 'robot_hostname' field)
 
(Arguments)
 
Line 1: Line 1:
__NOTOC__
 
 
<div class="title-block">
 
<div class="title-block">
<span style="font-size:120%;">'''This tutorial describes the setup of a development workstation'''</span>
 
</div>
 
 
<div class="content-block">
 
== Required Hardware ==
 
* 1 Sawyer Robot
 
* 1 Development Workstation (Meeting [[System_requirements | Minimum System Requirements]])
 
</div>
 
<div class="content-block">
 
== Step 1: Install Ubuntu ==
 
 
'''Current required version: Ubuntu 14.04'''
 
 
Follow the standard Ubuntu Installation Instructions for 14.04 (Desktop):
 
* Download the Installer Image file, by picking the "[http://releases.ubuntu.com/trusty/ Desktop CD]" image appropriate for your machine:
 
** [http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-amd64.iso 64-bit (AMD64) .iso image (recommended)] / [http://releases.ubuntu.com/trusty/ubuntu-14.04.4-desktop-i386.iso 32-bit (Intel x86) .iso image]
 
 
* Create an Ubuntu LiveUSB installer by burning the installer image onto a USB stick.
 
** [http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows Windows] / [http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx Mac OS X] / [http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu Ubuntu]
 
* Follow the [https://help.ubuntu.com/community/GraphicalInstall Ubuntu Installation Instructions]
 
  
 +
<span style="font-size:120%;">'''Displays a given image file or multiple files on the robot's face.'''</span>
  
 
</div>
 
</div>
Line 27: Line 7:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 2: Install ROS ==
+
== Introduction ==
 
 
Current supported version: ROS Indigo
 
 
 
=== Configure Ubuntu repositories ===
 
  
Configure your Ubuntu repositories to allow "restricted," "universe," and "multiverse." You can follow [https://help.ubuntu.com/community/Repositories/Ubuntu the Ubuntu guide] for instructions on doing this.<br />
+
The camera display example demonstrates how to pass image file(s) to robot head for display. The example read and convert image file(s) using <code>cv_bridge</code>, sending the image info to the robot head screen as a standard ROS Image Message.
 
 
''Likely, they are already configured properly, and you only need to confirm the configuration.''
 
 
 
=== Setup your sources.list ===
 
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu trusty main" > /etc/apt/sources.list.d/ros-latest.list'
 
</syntaxhighlight>
 
 
 
=== Setup your keys ===
 
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ wget http://packages.ros.org/ros.key -O - | sudo apt-key add -
 
</syntaxhighlight>
 
 
 
=== Verify Latest Debians ===
 
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ sudo apt-get update
 
</syntaxhighlight>
 
 
 
=== Install ROS Indigo Desktop Full ===
 
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ sudo apt-get install ros-indigo-desktop-full
 
</syntaxhighlight>
 
 
 
'''NOTE:''' You may get a prompt about 'hddtemp' during the installation. You can safely answer 'No'.
 
 
 
=== Initialize rosdep ===
 
 
 
rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS.
 
<syntaxhighlight lang="bash" enclose="div">
 
$ sudo rosdep init
 
$ rosdep update
 
</syntaxhighlight>
 
 
 
=== Install rosinstall ===
 
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ sudo apt-get install python-rosinstall
 
</syntaxhighlight>
 
 
</div>
 
</div>
  
 
<div class="content-block">
 
<div class="content-block">
  
== Step 3: Create Intera Development Workspace ==
+
== Usage ==
 
 
=== Create ROS Workspace ===
 
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ mkdir -p ~/ros_ws/src
 
# ros_ws (short for ROS Workspace)
 
</syntaxhighlight>
 
 
 
=== Source ROS and Build ===
 
 
 
'''ROS Indigo (Supported)'''
 
 
 
=== Source ROS Setup ===
 
  
 +
Run the example as following command:
 
<syntaxhighlight lang="bash" enclose="div">
 
<syntaxhighlight lang="bash" enclose="div">
$ source /opt/ros/indigo/setup.bash
+
$ rosrun intera_examples head_display_image.py -f <the path to image file to send>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Build ===
 
 
<syntaxhighlight lang="bash" enclose="div">
 
$ cd ~/ros_ws
 
$ catkin_make
 
</syntaxhighlight>
 
 
</div>
 
</div>
  
 
<div class="content-block">
 
<div class="content-block">
  
== Step 4: Install Sawyer SDK Dependencies ==
+
== Arguments ==
  
ROS Indigo (Supported)
+
'''Important Arguments:''' 
  
=== Install SDK Dependencies ===
+
<code> -f </code> or <code> --file </code>: File path for display.
  
<syntaxhighlight lang="bash" enclose="div">
+
<code> -l </code> or <code> --loop </code>: Display images in loop.
$ sudo apt-get update
 
$ sudo apt-get install git-core python-argparse python-wstool python-vcstools python-rosdep ros-indigo-control-msgs ros-indigo-joystick-drivers ros-indigo-moveit-full
 
</syntaxhighlight>
 
  
</div>
+
<code> -r </code> or <code> --rate </code>: The frequency for multiple and looped images.
  
<div class="content-block">
+
<syntaxhighlight lang="bash" enclose="div">
 
+
usage: head_display_image.py [-h] [-f FILE [FILE ...]] [-l] [-r RATE]
== Step 5: Install Sawyer Research Robot SDK ==
 
 
 
=== Install Sawyer SDK ===
 
  
Checkout all required Github Repositories into your ROS workspace source directory:
+
RSDK Head Display Example:
Use git clone or download the packages directly from Github:
 
  
<syntaxhighlight lang="bash" enclose="div">
+
    Displays a given image file or multiple files on the robot.s face.
$ cd ~/ros_ws/src
 
$ wstool init .
 
$ git clone https://github.com/RethinkRobotics/sawyer_robot.git
 
$ wstool merge sawyer_robot/sawyer_robot.rosinstall
 
$ wstool update
 
</syntaxhighlight>
 
  
=== Source ROS Setup ===
+
    Pass the relative or absolute file path to an image file on your
You must use ROS Indigo to use RSDK, use command below:
+
    computer, and the example will read and convert the image using
 +
    cv_bridge, sending it to the screen as a standard ROS Image Message.
 +
   
  
<syntaxhighlight lang="bash" enclose="div">
+
optional arguments:
# ROS Indigo
+
  -h, --help            show this help message and exit
$ source /opt/ros/indigo/setup.bash
+
  -l, --loop            Display images in loop, add argument will display
</syntaxhighlight>
+
                        images in loop
 +
  -r RATE, --rate RATE  Image display frequency for multiple and looped
 +
                        images.
  
=== Build ===
+
required arguments:
 +
  -f FILE [FILE ...], --file FILE [FILE ...]
 +
                        Path to image file to send. Multiple files are
 +
                        separated by a space, eg.: a.png b.png
  
<syntaxhighlight lang="bash" enclose="div">
+
Notes:
$ cd ~/ros_ws
+
    Max screen resolution is 1024x600.
$ catkin_make
+
    Images are always aligned to the top-left corner.
 +
    Image formats are those supported by OpenCv - LoadImage().
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 158: Line 69:
 
<div class="content-block">
 
<div class="content-block">
  
== Step 6: Configure Sawyer Communication/ROS Workspace ==
+
== Code Walkthrough ==
This step describes the configuration and setup of your [http://wiki.ros.org/ROS/EnvironmentVariables ROS environment]. This section assumes an already configured [[Networking | Network Setup]].
 
 
 
'''The current recommended environment setup: intera.sh ROS Environment Setup'''
 
 
 
"intera.sh ROS Environment Setup (Recommended)"
 
 
 
 
 
The intera.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.
 
 
 
Further information and a detailed description is available on the [[SDK_Shell]] page.
 
  
=== Copy the intera.sh script ===
+
Now, let's break down the code.
  
The intera.sh file already exists in intera_sdk repo, copy the file into your ros workspace.
+
<syntaxhighlight lang="python" line start="30" enclose="div">
<syntaxhighlight lang="bash" enclose="div">
+
import intera_interface
$ cp ~/ros_ws/src/intera_sdk/intera.sh ~/ros_ws
+
import argparse
 +
import rospy
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Customize the intera.sh script ===
+
This imports the intera interface for accessing the HeadDisplay class.
  
Please edit the intera.sh shell script making the necessary modifications to describe your development PC.
+
<syntaxhighlight lang="python" line start="34" enclose="div">
 
+
def main():
Using your favorite editor ([https://wiki.gnome.org/Apps/Gedit gedit] used for example)
+
    """RSDK Head Display Example:
<syntaxhighlight lang="bash" enclose="div">
+
    Displays a given image file or multiple files on the robot's face.
$ cd ~/ros_ws
+
    Pass the relative or absolute file path to an image file on your
$ gedit intera.sh
+
    computer, and the example will read and convert the image using
 +
    cv_bridge, sending it to the screen as a standard ROS Image Message.
 +
    """
 +
    epilog = """
 +
Notes:
 +
    Max screen resolution is 1024x600.
 +
    Images are always aligned to the top-left corner.
 +
    Image formats are those supported by OpenCv - LoadImage().
 +
    """
 +
    arg_fmt = argparse.RawDescriptionHelpFormatter
 +
    parser = argparse.ArgumentParser(formatter_class=arg_fmt,
 +
                                    description=main.__doc__,
 +
                                    epilog=epilog)
 +
    required = parser.add_argument_group('required arguments')
 +
    required.add_argument(
 +
        '-f', '--file', nargs='+',
 +
        help='Path to image file to send. Multiple files are separated by a space, eg.: a.png b.png'
 +
    )
 +
    parser.add_argument(
 +
        '-l', '--loop', action="store_true",
 +
        help='Display images in loop, add argument will display images in loop'
 +
    )
 +
    parser.add_argument(
 +
        '-r', '--rate', type=float, default=1.0,
 +
        help='Image display frequency for multiple and looped images'
 +
    )
 +
    args = parser.parse_args()
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 +
Arguments for head image display, the image file(s) is a required argument, loop and rate are optional.
  
=== Edit the 'robot_hostname' field ===
+
<syntaxhighlight lang="python" line start="68" enclose="div">
Sawyer's hostname is defaulted as the controller's serial number. The serial number can be located on the back of the robot's controller box. <br/>
+
    rospy.init_node("head_display_example", anonymous=True)
If you prefer to use a more advanced ROS networking configuration, please refer to the [http://sdk.rethinkrobotics.com/intera1/index.php/Networking Networking Page].
 
  
=== Edit the 'your_ip' field ===
+
    head_display = intera_interface.HeadDisplay()
 +
    head_display.display_image(args.file, args.loop, args.rate)
  
Modify where 'your_ip' is the IP address of your PC.
+
if __name__ == '__main__':
 
+
    main()
<syntaxhighlight lang="bash" enclose="div">
 
**your_ip="192.168.XXX.XXX"**
 
</syntaxhighlight>
 
 
 
Useful command for identifying your IP address:
 
<syntaxhighlight lang="bash" enclose="div">
 
$ ifconfig
 
# Result will be contained in the 'inet addr' field (Ubuntu) or 'inet' field (Gentoo Robot PC).
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
The node is initialized and an instance of the <code>HeadDisplay()</code> class is created. Call display_image function by passing in arguments.
<div class="toccolours mw-collapsible mw-collapsed">
+
Press Ctrl-C to quit the example.
Alternatively, you may choose to use the hostname of your development PC rather than the PC's IP address.  For instructions, press Expand on the right.
 
<div class="mw-collapsible-content">
 
You may edit the 'your_hostname' field (only if not using 'your_ip'):
 
<syntaxhighlight lang="bash" enclose="div">
 
***your_hostname="my_computer.local***
 
</syntaxhighlight>
 
 
 
 
 
'''Important:''' This hostname must be resolvable to Sawyer. To test if your hostname is resolvable to Sawyer, please visit the development PC [[Hostname Validation]] page.
 
 
 
'''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.
 
  
 
</div>
 
</div>
</div>
 
 
=== Verify 'ros_version' field ===
 
 
Verify that the the 'ros_version' field matches the ROS version you are running:
 
 
This field will default to "indigo"
 
<syntaxhighlight lang="bash" enclose="div">
 
***ros_version="indigo"***
 
</syntaxhighlight>
 
 
=== Save and Close intera.sh script ===
 
 
Please save and close the intera.sh script.
 
 
=== Initialize your SDK environment ===
 
 
From this point forward, your ROS environment setup should be as simple as sourcing the intera.sh script from the root of your Catkin workspace:
 
<syntaxhighlight lang="bash" enclose="div">
 
$ cd ~/ros_ws
 
$ ./intera.sh
 
</syntaxhighlight>
 
 
</div>
 
 
<div class="content-block">
 
 
== Step 7: Verify Environment ==
 
 
A useful command for viewing and validating your ROS environment setup is:
 
<syntaxhighlight lang="bash" enclose="div">
 
$ env | grep ROS
 
</syntaxhighlight>
 
 
The important fields at this point: 
 
 
'''ROS_MASTER_URI''' - This should now contain your robot's hostname. 
 
 
'''ROS_IP''' - This should contain your workstation's IP address.
 
 
or
 
 
'''ROS_HOSTNAME''' - If not using the workstation's IP address, the ROS_HOSTNAME field should contain your PC's hostname.  Otherwise, this field should not be available.
 
 
</div>
 
 
== ''Next Step'' ==
 
We will verify your network setup in the next section.
 
<span style="font-size:130%;">[[Hello_Robot | '''Hello Robot!''']]</span>
 

Revision as of 19:21, 21 December 2016

Displays a given image file or multiple files on the robot's face.

Introduction

The camera display example demonstrates how to pass image file(s) to robot head for display. The example read and convert image file(s) using cv_bridge, sending the image info to the robot head screen as a standard ROS Image Message.

Usage

Run the example as following command:

$ rosrun intera_examples head_display_image.py -f <the path to image file to send>

Arguments

Important Arguments:

-f or --file : File path for display.

-l or --loop : Display images in loop.

-r or --rate : The frequency for multiple and looped images.

usage: head_display_image.py [-h] [-f FILE [FILE ...]] [-l] [-r RATE]

RSDK Head Display Example:

    Displays a given image file or multiple files on the robot.s face.

    Pass the relative or absolute file path to an image file on your
    computer, and the example will read and convert the image using
    cv_bridge, sending it to the screen as a standard ROS Image Message.
    

optional arguments:
  -h, --help            show this help message and exit
  -l, --loop            Display images in loop, add argument will display
                        images in loop
  -r RATE, --rate RATE  Image display frequency for multiple and looped
                        images.

required arguments:
  -f FILE [FILE ...], --file FILE [FILE ...]
                        Path to image file to send. Multiple files are
                        separated by a space, eg.: a.png b.png

Notes:
    Max screen resolution is 1024x600.
    Images are always aligned to the top-left corner.
    Image formats are those supported by OpenCv - LoadImage().

Code Walkthrough

Now, let's break down the code.

30 import intera_interface
31 import argparse
32 import rospy

This imports the intera interface for accessing the HeadDisplay class.

34 def main():
35     """RSDK Head Display Example:
36     Displays a given image file or multiple files on the robot's face.
37     Pass the relative or absolute file path to an image file on your
38     computer, and the example will read and convert the image using
39     cv_bridge, sending it to the screen as a standard ROS Image Message.
40     """
41     epilog = """
42 Notes:
43     Max screen resolution is 1024x600.
44     Images are always aligned to the top-left corner.
45     Image formats are those supported by OpenCv - LoadImage().
46     """
47     arg_fmt = argparse.RawDescriptionHelpFormatter
48     parser = argparse.ArgumentParser(formatter_class=arg_fmt,
49                                      description=main.__doc__,
50                                      epilog=epilog)
51     required = parser.add_argument_group('required arguments')
52     required.add_argument(
53         '-f', '--file', nargs='+',
54         help='Path to image file to send. Multiple files are separated by a space, eg.: a.png b.png'
55     )
56     parser.add_argument(
57         '-l', '--loop', action="store_true",
58         help='Display images in loop, add argument will display images in loop'
59     )
60     parser.add_argument(
61         '-r', '--rate', type=float, default=1.0,
62         help='Image display frequency for multiple and looped images'
63     )
64     args = parser.parse_args()

Arguments for head image display, the image file(s) is a required argument, loop and rate are optional.

68     rospy.init_node("head_display_example", anonymous=True)
69 
70     head_display = intera_interface.HeadDisplay()
71     head_display.display_image(args.file, args.loop, args.rate)
72 
73 if __name__ == '__main__':
74     main()

The node is initialized and an instance of the HeadDisplay() class is created. Call display_image function by passing in arguments. Press Ctrl-C to quit the example.