Problem using vector3_stamped in Micro-ROS
Hi all, I'm building a new robot with micro-ros, I'm using a Portenta-H7 and I'm having some problems posting the motor velocity to determine the position. To post the velocity I am using the class: geometry_msgs/msg/vector3_stamped.h from micro-ros, but when I echo the issue I get this:
header:
stamp:
sec: 536890720
nanosec: 536890136
frame_id: "\x01"
vector:
x: 2.121995791e-314
y: 1.493392295746842e-154
z: 1.5e-323
I assume I'm building the sequence wrong, but I don't see the error, this is the code I'm using to make this post:
geometry_msgs__msg__Vector3Stamped__Sequence * speed_message;
// Vector Stamped 3
speed_message = geometry_msgs__msg__Vector3Stamped__Sequence__create(4);
geometry_msgs__msg__Vector3Stamped__Sequence__init(speed_message, 4);
speed_message->data[0].header.frame_id.data = (char*)malloc(100 * sizeof(char));
char string3[] = "/robot_rpm";
memcpy(speed_message->data[0].header.frame_id.data, string3, strlen(string3) + 1);
speed_message->data[0].header.frame_id.size = strlen(speed_message->data[0].header.frame_id.data);
speed_message->data[0].header.frame_id.capacity = 100;
void speed_callback()
{
struct timespec tv = {0};
clock_gettime(0, &tv);
/*speed_message->header.stamp.sec = tv.tv_sec;
speed_message->header.stamp.nanosec = tv.tv_nsec;
speed_message->vector.x = 0.5; //speed_act_left; //left wheel speed (in m/s)
speed_message->vector.y = 0.3; //speed_act_right; //right wheel speed (in m/s)
speed_message->vector.z = double(LOOPTIME) / 1000; */
speed_message->data[0].header.stamp.sec = tv.tv_sec;
speed_message->data[0].header.stamp.nanosec = tv.tv_nsec;
speed_message->data[0].vector.x = 0.5;
speed_message->data[0].vector.y = 0.3;
speed_message->data[0].vector.z = double(LOOPTIME) / 1000;
RCSOFTCHECK(rcl_publish(&speed_publisher, &speed_message, NULL));
}
Does anyone have any idea why this is happening?
Thanks