[[SIGVerse]]
Ros tutorial on SIGverse
How to Use ROS with SIGverse
User has to create A SIGverse node using the following code:
In this tutorial two topics are used 
Message Topic to send messages from SIGverse Node to Command Node and Velocity format Topic to send the value of velocity to the SIGverse node.




 Let’s study this example step by step 
Now let’s create the callback function which preforms the command on the velocity of the robot’s wheels:
void SendController::poseCallback(const Sigvers_Ros::VelocityConstPtr& vel)
{
 
    Wheel_one =  vel->linear;
    Wheel_two =  vel->angular;
// read from the Velocity Topic
   printf("Velocity 1!!!  %f\n", Wheel_one);
   printf("Velocity 2!!!  %f\n", Wheel_two);
//Printing the Velocity value applied on the robot
}




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);
}




double SendController::
onAction(ActionEvent &evt)
{




my->setWheelVelocity(Weel_one,Weel_two);
ros::spinOnce();




  return 1.0;
}




Now let’s create a Node to control the robot’s velocity:
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_);
 // this part will give parameters will be given to the node




   vel_pub_ = nh_.advertise<Sigvers_Ros::Velocity>("mycommand_velocity", 1);
  // The Node will send velocity information using mycommand_velocity Topic 




   mess_sub = nh_.subscribe("CommandMess",100,&CommandSig::chatterCallback,this);
   // The Node will receive information using CommandMess Topic 
 }




And finally let’s write the main function which launches the command  node
int main(int argc, char** argv)
 {
   ros::init(argc, argv, "Sigvers_Command_node");
   // this command creates and does initialization on the Sigvers_Command_node Node 
   CommandSig Command_sig;
   
   ros::Rate loop_rate(10);
   ros::spin();
   return(0);
 }




Now let’s create the callback function which receveces message from Sigverse Node and  sends the right command to the robot:
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);




                     }
………
}




Create a new ROS Package :
We need to create a new Ros Package to perform the ROS SIGverse integration




Let’s create a new directory  named catkin_ws and let’s perform those few tasks




Create a new folder named src.




Now let’s initialize our workspace by using the following command:
catkin_init_workspace in the ~/catkin_ws folder  




Now we have our workspace let’s create our SIGverse ROS Package 




Firstable we have to make a new folder named SIGverse and then  edit the Cmake  file and  Sig_app.cpp in a new src folder which PATH is ~/catkin_ws/src/Sigvers_Ros/src.




Now  make  Cmake file in order to create the wanted package.
Catkin_make will generate a /devel folder with contains /devel/lib folder and in there the Cmake file generated a libSig_app.so file which will be used by the xml world file to control the robot simulation.
Now let’s souce our package by using the following command:




source ~/catkin_ws2/devel/setup.sh 




Now we can check our package by executing this command 
Roscd Sigvers_Ros so we get the following result:




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)




We use the target_link_libraries which generates the .so file 
include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(/home/ericgt/sigverse-2.2.0/include/sigverse /home/ericgt/sigverse-2.2.0/include/sigverse/comm/controller)




We include SiGverse .h files to compile our controller’s source code
Catkin Command:
catkin_make we compile our code using Cmake parameters so we generate .so  file used by the xml world file to control the robot simulation.

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