1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 01:50:46 +02:00

Added parse and toString functions for higher-level primary functions

This commit is contained in:
Felix Mauch
2019-04-09 11:51:07 +02:00
parent 4bf5793d79
commit 6699c1facb
10 changed files with 125 additions and 22 deletions

View File

@@ -35,16 +35,20 @@ namespace ur_driver
{
namespace primary_interface
{
class PrimaryPackage : comm::URPackage<PackageHeader>
class PrimaryPackage : public comm::URPackage<PackageHeader>
{
public:
PrimaryPackage() = default;
virtual ~PrimaryPackage() = default;
virtual bool parseWith(comm::BinParser& bp);
virtual std::string toString() const;
private:
uint8_t* data_buffer_;
std::string buffer_;
};
} // namespace primary_interface
} // namespace ur_driver

View File

@@ -34,20 +34,7 @@ namespace ur_driver
{
namespace primary_interface
{
enum class message_type : uint8_t
{
ROBOT_MESSAGE_TEXT = 0,
ROBOT_MESSAGE_PROGRAM_LABEL = 1,
PROGRAM_STATE_MESSAGE_VARIABLE_UPDATE = 2,
ROBOT_MESSAGE_VERSION = 3,
ROBOT_MESSAGE_SAFETY_MODE = 5,
ROBOT_MESSAGE_ERROR_CODE = 6,
ROBOT_MESSAGE_KEY = 7,
ROBOT_MESSAGE_REQUEST_VALUE = 9,
ROBOT_MESSAGE_RUNTIME_EXCEPTION = 10
};
class RobotMessage : PrimaryPackage
class RobotMessage : public PrimaryPackage
{
public:
RobotMessage(const uint64_t timestamp, const uint8_t source) : timestamp_(timestamp), source_(source)
@@ -55,8 +42,8 @@ public:
}
virtual ~RobotMessage() = default;
virtual bool parseWith(comm::BinParser& bp) = 0;
virtual std::string toString() const = 0;
virtual bool parseWith(comm::BinParser& bp);
virtual std::string toString() const;
uint64_t timestamp_;
uint8_t source_;

View File

@@ -40,6 +40,7 @@ public:
VersionMessage(uint64_t timestamp, uint8_t source) : RobotMessage(timestamp, source)
{
}
virtual ~VersionMessage() = default;
virtual bool parseWith(comm::BinParser& bp);

View File

@@ -48,6 +48,15 @@ public:
RobotState() = default;
virtual ~RobotState() = default;
virtual bool parseWith(comm::BinParser& bp)
{
return true;
}
virtual std::string toString() const
{
return std::string();
}
private:
};

View File

@@ -26,7 +26,7 @@ namespace primary_interface
* a combination between the perfect model parameters and the correction deltas as noted in the
* configuration files on the robot controller.
*/
class KinematicsInfo : RobotState
class KinematicsInfo : public RobotState
{
public:
KinematicsInfo() = default;

View File

@@ -43,6 +43,9 @@ public:
virtual ~PackageHeader() = default;
using _package_size_type = uint16_t;
PackageHeader(PackageType& type) : package_type_(type){};
PackageHeader(_package_size_type& size, PackageType& type) : package_size_(size), package_type_(type){};
static size_t getPackageLength(uint8_t* buf)
{
return be16toh(*(reinterpret_cast<_package_size_type*>(buf)));