Skip to content
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

driver: fix deserialisation of JointFeedbackEx #225

Merged
merged 1 commit into from
Jun 26, 2018
Merged
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
29 changes: 23 additions & 6 deletions motoman_driver/src/simple_message/joint_feedback_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,41 @@ bool JointFeedbackEx::unload(industrial::byte_array::ByteArray *buffer)
return false;
}

for (int i = 0; i < this->groups_number_; i++)
// deserialise all JointFeedback submsgs contained in the buffer, going from
// back to front (ie: start with the last and end with the first). But only
// retain deserialised msgs that actually contain valid data.
//
// Note: we cannot assume that there is a 1-to-1 mapping between the order of
// JointFeedback msgs in the buffer and motion groups on the controller.
// Because of that we have to deserialise all submsgs and check validity
// of each individually (ie: we cannot skip submsgs 3 & 4 if there are only
// two motion groups, as the data for grp1 could be in submsg 3 fi).
for (std::size_t i = 0; i < MAX_NUM_GROUPS; ++i)
{
JointFeedbackMessage tmp_msg;
JointFeedback j_feedback;



if (!buffer->unload(j_feedback))
{
LOG_ERROR("Failed to unload joint feedback groups_number");
return false;
}
tmp_msg.init(j_feedback);

this->joint_feedback_messages_.push_back(tmp_msg);
// every msg gets deserialised, but we only keep those with valid data.
//
// TODO: is a message with just 'TIME' also valid? For now it is not (not
// sure how that would work anyway, as Jointfeedback msgs are assumed to
// contain joint feedback. Time alone would not seem to fit in that
// category).
if (j_feedback.is_valid(joint_feedback::ValidFieldTypes::POSITION)
|| j_feedback.is_valid(joint_feedback::ValidFieldTypes::VELOCITY)
|| j_feedback.is_valid(joint_feedback::ValidFieldTypes::ACCELERATION))
{
tmp_msg.init(j_feedback);
this->joint_feedback_messages_.push_back(tmp_msg);
}
}


LOG_COMM("Joint feedback successfully unloaded");
return true;
}
Expand Down