ROS

This section will show you how to use Mech-Eye SDK on ROS on Ubuntu.

Requirements

  1. Operating system: Ubuntu.

  2. ROS installed according to instructions on Documentation of ROS.

Note:

  1. In the example below, the Ubuntu system’s version is 18.04, but the installation of ROS will be different for different versions of Ubuntu systems.

  2. If using a virtual machine to install the software, please reserve more than 20G of disk space; otherwise, the installation may fail.

  3. If after following the instructions below, you can run turtlesim normally, you have successfully installed ROS.

    # Open a terminal in any directory and enter the command:
    roscore
    # Open a second terminal and enter the command:
    rosrun turtlesim turtlesim_node
    # Open a third terminal and enter the command:
    rosrun turtlesim turtle_teleop_key
    

    After executing the above command, in the third terminal window, you will be able to control the little turtle by pressing the up, down, left, and right keys on the keyboard, as shown in the figure below.

    ../../../_images/turtle_sim.png

Instructions

Install Mech-Eye SDK for Ubuntu

Please see :ref: ref-install-sdk-on-ubuntu for instructions on installing.

Install ROS API

  1. Install libzmq5 and libzmq3-dev. .. code-block:: sh

    sudo apt install libzmq5 libzmq3-dev

  2. Create directory ~/ros_ws/src and open it.

    mkdir -p ~/ros_ws/src && cd ~/ros_ws/src
    
  3. Clone repository mecheye_ros_interface to directory ~/ros_ws/src.

    git clone https://github.com/MechMindRobotics/mecheye_ros_interface
    
  4. Open directory ~/ros_ws and build.

    cd ~/ros_ws && catkin_make
    
  5. Modify the files.

    • If you need to store the images, please change false to true in the line <arg name="save_file" default="true"/> in the file ~/ros_ws/src/mecheye_ros_interface/launch/start_camera.launch.

    • The path to store the images can be modified in the file ~/ros_ws/src/mecheye_ros_interface/src/main.cpp.

Run the Service

  1. Open a new terminal and run the following command to start the service.

    source ~/ros_ws/devel/setup.bash
    roslaunch mecheye_ros_interface start_camera.launch
    

    The output is as follows:

    ... logging to /home/mechmind/.ros/log/69ffe3a2-d290-11ec-828a-000c29351753/roslaunch-ubuntu-4349.log
    Checking log directory for disk usage. This may take a while.
    Press Ctrl-C to interrupt
    Done checking log file disk usage. Usage is <1GB.
    
    started roslaunch server http://ubuntu:38711/
    
    SUMMARY
    ========
    
    PARAMETERS
        * /mechmind_camera_start/camera_ip: 192.168.0.123
        * /mechmind_camera_start/fx: 1727.46410256
        * /mechmind_camera_start/fy: 1727.45869267
        * /mechmind_camera_start/save_file: False
        * /mechmind_camera_start/u: 655.818082573
        * /mechmind_camera_start/use_external_intri: False
        * /mechmind_camera_start/v: 516.630650061
        * /rosdistro: melodic
        * /rosversion: 1.14.13
    
    NODES
        /
        mechmind_camera_start (mecheye_ros_interface/start)
    
    auto-starting new master
    process[master]: started with pid [4359]
    ROS_MASTER_URI=http://localhost:11311
    
    setting /run_id to 69ffe3a2-d290-11ec-828a-000c29351753
    process[rosout-1]: started with pid [4370]
    started core service [/rosout]
    process[mechmind_camera_start-2]: started with pid [4377]
    Find Mech-Eye devices...
    Mech-Eye device index : 0
    ............................
    Camera Model Name: Mech-Eye Pro M Enhanced
    Camera ID:         Sample
    Camera IP Address: 192.168.xx.xx
    Hardware Version:  Vx.x.x
    Firmware Version:  Vx.x.x
    ............................
    Please enter the device index you want to connect: 0
    Connected to the Mech-Eye device successfully.
    ............................
    Camera Model Name: Mech-Eye Nano
    Camera ID:         TAM06218A3020706
    Camera IP Address: 192.168.xx.xx
    Hardware Version:  Vx.x.x
    Firmware Version:  Vx.x.x
    ............................
    
  2. Open another new terminal and run the following command to capture images.

    source ~/ros_ws/devel/setup.bash
    rosservice call /run_mechmind_camera
    

    The output is as follows:

    success: True
    message: ''
    

    At this point, the camera has started working. Data such as 2D images and depth maps are saved in the folder /tmp by default.

Attention

Every time you modify a file under ~/ros_ws/src/mecheye_ros_interface/src, please do cd ~/ros_ws && catkin_make to update the executable.