## For instruction on writing tutorials ## http://www.ros.org/wiki/WritingTutorials #################################### ##FILL ME IN #################################### ## for a custom note with links: ## note = ## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links ## note.0= [[sr_tactile_sensors/Tutorials/Real|Using the Real Tactile Sensors]] or [[sr_tactile_sensors/Tutorials/Simulation|Using Simulated Tactile Sensors]] ## descriptive title for the tutorial ## title = Getting Data ## multi-line description to be displayed in search ## description = Getting data from the tactile sensors. ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link= ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory ## keywords = #################################### <> <> ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE == Accessing the data in a different node == To access the data being published by the tactile sensors, you just need to subscribe to each of the topic you're interested in. There's an example in the example folder. Here is a very basic example to showcase this: {{{{#!cplusplus #include #include void callback(const std_msgs::Float64ConstPtr& msg) { ROS_ERROR_STREAM("Touch value for the First Finger finger tip: " << msg->data); } int main(int argc, char** argv) { ros::init(argc, argv, "test_tactile"); ros::NodeHandle node_tactile; ros::Subscriber sub; sub = node_tactile.subscribe("/sr_tactile/touch/ff", 2, callback); ros::spin(); return 0; } }}}} '''The code explained:''' * First we initialize the node and subscribe to one of the touch sensors topic: {{{#!cplusplus [...] sub = node_tactile.subscribe("/sr_tactile/touch/ff", 2, callback); [...] }}} * Then we print a message containing the value of the sensor in the callback function: {{{#!cplusplus [...] void callback(const std_msgs::Float64ConstPtr& msg) { ROS_ERROR_STREAM("Touch value for the First Finger finger tip: " << msg->data); } [...] }}} == Visualizing the sensor output == To visually check the sensor output, you can use [[rxplot|rxplot]]. The following command displays the 5 finger tips tactile sensors in a plot: {{{ $ rxplot /sr_tactile/touch/ff/data,\ /sr_tactile/touch/mf/data,\ /sr_tactile/touch/rf/data,\ /sr_tactile/touch/lf/data,\ /sr_tactile/touch/th/data }}}