Skip to content

reading a YARP port from ROS #35

Answered by apaikan
nigno17 asked this question in Q&A
Discussion options

You must be logged in to vote

@nigno17

There is an example in the example/yarpros_examples folder of the Yarp repository called grab_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 :

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…

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pattacini
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #35 on December 08, 2020 17:11.