ROS integration
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
Up:[[Tutorial]]
----
The aim of this tutorial is to explain how to integrate S...
First, we will show how to install ROS on your operating ...
The ROS part tutorial is based on the official [[ROS wiki...
#contents
*Overview[#ed1b8322]
In order to integrate SIGVerse and ROS, we first need to ...
The first node, SIGVerse controller node, will receive da...
&ref(Simple_Ros_.PNG,,80%);
////////////////////////////////////
*Installing ROS [#ed1b8326]
To install ROS on your server please refer to the [[offic...
**Creating ROS workspace [#ed1b8324]
In our project we are using catkin, here are the steps to...
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 ...
$ cd ~/catkin_ws/
$ catkin_make
Run the setup.bash
$ source devel/setup.bash
////////////////////////////////////
*Creating the package [#ed1b8323]
We need to create a new package in the catkin_ws directory.
// containing two nodes.
- To create a new package, go to catkin_ws:
$ cd ~/catkin_ws/src
$ catkin_create_pkg sig_ros
//- Create two new cpp files named sig_controller.cpp and...
// $ cd ~/catkin_ws/sig_ros/src/
// $ vim sig_controller.cpp
// $ vim ros_controller.cpp
/////////////////////////////////////////
*Download the project [#ed1b8232]
Please download the project file from here.~
https://github.com/SIGVerse/samples/tree/master/ROS_integ...
// To download the project from GIT repository, use the f...
// git@socio4.iir.nii.ac.jp:~/SigverseGitServer/unstable/...
////////////////////////////////////////
* Compiling the project [#ed1b8353]
-After downloading the project from git, copy the "sig_ro...
-In "~/catkin_make/devel/lib" create a new directory name...
You need to have Cmake installed on your server.
Let's edit the CMakeLists.txt file to compile the project:
Cmake parameters:
#highlight(cpp){{
cmake_minimum_required(VERSION 2.8.3)
project(Sigvers_Ros)
find_package(catkin REQUIRED COMPONENTS roscpp rospy st...
## Generate messages in the 'msg' folder
add_message_files(
FILES
Velocity.msg
)
## Generate added messages and services with any depend...
generate_messages(
DEPENDENCIES
std_msgs
)
## include libraries
include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(/home/<username>/sigverse-2.2.0/inc...
}}
- 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_LI...
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/...
Run the following command to add this package to ROS pack...
$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 [#ed1b4432]
**Running the server [#ed1b8132]
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 sigv...
$ cd ~/catkin_ws/devel/lib/libsig_ros
$ sigserver.sh -w ./RobotInMove.xml
**Client side [#ed1b8131]
-Run SIGViewer and start the viewer to launch the two nod...
-To make the robot move, click on the message button, sel...
moveforward, movebackward, turnleft and turnright.
*Source Code understanding [#ed1b3329]
**SIGVerse controller node [#ed1b3669]
sig_controller.cpp
- Let’s check this file step by step
The following is the callback function which preforms the...
***Message Sender [#ed1b8136]
#highlight(cpp){{
void SendController::poseCallback(const Sigvers_Ros::V...
{ Wheel_one = vel->linear;
Wheel_two = vel->angular;
printf("Velocity 1!!! %f\n", Wheel_one);
printf("Velocity 2!!! %f\n", Wheel_two);
}
}}
-Read from the Velocity Topic.
-Print the Velocity value applied on the robot.
***Node Initialization [#ed1b8137]
#highlight(cpp){{
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, "sig_controller_node"); //Initi...
// -- n...
//Node ...
ros::NodeHandle n; // Crea...
// of t...
velocity = 1;
chatter_pub = n.advertise<std_msgs::String>("command_...
pose_sub = n.subscribe<Sigvers_Ros::Velocity>("vel...
ros::Rate loop_rate(10); //A ros::Rate object allows ...
//It will keep track of how ...
//and sleep for the correct ...
// Running the ros_command node
system ("source ~/catkin_ws/devel/setup.sh");
system ("rosrun sig_ros ros_controller &");
}
}}
-In this part, we initialize the ROS node.
-Create two topics for publishing/reading data, command_m...
-Launch the ros_controller node.
***Robot Controller [#ed1b8138]
#highlight(cpp){{
double SendController::onAction(ActionEvent &evt)
{
my->setWheelVelocity(Weel_one,Weel_two);
ros::spinOnce(); //
return 1.0;
}
}}
This function allows to control the robot using the appro...
**ROS command node [#ed1b3779]
This is the node that controls the robot’s velocity:
ros_controller.cpp:
#highlight(cpp){{
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>("vel...
mess_sub = nh_.subscribe("command_message",100,&C...
}
}}
- Initialization of the command Node's Parameters
- The Node will send velocity information using velocity_...
- The Node will receive information using command_message...
***Main to execute the Node [#v1bef770]
#highlight(cpp){{
int main(int argc, char** argv)
{
ros::init(argc, argv, "ros_command_node");
CommandSig Command_sig;
ros::Rate loop_rate(10);
ros::spin();
return(0);
}
}}
- This part starts the Sigvers_Command_node Node.
***Message Sender [#ed1b8140]
- This is the callback function which receives messages f...
#highlight(cpp){{
void CommandSig::chatterCallback (const std_msgs::Stri...
{
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);
}
.....
}
}}
//////////////////////////////////////////////////////
* World file [#ed1b8152]
RobotInMove.xml:
#highlight(cpp){{
<?xml version="1.0" encoding="utf-8"?>
<world name="myworld1">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="WheelRobot-nii-v1.xml" type="Robot">
<set-attr-value name="name" value="robot_00...
<set-attr-value name="language" value="c++"/>
<set-attr-value name="implementation" value="./libSig...
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-100.0"/>
<set-attr-value name="y" value="30.0"/>
<set-attr-value name="z" value="-130.0"/>
<set-attr-value name="collision" value="true"/>
<!--stereo camera right-->
<camera id="1"
link="REYE_LINK"
direction="0.0 -1.0 1.0"
position="0.0 0.0 3.0"/>
<!--stereo camera left-->
<camera id="2"
link="LEYE_LINK"
direction="0.0 -1.0 1.0"
position="0.0 0.0 3.0"/>
<!--distance sensor-->
<camera id="3"
link="WAIST_LINK0"
direction="0.0 1.0 0.0"
position="0.0 -5.0 20.0"/>
<!--monitoring camera-->
<camera id="4"
link="WAIST_LINK2"
direction="0 0 1"
quaternion="0.0 0.0 -0.966 0.259"
position="0.0 40.0 120.0"/>
</instanciate>
</world>
}}
////////////////////////////////////////////////////
#counter
#highlight(end)
[[Tutorial]]
End:
Up:[[Tutorial]]
----
The aim of this tutorial is to explain how to integrate S...
First, we will show how to install ROS on your operating ...
The ROS part tutorial is based on the official [[ROS wiki...
#contents
*Overview[#ed1b8322]
In order to integrate SIGVerse and ROS, we first need to ...
The first node, SIGVerse controller node, will receive da...
&ref(Simple_Ros_.PNG,,80%);
////////////////////////////////////
*Installing ROS [#ed1b8326]
To install ROS on your server please refer to the [[offic...
**Creating ROS workspace [#ed1b8324]
In our project we are using catkin, here are the steps to...
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 ...
$ cd ~/catkin_ws/
$ catkin_make
Run the setup.bash
$ source devel/setup.bash
////////////////////////////////////
*Creating the package [#ed1b8323]
We need to create a new package in the catkin_ws directory.
// containing two nodes.
- To create a new package, go to catkin_ws:
$ cd ~/catkin_ws/src
$ catkin_create_pkg sig_ros
//- Create two new cpp files named sig_controller.cpp and...
// $ cd ~/catkin_ws/sig_ros/src/
// $ vim sig_controller.cpp
// $ vim ros_controller.cpp
/////////////////////////////////////////
*Download the project [#ed1b8232]
Please download the project file from here.~
https://github.com/SIGVerse/samples/tree/master/ROS_integ...
// To download the project from GIT repository, use the f...
// git@socio4.iir.nii.ac.jp:~/SigverseGitServer/unstable/...
////////////////////////////////////////
* Compiling the project [#ed1b8353]
-After downloading the project from git, copy the "sig_ro...
-In "~/catkin_make/devel/lib" create a new directory name...
You need to have Cmake installed on your server.
Let's edit the CMakeLists.txt file to compile the project:
Cmake parameters:
#highlight(cpp){{
cmake_minimum_required(VERSION 2.8.3)
project(Sigvers_Ros)
find_package(catkin REQUIRED COMPONENTS roscpp rospy st...
## Generate messages in the 'msg' folder
add_message_files(
FILES
Velocity.msg
)
## Generate added messages and services with any depend...
generate_messages(
DEPENDENCIES
std_msgs
)
## include libraries
include_directories(include ${catkin_INCLUDE_DIRS})
include_directories(/home/<username>/sigverse-2.2.0/inc...
}}
- 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_LI...
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/...
Run the following command to add this package to ROS pack...
$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 [#ed1b4432]
**Running the server [#ed1b8132]
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 sigv...
$ cd ~/catkin_ws/devel/lib/libsig_ros
$ sigserver.sh -w ./RobotInMove.xml
**Client side [#ed1b8131]
-Run SIGViewer and start the viewer to launch the two nod...
-To make the robot move, click on the message button, sel...
moveforward, movebackward, turnleft and turnright.
*Source Code understanding [#ed1b3329]
**SIGVerse controller node [#ed1b3669]
sig_controller.cpp
- Let’s check this file step by step
The following is the callback function which preforms the...
***Message Sender [#ed1b8136]
#highlight(cpp){{
void SendController::poseCallback(const Sigvers_Ros::V...
{ Wheel_one = vel->linear;
Wheel_two = vel->angular;
printf("Velocity 1!!! %f\n", Wheel_one);
printf("Velocity 2!!! %f\n", Wheel_two);
}
}}
-Read from the Velocity Topic.
-Print the Velocity value applied on the robot.
***Node Initialization [#ed1b8137]
#highlight(cpp){{
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, "sig_controller_node"); //Initi...
// -- n...
//Node ...
ros::NodeHandle n; // Crea...
// of t...
velocity = 1;
chatter_pub = n.advertise<std_msgs::String>("command_...
pose_sub = n.subscribe<Sigvers_Ros::Velocity>("vel...
ros::Rate loop_rate(10); //A ros::Rate object allows ...
//It will keep track of how ...
//and sleep for the correct ...
// Running the ros_command node
system ("source ~/catkin_ws/devel/setup.sh");
system ("rosrun sig_ros ros_controller &");
}
}}
-In this part, we initialize the ROS node.
-Create two topics for publishing/reading data, command_m...
-Launch the ros_controller node.
***Robot Controller [#ed1b8138]
#highlight(cpp){{
double SendController::onAction(ActionEvent &evt)
{
my->setWheelVelocity(Weel_one,Weel_two);
ros::spinOnce(); //
return 1.0;
}
}}
This function allows to control the robot using the appro...
**ROS command node [#ed1b3779]
This is the node that controls the robot’s velocity:
ros_controller.cpp:
#highlight(cpp){{
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>("vel...
mess_sub = nh_.subscribe("command_message",100,&C...
}
}}
- Initialization of the command Node's Parameters
- The Node will send velocity information using velocity_...
- The Node will receive information using command_message...
***Main to execute the Node [#v1bef770]
#highlight(cpp){{
int main(int argc, char** argv)
{
ros::init(argc, argv, "ros_command_node");
CommandSig Command_sig;
ros::Rate loop_rate(10);
ros::spin();
return(0);
}
}}
- This part starts the Sigvers_Command_node Node.
***Message Sender [#ed1b8140]
- This is the callback function which receives messages f...
#highlight(cpp){{
void CommandSig::chatterCallback (const std_msgs::Stri...
{
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);
}
.....
}
}}
//////////////////////////////////////////////////////
* World file [#ed1b8152]
RobotInMove.xml:
#highlight(cpp){{
<?xml version="1.0" encoding="utf-8"?>
<world name="myworld1">
<gravity x="0.0" y="-980.7" z="0.0"/>
<instanciate class="WheelRobot-nii-v1.xml" type="Robot">
<set-attr-value name="name" value="robot_00...
<set-attr-value name="language" value="c++"/>
<set-attr-value name="implementation" value="./libSig...
<set-attr-value name="dynamics" value="false"/>
<set-attr-value name="x" value="-100.0"/>
<set-attr-value name="y" value="30.0"/>
<set-attr-value name="z" value="-130.0"/>
<set-attr-value name="collision" value="true"/>
<!--stereo camera right-->
<camera id="1"
link="REYE_LINK"
direction="0.0 -1.0 1.0"
position="0.0 0.0 3.0"/>
<!--stereo camera left-->
<camera id="2"
link="LEYE_LINK"
direction="0.0 -1.0 1.0"
position="0.0 0.0 3.0"/>
<!--distance sensor-->
<camera id="3"
link="WAIST_LINK0"
direction="0.0 1.0 0.0"
position="0.0 -5.0 20.0"/>
<!--monitoring camera-->
<camera id="4"
link="WAIST_LINK2"
direction="0 0 1"
quaternion="0.0 0.0 -0.966 0.259"
position="0.0 40.0 120.0"/>
</instanciate>
</world>
}}
////////////////////////////////////////////////////
#counter
#highlight(end)
[[Tutorial]]
Page: