Up:Tutorial?


The aim of this tutorial is to explain how to integrate SIGVerse with ROS operating system.

First, we will show how to install ROS on your operating system, then we will explain step by step how to run SIGVerse controller in ROS node and how to communicate with another node.

The ROS part tutorial is based on the official ROS wiki, you can check it for more details.

Overview

In order to integrate SIGVerse and ROS, we first need to create ROS package containing two nodes, SIGVerse controller node and ROS command node. The first node, SIGVerse controller node, will receive data from the SIGViewer as messages, then publish them on the message topic, in the other part, ROS command node reads these data and subscribe the corresponding velocity on the velocity topic, the velocity command will be retrieved by the SIGVerse controller node to be used for controlling the robot.

Simple_Ros_.PNG

Installing ROS

To install ROS on your server please refer to the official web site.

Creating ROS workspace

In our project we are using catkin, here are the steps to follow to create a ROS workspace:

Run the following command:

$ source /opt/ros/groovy/setup.sh

To create a catkin workspace:

$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
$ catkin_init_workspace

You can build even though no project is created yet, you just need MakeLists.txt:

$ cd ~/catkin_ws/
$ catkin_make

Run the setup.bash

$ source devel/setup.bash

Creating the package

We need to create a new package in the catkin_ws directory.

  • To create a new package, go to catkin_ws:
    $ cd ~/catkin_ws/src
    $ catkin_create_pkg sig_ros

Download the project

Please download the project file from here.
https://github.com/SIGVerse/samples/tree/master/ROS_integration

Compiling the project

  • After downloading the project from git, copy the "sig_ros" directory to ~/catkin_make/src.
  • In "~/catkin_make/devel/lib" create a new directory named "libsig_ros" and copy the file "RobotInMove.xml"

You need to have Cmake installed on your server.

Let's edit the CMakeLists.txt file to compile the project:

Cmake parameters:

  • These lines allow to generate the ros_controller node:
add_executable(ros_controller src/ros_controller.cpp)
target_link_libraries(ros_controller ${catkin_LIBRARIES})
add_dependencies(ros_controller sig_ros_gencpp)
  • These lines allow to generate the sig_controller library:
ADD_LIBRARY(sig_ros/sig_controller src/sig_controller.cpp)
target_link_libraries(sig_ros/sig_controller ${catkin_LIBRARIES})
add_dependencies(sig_ros/sig_controller sig_ros_gencpp)
  • To compile the package, run the following commands:
    $ cd ~/catkin_ws
    $ catkin_make

A new library will be generated in ~/catkin_ws/devel/lib/libsig_ros.

Run the following command to add this package to ROS packages:

  $source ~/catkin_ws/devel/setup.sh 
  • Now let's check if our package is recognized by ROS:
    & Roscd sig_ros

We must have the following output:

$ CMakeLists.txt include msg package.xml src

This shows that the sig_ros package exists.

Testing the project

Running the server

To run the server please follow the these steps:

Go to catkin_ws and and follow these steps :

  • Run the ROS system:
$ roscore
  • Go to ~/catkin_ws/devel/lib/libsig_ros, and run the sigverse controller:
$ cd ~/catkin_ws/devel/lib/libsig_ros
$ sigserver.sh -w ./RobotInMove.xml

Client side

  • Run SIGViewer and start the viewer to launch the two nodes.
  • To make the robot move, click on the message button, select robot_000 as entity, and send one the following messages: moveforward, movebackward, turnleft and turnright.

Source Code understanding

SIGVerse controller node

sig_controller.cpp

  • Let’s check this file step by step 

The following is the callback function which preforms the command on the velocity of the robot’s wheels:

Message Sender

  • Read from the Velocity Topic.
  • Print the Velocity value applied on the robot.

Node Initialization

  • In this part, we initialize the ROS node.
  • Create two topics for publishing/reading data, command_message and velocity_command node.
  • Launch the ros_controller node.

Robot Controller

This function allows to control the robot using the appropriate velocity.

ROS command node

This is the node that controls the robot’s velocity:

ros_controller.cpp:

  • Initialization of the command Node's Parameters
  • The Node will send velocity information using velocity_command Topic
  • The Node will receive information using command_message Topic

Main to execute the Node

  • This part starts the Sigvers_Command_node Node.

Message Sender

  • This is the callback function which receives messages from the SIGVerse controller node and publishes the corresponding velocity to be sent to the robot on the velocity_command topic:

World file

RobotInMove.xml:

Counter: 7292, today: 1, yesterday: 0

Tutorial?


Attach file: fileSimple_Ros_.PNG 2817 download [Information] fileSimple_Ros.PNG 1648 download [Information]

Front page   Edit Freeze Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes
Last-modified: 2015-07-21 (Tue) 17:41:48 (3201d)