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

The problem seems to be a simple type mismatch (and thus a C++ issue). You have:

vector<std_msgs::Float64> y;

and then in one of the callbacks, there is this:

y[0] = msg->x;
y[1] = msg->y;
y[2] = msg->theta;

According to the documentation on Pose2D (geometry_msgs/Pose2D), the x, y and theta fields are of type float64, not std_msgs::Float64.

You cannot assign primitives to objects in this case.

I recommend you change your vector to take regular doubles.

The problem seems to be a simple type mismatch (and thus a C++ issue). You have:

vector<std_msgs::Float64> y;

and then in one of the callbacks, there is this:

y[0] = msg->x;
y[1] = msg->y;
y[2] = msg->theta;

According to the documentation on Pose2D (geometry_msgs/Pose2D), the x, y and theta fields are of type float64, not std_msgs::Float64.

You cannot assign primitives to objects in this case.

For the second callback: the message is a std_msgs::Float64, but the value (what you are actually interested in) is in a field called data, which is of type float64 again. So that line will also not work.

I recommend you change your vector to take regular doubles.

The problem seems to be a simple type mismatch (and thus a C++ issue). You have:

vector<std_msgs::Float64> y;

and then in one of the callbacks, there is this:

y[0] = msg->x;
y[1] = msg->y;
y[2] = msg->theta;

According to the documentation on Pose2D (geometry_msgs/Pose2D), the x, y and theta fields are of type float64, not std_msgs::Float64.

You cannot assign primitives to objects in this case.

For the second callback: the message is a std_msgs::Float64, but the value (what you are actually interested in) is in a field called data, which is of type float64 again. So that line will also not work.

I recommend you change your vector to take regular doubles.

See wiki/msg for how ROS IDL types map to C++ types.