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

Add version detection #81

Merged
merged 9 commits into from
Feb 19, 2020
7 changes: 7 additions & 0 deletions include/abb_libegm/egm_base_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@ class EGMBaseInterface : public AbstractUDPServerInterface
bool statesOk() const;

private:
/**
* \brief Detect RobotWare and EGM protocol versions from a received EGM message.
*
* Note: Only a rough version detection is possible based on if certain fields are present or not.
jontje marked this conversation as resolved.
Show resolved Hide resolved
*/
void detectRWAndEGMVersions();

/**
* \brief Estimate the sample time.
*
Expand Down
17 changes: 17 additions & 0 deletions proto/egm_wrapper.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,26 @@ message Header
DATA = 1; // Message contains data sent by the robot controller.
}

enum RWVersion
{
RW_UNKNOWN = 0;
RW_6_10_AND_NEWER = 1;
RW_BETWEEN_6_AND_6_06_03 = 2;
RW_BETWEEN_6_07_AND_6_09_02 = 3;
gavanderhoorn marked this conversation as resolved.
Show resolved Hide resolved
}

enum EGMVersion
{
EGM_UNKNOWN = 0;
EGM_1_0 = 1;
EGM_1_1 = 2;
gavanderhoorn marked this conversation as resolved.
Show resolved Hide resolved
}

optional uint32 sequence_number = 1; // Sequence number (to be able to detect lost messages).
optional uint32 time_stamp = 2; // Time stamp in milliseconds.
optional MessageType message_type = 3 [default = UNDEFINED];
optional RWVersion rw_version = 4 [default = RW_UNKNOWN];
optional EGMVersion egm_version = 5 [default = EGM_UNKNOWN];
}

// Note: Status of the robot controller, and the active EGM motion.
Expand Down
31 changes: 31 additions & 0 deletions src/egm_base_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bool EGMBaseInterface::InputContainer::extractParsedInformation(const RobotAxes&
{
bool success = false;

detectRWAndEGMVersions();

if (has_new_data_ &&
parse(current_.mutable_header(), egm_robot_.header()) &&
parse(current_.mutable_feedback(), egm_robot_.feedback(), axes) &&
Expand Down Expand Up @@ -121,6 +123,35 @@ bool EGMBaseInterface::InputContainer::statesOk() const
* Auxiliary methods
*/

void EGMBaseInterface::InputContainer::detectRWAndEGMVersions()
gavanderhoorn marked this conversation as resolved.
Show resolved Hide resolved
{
if(has_new_data_)
{
if(egm_robot_.feedback().has_time())
{
if(egm_robot_.has_utilizationrate())
{
current_.mutable_header()->set_rw_version(wrapper::Header_RWVersion_RW_6_10_AND_NEWER);
}
else
{
current_.mutable_header()->set_rw_version(wrapper::Header_RWVersion_RW_BETWEEN_6_07_AND_6_09_02);
}
current_.mutable_header()->set_egm_version(wrapper::Header_EGMVersion_EGM_1_1);
}
else
{
current_.mutable_header()->set_rw_version(wrapper::Header_RWVersion_RW_BETWEEN_6_AND_6_06_03);
current_.mutable_header()->set_egm_version(wrapper::Header_EGMVersion_EGM_1_0);
}
}
else
{
current_.mutable_header()->set_rw_version(wrapper::Header_RWVersion_RW_UNKNOWN);
current_.mutable_header()->set_egm_version(wrapper::Header_EGMVersion_EGM_UNKNOWN);
}
}

double EGMBaseInterface::InputContainer::estimateSampleTime()
{
double estimate = 0.0;
Expand Down