ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Jorge,

actually, I would like to receive what the programme "points_and_lines.cpp" (from the mentioned tutorial) publishes.

As you can see in the source code of this programme, the coordinates are changing. Here is the section, which explains the change of the coordinates:

// Create the vertices for the points and lines
for (uint32_t i = 0; i < 100; ++i)
{
  float y = 5 * sin(f + i / 100.0f * 2 * M_PI);
  float z = 5 * cos(f + i / 100.0f * 2 * M_PI);

  geometry_msgs::Point p;
  p.x = (int32_t)i - 50;
  p.y = y;
  p.z = z;

  points.points.push_back(p);
  line_strip.points.push_back(p);

  // The line list needs two points for each line
  line_list.points.push_back(p);
  p.z += 1.0;
  line_list.points.push_back(p);
}

For the moment, let us try to receive only the x-coordinate.

The printout should be like this:

I received: -50
I received: -49
I received: -48
..... and so on .....

When I try your code, I get, as you described, only the same message over and over again:

I received: 49
I received: 49
I received: 49
I received: 49

Therefore, I tried this line of code, instead of yours:

std::cout << "I received: " << msg->points[0] << std::endl;

But then I receive:

I received: x: -50
y: 4.11811
z: 2.83569

I received: x: -50
y: 4.11811
z: 2.83569

I received: x: -50
y: 4.22832
z: 2.66858

I received: x: -50
y: 4.22832
z: 2.66858

I cannot explain, why I am getting the same value of x and why y and z are getting printed on the terminal at all. This is absolutely not what I want. I only want to work with the different x-coordinates.

Has somebody an idea, how to receive the different x-coordinates?

With best regards Commander Data