47 #ifndef CLEARPATH_MESSAGE_H 48 #define CLEARPATH_MESSAGE_H 78 static const size_t MAX_MSG_LENGTH = 256;
82 static const size_t CRC_LENGTH = 2;
83 static const uint16_t CRC_INIT_VAL = 0xFFFF;
85 static const size_t HEADER_LENGTH = 12;
112 static const size_t MIN_MSG_LENGTH = HEADER_LENGTH + CRC_LENGTH;
113 static const uint8_t SOH = 0xAA;
114 static const uint8_t STX = 0x55;
119 return total_len - CRC_LENGTH;
122 void setLength(uint8_t len);
124 void setVersion(uint8_t version);
126 void setTimestamp(uint32_t timestamp);
128 void setFlags(uint8_t flags);
130 void setType(uint16_t
type);
132 uint8_t *getPayloadPointer(
size_t offset = 0);
134 void setPayload(
void *buf,
size_t buf_size);
136 void setPayloadLength(uint8_t len);
143 Message(
void *input,
size_t msg_len);
147 Message(uint16_t type, uint8_t *payload,
size_t payload_len,
148 uint32_t timestamp = 0, uint8_t flags = 0, uint8_t version = 0);
155 uint8_t getLengthComp();
157 uint8_t getVersion();
165 uint16_t getChecksum();
169 return total_len - HEADER_LENGTH - CRC_LENGTH;
172 size_t getPayload(
void *buf,
size_t max_size);
179 size_t toBytes(
void *buf,
size_t buf_size);
181 bool isValid(
char *whyNot = NULL,
size_t strLen = 0);
185 return getType() < 0x4000;
190 return (getType() >= 0x4000) && (getType() < 0x8000);
195 return (getType() >= 0x8000) && (getType() < 0xC000);
198 virtual std::ostream &printMessage(std::ostream &stream = std::cout);
200 void printRaw(std::ostream &stream = std::cout);
203 static Message *factory(
void *input,
size_t msg_len);
207 static Message *waitNext(
double timeout = 0.0);
320 #endif // CLEARPATH_MESSAGE_H
std::ostream & operator<<(std::ostream &stream, clearpath::Message &msg)
MessageException(const char *msg, enum errors ex_type=ERROR_BASE)
const ros::Time & getTimestamp(const T &t)
size_t getPayloadLength()
bool isValid(const trajectory_msgs::JointTrajectoryPoint &point, const unsigned int joint_dim)