link_joints.cpp
Go to the documentation of this file.
00001 
00059 #include <ros/ros.h>
00060 #include <string>
00061 
00062 //messages
00063 #include <std_msgs/Float64.h>
00064 #include <sr_robot_msgs/JointControllerState.h>
00065 #include <pr2_controllers_msgs/JointControllerState.h>
00066 
00068 std::string parent_name = "ffj3";
00070 std::string child_name  = "mfj3";
00072 // If you use the simulated hand (in gazebo) use the mixed controllers
00073 std::string controller_type = "_mixed_position_velocity_controller";
00074 // If you use the real hand, generally use the position controller (comment the previous line and uncomment the following)
00075 //std::string controller_type = "_position_controller";
00076 
00077 //a ros subscriber (will be instantiated later on)
00078 ros::Subscriber sub;
00079 //a ros publisher (will be instantiated later on)
00080 ros::Publisher pub;
00081 
00088 // If you use the simulated hand (in gazebo) use the mixed controllers
00089 void callback(const sr_robot_msgs::JointControllerStateConstPtr& msg)
00090 // If you use the real hand, generally use the position controller (comment the previous line and uncomment the following)
00091 //void callback(const pr2_controllers_msgs::JointControllerStateConstPtr& msg)
00092 {
00093   //publish the message
00094   std_msgs::Float64 command;
00095   command.data = msg->set_point;
00096   pub.publish(command);
00097 
00098   return;
00099 }
00100 
00109 int main(int argc, char** argv)
00110 {
00111   //init the ros node
00112   ros::init(argc, argv, "link_joints_example");
00113   ros::NodeHandle node;
00114 
00120   sub = node.subscribe("sh_" + parent_name + controller_type + "/state", 2,  callback);
00121 
00126   pub = node.advertise<std_msgs::Float64>("sh_" + child_name + controller_type + "/command", 2);
00127 
00128   //subscribe until interrupted.
00129   while( ros::ok() )
00130     ros::spin();
00131 
00132   return 0;
00133 }


sr_example
Author(s): Ugo Cupcic
autogenerated on Mon Oct 6 2014 07:49:30