ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I figured out what the problem was.
In the function parse(), the program does not add the counter for buffer exactly. To fix this error we need to add
seek(2);
after the line
//skip mean marker error
seek(sizeof(float));
This is in the for loop that keeps iterating for each rigid bodies. Since after the 1st rigid body the counter was not at the right place, the function
read_and_seek(model.rigidBodies[m].NumberOfMarkers);
would return a value like 24533 instead of 3.
So after the 1st rigid body the function
model.rigidBodies[m].marker = new Marker [model.rigidBodies[m].NumberOfMarkers];
would allocate more memory and the functions
size_t byte_count = model.rigidBodies[m].NumberOfMarkers * sizeof(Marker); memcpy(model.rigidBodies[m].marker, packet, byte_count);
So the value for bytecount was more than 60000 when it should have been 36 (since i have 3 markers), and this would lead the memcpy to acces data out of the buffer which caused the crash
So we correct this by adding the seek(2) which will get everything to the right indices