24 #define MESSAGE_CONSTRUCTORS(MessageClass, ExpectedLength) \ 25 MessageClass::MessageClass(void* input, size_t msg_len) : Message(input, msg_len) \ 27 if( ((ExpectedLength) >= 0) && ((ssize_t)getPayloadLength() != (ExpectedLength)) ) { \ 29 ss << "Bad payload length: actual="<<getPayloadLength(); \ 30 ss <<" vs. expected="<<(ExpectedLength); \ 31 throw new MessageException(ss.str().c_str(), MessageException::INVALID_LENGTH); \ 34 MessageClass::MessageClass(const MessageClass& other) : Message(other) {} 41 #define MESSAGE_CONVENIENCE_FNS(MessageClass, DataMsgID) \ 42 MessageClass* MessageClass::popNext() { \ 43 return dynamic_cast<MessageClass*>(Transport::instance().popNext(DataMsgID)); \ 46 MessageClass* MessageClass::waitNext(double timeout) { \ 47 return dynamic_cast<MessageClass*>(Transport::instance().waitNext(DataMsgID, timeout)); \ 50 MessageClass* MessageClass::getUpdate(double timeout) { \ 51 Transport::instance().flush(DataMsgID); \ 53 return dynamic_cast<MessageClass*>( \ 54 Transport::instance().waitNext(DataMsgID, timeout) ); \ 57 void MessageClass::subscribe(uint16_t freq) { \ 58 Request(DataMsgID-0x4000, freq).send(); \ 61 enum MessageTypes MessageClass::getTypeID() { \ 69 double DataAckermannOutput::getSteering()
71 return btof(getPayloadPointer(STEERING), 2, 100);
74 double DataAckermannOutput::getThrottle()
76 return btof(getPayloadPointer(THROTTLE), 2, 100);
79 double DataAckermannOutput::getBrake()
81 return btof(getPayloadPointer(BRAKE), 2, 100);
84 ostream &DataAckermannOutput::printMessage(ostream &stream)
86 stream <<
"Ackermann Control" << endl;
87 stream <<
"=================" << endl;
88 stream <<
"Steering: " << getSteering() << endl;
89 stream <<
"Throttle: " << getThrottle() << endl;
90 stream <<
"Brake : " << getBrake() << endl;
102 return btof(getPayloadPointer(LEFT_P), 2, 100);
105 double DataDifferentialControl::getLeftI()
107 return btof(getPayloadPointer(LEFT_I), 2, 100);
110 double DataDifferentialControl::getLeftD()
112 return btof(getPayloadPointer(LEFT_D), 2, 100);
115 double DataDifferentialControl::getLeftFeedForward()
117 return btof(getPayloadPointer(LEFT_FEEDFWD), 2, 100);
120 double DataDifferentialControl::getLeftStiction()
122 return btof(getPayloadPointer(LEFT_STIC), 2, 100);
125 double DataDifferentialControl::getLeftIntegralLimit()
127 return btof(getPayloadPointer(LEFT_INT_LIM), 2, 100);
130 double DataDifferentialControl::getRightP()
132 return btof(getPayloadPointer(RIGHT_P), 2, 100);
135 double DataDifferentialControl::getRightI()
137 return btof(getPayloadPointer(RIGHT_I), 2, 100);
140 double DataDifferentialControl::getRightD()
142 return btof(getPayloadPointer(RIGHT_D), 2, 100);
145 double DataDifferentialControl::getRightFeedForward()
147 return btof(getPayloadPointer(RIGHT_FEEDFWD), 2, 100);
150 double DataDifferentialControl::getRightStiction()
152 return btof(getPayloadPointer(RIGHT_STIC), 2, 100);
155 double DataDifferentialControl::getRightIntegralLimit()
157 return btof(getPayloadPointer(RIGHT_INT_LIM), 2, 100);
160 ostream &DataDifferentialControl::printMessage(ostream &stream)
162 stream <<
"Differential Control Constant Data" << endl;
163 stream <<
"==================================" << endl;
164 stream <<
"Left P : " << getLeftP() << endl;
165 stream <<
"Left I : " << getLeftI() << endl;
166 stream <<
"Left D : " << getLeftD() << endl;
167 stream <<
"Left Feed Forward : " << getLeftFeedForward() << endl;
168 stream <<
"Left Stiction : " << getLeftStiction() << endl;
169 stream <<
"Left Integral Limit : " << getLeftIntegralLimit() << endl;
170 stream <<
"Right P : " << getRightP() << endl;
171 stream <<
"Right I : " << getRightI() << endl;
172 stream <<
"Right D : " << getRightD() << endl;
173 stream <<
"Right Feed Forward : " << getRightFeedForward() << endl;
174 stream <<
"Right Stiction : " << getRightStiction() << endl;
175 stream <<
"Right Integral Limit: " << getRightIntegralLimit() << endl;
186 return btof(getPayloadPointer(LEFT), 2, 100);
189 double DataDifferentialOutput::getRight()
191 return btof(getPayloadPointer(RIGHT), 2, 100);
194 ostream &DataDifferentialOutput::printMessage(ostream &stream)
196 stream <<
"Differential Output Data" << endl;
197 stream <<
"========================" << endl;
198 stream <<
"Left : " << getLeft() << endl;
199 stream <<
"Right: " << getRight() << endl;
209 double DataDifferentialSpeed::getLeftSpeed()
211 return btof(getPayloadPointer(LEFT_SPEED), 2, 100);
214 double DataDifferentialSpeed::getLeftAccel()
216 return btof(getPayloadPointer(LEFT_ACCEL), 2, 100);
219 double DataDifferentialSpeed::getRightSpeed()
221 return btof(getPayloadPointer(RIGHT_SPEED), 2, 100);
224 double DataDifferentialSpeed::getRightAccel()
226 return btof(getPayloadPointer(RIGHT_ACCEL), 2, 100);
229 ostream &DataDifferentialSpeed::printMessage(ostream &stream)
231 stream <<
"Differential Speed Data" << endl;
232 stream <<
"=======================" << endl;
233 stream <<
"Left Speed : " << getLeftSpeed() << endl;
234 stream <<
"Left Accel : " << getLeftAccel() << endl;
235 stream <<
"Right Speed: " << getRightSpeed() << endl;
236 stream <<
"Right Accel: " << getRightAccel() << endl;
252 DataEncoders::DataEncoders(
void *input,
size_t msg_len) :
Message(input, msg_len)
258 ss <<
" vs. expected=" << (1 +
getCount() * 6);
288 stream <<
"Encoder Data" << endl;
289 stream <<
"============" << endl;
290 stream <<
"Count : " << (int) (
getCount()) << endl;
291 for (
unsigned i = 0; i <
getCount(); ++i)
293 stream <<
"Encoder " << i <<
":" << endl;
294 stream <<
" Travel: " <<
getTravel(i) << endl;
295 stream <<
" Speed : " <<
getSpeed(i) << endl;
318 stream <<
"Raw Encoder Data" << endl;
319 stream <<
"================" << endl;
320 for (
int i = 0; i <
getCount(); ++i)
322 stream <<
"Encoder " << i <<
": " << getTicks(i) << endl;
360 stream <<
"Firmware Info" << endl;
361 stream <<
"=============" << endl;
362 stream <<
"Major firmware version: " << (int) getMajorFirmwareVersion() << endl;
363 stream <<
"Minor firmware version: " << (int) getMinorFirmwareVersion() << endl;
364 stream <<
"Major protocol version: " << (int) getMajorProtocolVersion() << endl;
365 stream <<
"Minor protocol version: " << (int) getMinorProtocolVersion() << endl;
367 stream <<
"Firmware write time : ";
368 stream << (2000 + t.
year()) <<
"-" << (
int) t.
month() <<
"-" << (int) t.
day() <<
" ";
369 stream << (int) t.
hour() <<
":" << (int) t.
minute() << endl;
386 stream <<
"Gear" << endl;
387 stream <<
"====" << endl;
388 stream <<
"Gear: " << (int) getGear() << endl;
410 stream <<
"Max Acceleration Data" << endl;
411 stream <<
"=====================" << endl;
412 stream <<
"Max Forward: " << getForwardMax() << endl;
413 stream <<
"Max Reverse: " << getReverseMax() << endl;
435 stream <<
"Max Speed Data" << endl;
436 stream <<
"==============" << endl;
437 stream <<
"Max Forward: " << getForwardMax() << endl;
438 stream <<
"Max Reverse: " << getReverseMax() << endl;
465 stream <<
"Platform Acceleration" << endl;
466 stream <<
"=====================" << endl;
467 stream <<
"X: " <<
getX() << endl;
468 stream <<
"Y: " <<
getY() << endl;
469 stream <<
"Z: " <<
getZ() << endl;
479 uint8_t DataPlatformInfo::strlenModel()
488 size_t cpy_len = strlenModel();
497 char offset = strlenModel() + 1;
503 char offset = strlenModel() + 2;
509 stream <<
"Platform Info" << endl;
510 stream <<
"=============" << endl;
511 stream <<
"Model : " << getModel() << endl;
512 stream <<
"Revision: " << (int) (getRevision()) << endl;
513 stream <<
"Serial : " << getSerial() << endl;
523 string DataPlatformName::getName()
534 stream <<
"Platform Name" << endl;
535 stream <<
"=============" << endl;
536 stream <<
"Name: " <<
getName() << endl;
563 stream <<
"PlatformMagnetometer Data" << endl;
564 stream <<
"=================" << endl;
565 stream <<
"X: " <<
getX() << endl;
566 stream <<
"Y: " <<
getY() << endl;
567 stream <<
"Z: " <<
getZ() << endl;
594 stream <<
"Platform Orientation" << endl;
595 stream <<
"====================" << endl;
596 stream <<
"Roll : " << getRoll() << endl;
597 stream <<
"Pitch: " << getPitch() << endl;
598 stream <<
"Yaw : " <<
getYaw() << endl;
626 stream <<
"Platform Rotationa Rate Data" << endl;
627 stream <<
"============================" << endl;
628 stream <<
"Roll : " << getRollRate() << endl;
629 stream <<
"Pitch: " << getPitchRate() << endl;
630 stream <<
"Yaw : " << getYawRate() << endl;
655 + 2 * getBatteryCount()
663 + 4 * getBatteryCount()
670 stream <<
"Power System Status Data" << endl;
671 stream <<
"========================" << endl;
672 int num_bat = getBatteryCount();
673 stream <<
"Number of Batteries: " << num_bat << endl;
674 for (
int i = 0; i < num_bat; ++i)
676 stream <<
"Battery " << i <<
":" << endl;
677 stream <<
" Charge Estimate : " << getChargeEstimate(i) << endl;
678 stream <<
" Capacity Estimate: " << getCapacityEstimate(i) << endl;
679 stream <<
" Present : " << (getDescription(0).isPresent() ?
"yes" :
"no") << endl;
680 stream <<
" In Use : " << (getDescription(0).isInUse() ?
"yes" :
"no") << endl;
681 stream <<
" Type : ";
682 switch (getDescription(0).getType())
684 case BatteryDescription::EXTERNAL:
685 stream <<
"External" << endl;
687 case BatteryDescription::LEAD_ACID:
688 stream <<
"Lead-Acid" << endl;
690 case BatteryDescription::NIMH:
691 stream <<
"NiMH" << endl;
693 case BatteryDescription::GASOLINE:
694 stream <<
"Internal Combustion Engine" << endl;
697 stream <<
"Unknown Type" << endl;
711 uint8_t DataProcessorStatus::getProcessCount()
723 stream <<
"Processor Status" << endl;
724 stream <<
"================" << endl;
725 stream <<
"Process Count : " << (int) (getProcessCount()) << endl;
726 for (
unsigned int i = 0; i < getProcessCount(); ++i)
728 stream <<
"Process " << i <<
" Errors: " << getErrorCount(i) << endl;
739 uint8_t DataRangefinders::getRangefinderCount()
751 stream <<
"Rangefinder Data" << endl;
752 stream <<
"================" << endl;
753 stream <<
"Rangefinder Count: " << (int) (getRangefinderCount()) << endl;
754 for (
unsigned int i = 0; i < getRangefinderCount(); ++i)
756 stream <<
"Distance " << i <<
" : " << getDistance(i) << endl;
767 uint8_t DataRangefinderTimings::getRangefinderCount()
784 stream <<
"Rangefinder Timing Data" << endl;
785 stream <<
"=======================" << endl;
786 stream <<
"Rangefinder Count : " << (int) (getRangefinderCount()) << endl;
787 for (
unsigned int i = 0; i < getRangefinderCount(); ++i)
789 stream <<
"Rangefinder " << i <<
":" << endl;
790 stream <<
" Distance : " << getDistance(i) << endl;
791 stream <<
" Acquisition Time: " << getAcquisitionTime(i) << endl;
819 stream <<
"Raw Acceleration Data" << endl;
820 stream <<
"=====================" << endl;
821 stream <<
"X: 0x" << hex <<
getX() << endl;
822 stream <<
"Y: 0x" <<
getY() << endl;
823 stream <<
"Z: 0x" <<
getZ() << dec << endl;
833 uint8_t DataRawCurrent::getCurrentCount()
845 stream <<
"Raw Current Data" << endl;
846 stream <<
"================" << endl;
848 for (
unsigned int i = 0; i < getCurrentCount(); ++i)
850 stream <<
"Current " << i <<
": 0x" << getCurrent(i) << endl;
879 stream <<
"Raw Gyro Data" << endl;
880 stream <<
"=============" << endl;
881 stream <<
"Roll : 0x" << hex << getRoll() << endl;
882 stream <<
"Pitch: 0x" << getPitch() << endl;
883 stream <<
"Yaw : 0x" <<
getYaw() << dec << endl;
910 stream <<
"Raw Magnetometer Data" << endl;
911 stream <<
"=====================" << endl;
912 stream <<
"X: 0x" << hex <<
getX() << endl;
913 stream <<
"Y: 0x" <<
getY() << endl;
914 stream <<
"Z: 0x" <<
getZ() << dec << endl;
941 stream <<
"Raw Orientation Data" << endl;
942 stream <<
"====================" << endl;
943 stream <<
"Roll : 0x" << hex << getRoll() << endl;
944 stream <<
"Pitch: 0x" << getPitch() << endl;
945 stream <<
"Yaw : 0x" <<
getYaw() << dec << endl;
955 uint8_t DataRawTemperature::getTemperatureCount()
967 stream <<
"Raw Temperature Data" << endl;
968 stream <<
"====================" << endl;
969 stream <<
"Temperature Count: " << (int) (getTemperatureCount()) << endl;
971 for (
unsigned i = 0; i < getTemperatureCount(); ++i)
973 stream <<
"Temperature " << i <<
" : 0x" << getTemperature(i) << endl;
985 uint8_t DataRawVoltage::getVoltageCount()
997 stream <<
"Raw Voltage Data" << endl;
998 stream <<
"================" << endl;
999 stream <<
"Voltage Count: " << (int) (getVoltageCount()) << endl;
1001 for (
unsigned i = 0; i < getVoltageCount(); ++i)
1003 stream <<
"Voltage " << i <<
" : 0x" << getVoltage(i) << endl;
1022 stream <<
"Safety System Status Data" << endl;
1023 stream <<
"=========================" << endl;
1024 stream <<
"Flags: " <<
getFlags() << endl;
1040 ss <<
" vs. expected=" << expect_len;
1088 stream <<
"System Status" << endl;
1089 stream <<
"=============" << endl;
1090 stream <<
"Uptime : " <<
getUptime() << endl;
1092 stream <<
"Voltages : ";
1100 stream <<
"Currents : ";
1108 stream <<
"Temperatures : ";
1141 stream <<
"Velocity Setpoints" << endl;
1142 stream <<
"==================" << endl;
1143 stream <<
"Translational:" << getTranslational() << endl;
1144 stream <<
"Rotational: " << getRotational() << endl;
1145 stream <<
"Trans Accel: " << getTransAccel() << endl;
uint16_t getTemperature(int temperature)
double getCurrent(uint8_t index)
int64_t btoi(void *src, size_t src_len)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
double getVoltage(uint8_t index)
TFSIMD_FORCE_INLINE const tfScalar & getX() const
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
uint8_t temperatures_offset
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
uint8_t getVoltagesCount()
uint64_t btou(void *src, size_t src_len)
uint32_t getAcquisitionTime(int rangefinder)
uint8_t getCurrentsCount()
std::string getName(void *handle)
int16_t getCapacityEstimate(uint8_t battery)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
#define MESSAGE_CONVENIENCE_FNS(MessageClass, DataMsgID)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
geometry_msgs::TransformStamped t
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
uint8_t getMajorProtocolVersion()
int16_t getDistance(int rangefinder)
uint8_t * getPayloadPointer(size_t offset=0)
#define MESSAGE_CONSTRUCTORS(MessageClass, ExpectedLength)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
uint8_t getMinorProtocolVersion()
int16_t getErrorCount(int process)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
uint16_t getCurrent(int current)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
double getSpeed(uint8_t index)
DataEncoders(void *input, size_t msg_len)
uint8_t getMinorFirmwareVersion()
MESSAGE_CONVENIENCE_FNS(DataDifferentialSpeed, DATA_DIFF_WHEEL_SPEEDS)
MESSAGE_CONSTRUCTORS(DataDifferentialSpeed, PAYLOAD_LEN)
int32_t getTicks(uint8_t inx)
double getChargeEstimate(uint8_t battery)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
BatteryDescription getDescription(uint8_t battery)
uint8_t getTemperaturesCount()
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
double getTravel(uint8_t index)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
double getTemperature(uint8_t index)
size_t getPayloadLength()
int16_t getDistance(int rangefinder)
double getYaw(const tf2::Quaternion quat)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
TFSIMD_FORCE_INLINE const tfScalar & getZ() const
uint16_t getVoltage(int temperature)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
double btof(void *src, size_t src_len, double scale)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
TFSIMD_FORCE_INLINE const tfScalar & getY() const
DataSystemStatus(void *input, size_t msg_len)