Skip to content

Apply patch for motive3 to work #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/mocap_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ namespace mocap_optitrack
std::bind(&OptiTrackRosBridge::parametersCallback, this, std::placeholders::_1));
}

~OptiTrackRosBridge() {
multicastClientSocketPtr.reset();
};

void initialize()
{
if (serverDescription.enableOptitrack)
Expand All @@ -70,9 +74,9 @@ namespace mocap_optitrack
dataModel.setVersions(&serverDescription.version[0], &serverDescription.version[0]);
}

// Need verion information from the server to properly decode any of their packets.
// If we have not recieved that yet, send another request.
while (rclcpp::ok() && !dataModel.hasServerInfo())
// Need version information from the server to properly decode any of their packets.
// If we have not received that yet, send another request.
while (rclcpp::ok())
{
natnet::ConnectionRequestMessage connectionRequestMsg;
natnet::MessageBuffer connectionRequestMsgBuffer;
Expand All @@ -83,6 +87,8 @@ namespace mocap_optitrack
else sleep(1);

spin_some(node);
if (dataModel.hasServerInfo())
break;
}
// Once we have the server info, create publishers
publishDispatcherPtr.reset(
Expand Down
15 changes: 15 additions & 0 deletions src/natnet/natnet_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ void DataFrameMessage::deserialize(
RCLCPP_DEBUG(logger, "Marker set count: %d", numMarkerSets);
dataFrame->markerSets.resize(numMarkerSets);

if (NatNetVersion.v_major >= 4 and NatNetVersion.v_minor > 0) {
// NatNet version > 4.0: size of all data for this data type (in bytes);
msgBufferIter += 4;
}

// Loop through number of marker sets and get name and data
// TODO: Whether this correctly parses marker sets has not been tested
int icnt = 0;
Expand Down Expand Up @@ -231,6 +236,11 @@ void DataFrameMessage::deserialize(
dataFrame->otherMarkers.resize(numUnlabeledMarkers);
RCLCPP_DEBUG(logger, "Unlabled marker count: %d", numUnlabeledMarkers);

if (NatNetVersion.v_major >= 4 and NatNetVersion.v_minor > 0) {
// NatNet version > 4.0: size of all data for this data type (in bytes);
msgBufferIter += 4;
}

// Loop over unlabled markers
icnt = 0;
for (auto& marker : dataFrame->otherMarkers)
Expand All @@ -249,6 +259,11 @@ void DataFrameMessage::deserialize(
dataFrame->rigidBodies.resize(numRigidBodies);
RCLCPP_DEBUG(logger, "Rigid count: %d", numRigidBodies);

if (NatNetVersion.v_major >= 4 and NatNetVersion.v_minor > 0) {
// NatNet version > 4.0: size of all data for this data type (in bytes);
msgBufferIter += 4;
}

// Loop over rigid bodies
for (auto& rigidBody : dataFrame->rigidBodies)
{
Expand Down