Tutorial?

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

Ros tutorial on SIGverse

Overview

In order to integrate SIGVerse and ROS You need to build the following basic system. You first have to install ROS on your computer then build two ROS packages.

Simple_Ros.PNG

Installing ROS

= Ubuntu install of ROS Groovy =

We are building Debian packages for several Ubuntu platforms, listed below. These packages are more efficient than source-based builds and are our preferred installation method for Ubuntu.

If you need to install from source (not recommended), please see groovy/Installation/Source|source (download-and-compile) installation instructions?.

=== Installation ===

First, make sure your Debian package index is up-to-date:

 $ sudo apt-get update

There are many different libraries and tools in ROS. We provided four default configurations to get you started. You can also install ROS packages individually.

 
  $ sudo apt-get install ros-groovy-desktop-full
  $ sudo apt-get install ros-groovy-desktop

ROS-Base: (Bare Bones)

 $ sudo apt-get install ros-groovy-ros-base

Individual Package:

$ sudo apt-get install ros-groovy-PACKAGE
$ sudo apt-get install ros-groovy-slam-gmapping

To find available packages, use:

$ apt-cache search ros-groovy

=== Initialize rosdep ===

Before you can use ROS, you will need to 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.

$ sudo rosdep init
$ rosdep update

=== Getting rosinstall ===

rosinstall? is a frequently used command-line tool in ROS that is distributed separately. It enables you to easily download many source trees for ROS packages with one command.

$ sudo apt-get install python-rosinstall

Creating SIGVerse Package

Catkin Workspace initialization

 $catkin_init_workspace in the ~/catkin_ws folder  
 $~/catkin_ws/src/Sigvers_Ros/src.
$ cd ~/catkin_ws/src
$ catkin_create_pkg Sigvers_Ros
  $source ~/catkin_ws2/devel/setup.sh 

CMakeLists.txt include msg package.xml src

This shows that the Sigvers_Ros packages exists

Cmake parameters: For Sig.cpp:

cmake_minimum_required(VERSION 2.8.3)
project(Sigvers_Ros)
 find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation )
## Generate messages in the 'msg' folder
    add_message_files(
    FILES
    Velocity.msg
    )
 ## Generate added messages and services with any dependencies listed here
    generate_messages(
    DEPENDENCIES
    std_msgs
    )
 ADD_LIBRARY(Sig_app src/Sig_app.cpp)
 target_link_libraries(Sig_app ${catkin_LIBRARIES})
 add_dependencies(Sig_app Sigvers_Ros_gencpp)

Creating ROS Package

Source Code understanding

Message Sender

  void SendController::poseCallback(const Sigvers_Ros::VelocityConstPtr& vel)
  {     Wheel_one =  vel->linear;
        Wheel_two =  vel->angular;
     
        printf("Velocity 1!!!  %f\n", Wheel_one);
        printf("Velocity 2!!!  %f\n", Wheel_two);
     
  }

Node Initialization

 void SendController::onInit(InitEvent &evt)
  { Wheel_one = 0.0;
   Wheel_two = 0.0;
   int argc =0;
   char** argv = NULL;
   my = this->getRobotObj(this->myname());
   my->setWheel(10.0, 10.0);
   ros::init(argc, argv, "Sigvers_controller_node");
   ros::NodeHandle n;
   velocity = 1;
   chatter_pub = n.advertise<std_msgs::String>("CommandMess", 1);
   pose_sub = n.subscribe<Sigvers_Ros::Velocity>("mycommand_velocity",    1,&SendController::poseCallback,this);
   ros::Rate loop_rate(10);
  }

Robot Controller

double SendController::onAction(ActionEvent &evt)
{
 my->setWheelVelocity(Weel_one,Weel_two);
 ros::spinOnce();
 return 1.0;
}

Command Node initialization ROS Side

 CommandSig::CommandSig():
  linear_(0),
  angular_(0),
  l_scale_(2.0),
  a_scale_(2.0)
  {
   nh_.param("scale_angular", a_scale_, a_scale_);
   nh_.param("scale_linear", l_scale_, l_scale_);
   vel_pub_ = nh_.advertise<Sigvers_Ros::Velocity>("mycommand_velocity", 1);
   mess_sub =    nh_.subscribe("CommandMess",100,&CommandSig::chatterCallback,this);
   
   }

Main to execute the Node

int main(int argc, char** argv)
 {
  ros::init(argc, argv, "Sigvers_Command_node");
  CommandSig Command_sig;
  ros::Rate loop_rate(10);
  ros::spin();
  return(0);
 }

Message Sender

Robot Motion Command ROS Side

  void CommandSig::chatterCallback (const std_msgs::String::ConstPtr& msg)
  {
   Sigvers_Ros::Velocity vel;
   if(strcmp("go",msg->data.c_str())==0)
   {
   vel.angular = 3.0;
   vel.linear = 3.0;
   vel_pub_.publish(vel);
   }
   else if(strcmp("back",msg->data.c_str())==0)
  {
   vel.angular = -3.0;
   vel.linear = -3.0;
   vel_pub_.publish(vel);
   }
   else if(strcmp("left" ,msg->data.c_str())==0)
  {
  vel.angular = 0.78;
  vel.linear = -0.78;
  vel_pub_.publish(vel);
  sleep(1.8);
  vel.angular = 0.0;
  vel.linear = 0.0;
  vel_pub_.publish(vel);
  }
  else if(strcmp("right" ,msg->data.c_str())==0)
  {
  vel.angular = -0.78;
  vel.linear = 0.78;
  vel_pub_.publish(vel);
  sleep(1.8);
  vel.angular = 0.0;
  vel.linear =  0.0;
  vel_pub_.publish(vel);
  }
  else if(strcmp("stop",msg->data.c_str())==0)
 {
  vel.angular = 0.0;
  vel.linear = 0.0;
  vel_pub_.publish(vel);
 }
………
}

Running the server

To run the server you have to follow the following steps:

Go to catkin_ws and execute the follwing command :

$ rosrun key_sig sig_app 

Go to ~/catkin_ws/devel/lib/libsig_app and run the sigverse controller: $ cd ~/catkin_ws/devel/lib/libsig_app $ sigserver.sh -w ./move_robot.xml


Front page   New List of pages Search Recent changes   Help   RSS of recent changes