Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 314

ros msg serialize and deserialize for type double

$
0
0
Hi I have done a custom message for a type uint64_t but how I do this for type double? Here my code: class EkfParameters : public ros::Msg { public: typedef uint64_t _residual_type; _residual_type residual; EkfParameters(): residual(0) { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; *(outbuffer + offset + 0) = (this->residual >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->residual >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->residual >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->residual >> (8 * 3)) & 0xFF; *(outbuffer + offset + 4) = (this->residual >> (8 * 4)) & 0xFF; *(outbuffer + offset + 5) = (this->residual >> (8 * 5)) & 0xFF; *(outbuffer + offset + 6) = (this->residual >> (8 * 6)) & 0xFF; *(outbuffer + offset + 7) = (this->residual >> (8 * 7)) & 0xFF; offset += sizeof(this->residual); return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; this->residual = ((uint64_t) (*(inbuffer + offset))); this->residual |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); this->residual |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); this->residual |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); this->residual |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); this->residual |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); this->residual |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); this->residual |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); offset += sizeof(this->residual); return offset; } const char * getType(){ return "arduino_vi_sync/EkfParameters"; }; const char * getMD5(){ return "429a0337b7125479e9bf5f4056e69192"; }; }; But how I do this for a type double. If I just change the type then I get a error message because << is not for type double. What can I do? Thanks

Viewing all articles
Browse latest Browse all 314

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>