-
Hi everybody, My goal is to read the encoders and send motor commands to the joints from ROS. I was following this tutorial: http://wiki.icub.org/yarpdoc/yarp_with_ros.html , but I don't understand how can I read an existing yarp port from ROS. Does it exist an automatic way to connect a yarp port to a ros topic (something like "yarp connect 'icubGazeboSim/head/state:o topic://head_enc") or I have to write a yarp program that reads from the port and publishes on the topic by hand? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
There is an example in the Here is the code according to the example: Ros message : int32 v_tag # set to 266 (BOTTLE_TAG_LIST+code)
float64[] v # suggested length: 16 and the C++ Code: #include <ros/ros.h>
#include <yarpros_examples/Encoders.h>
#include <stdio.h>
void chatterCallback(const yarpros_examples::EncodersConstPtr& enc)
{
printf("Encoder readings for first three joints: %g %g %g\n",
enc->v[0], enc->v[1], enc->v[2]);
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "yarp_encoder_listener");
ros::NodeHandle n;
ros::Subscriber chatter_sub = n.subscribe("pos", 1, chatterCallback);
ros::spin();
} |
Beta Was this translation helpful? Give feedback.
-
Did you also see this: http://sourceforge.net/p/robotcub/mailman/message/33947143/ ? |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot. I'm using the wrapper and everything is working. |
Beta Was this translation helpful? Give feedback.
-
@nigno17 can we close this issue then? |
Beta Was this translation helpful? Give feedback.
-
yes thanks! |
Beta Was this translation helpful? Give feedback.
@nigno17
There is an example in the
example/yarpros_examples
folder of the Yarp repository calledgrab_encodrs.cpp
which I guess does the same thing you need. Have you tried that?Here is the code according to the example:
Ros message :
and the C++ Code: