ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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 double
s.
2 | No.2 Revision |
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 double
s.
3 | No.3 Revision |
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 double
s.
See wiki/msg for how ROS IDL types map to C++ types.