rosserial library for mbed Inspired by nucho's rosserial library This library is still under development
Dependents: mbed_roshydro_test
Library still under development!
control_msgs/JointTrajectoryControllerState.h@0:30537dec6e0b, 2015-02-15 (annotated)
- Committer:
- akashvibhute
- Date:
- Sun Feb 15 10:53:43 2015 +0000
- Revision:
- 0:30537dec6e0b
First commit; Library still need to be debugged, compilation issues with new mbed and modserial updates.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
akashvibhute | 0:30537dec6e0b | 1 | #ifndef _ROS_control_msgs_JointTrajectoryControllerState_h |
akashvibhute | 0:30537dec6e0b | 2 | #define _ROS_control_msgs_JointTrajectoryControllerState_h |
akashvibhute | 0:30537dec6e0b | 3 | |
akashvibhute | 0:30537dec6e0b | 4 | #include <stdint.h> |
akashvibhute | 0:30537dec6e0b | 5 | #include <string.h> |
akashvibhute | 0:30537dec6e0b | 6 | #include <stdlib.h> |
akashvibhute | 0:30537dec6e0b | 7 | #include "ros/msg.h" |
akashvibhute | 0:30537dec6e0b | 8 | #include "std_msgs/Header.h" |
akashvibhute | 0:30537dec6e0b | 9 | #include "trajectory_msgs/JointTrajectoryPoint.h" |
akashvibhute | 0:30537dec6e0b | 10 | |
akashvibhute | 0:30537dec6e0b | 11 | namespace control_msgs |
akashvibhute | 0:30537dec6e0b | 12 | { |
akashvibhute | 0:30537dec6e0b | 13 | |
akashvibhute | 0:30537dec6e0b | 14 | class JointTrajectoryControllerState : public ros::Msg |
akashvibhute | 0:30537dec6e0b | 15 | { |
akashvibhute | 0:30537dec6e0b | 16 | public: |
akashvibhute | 0:30537dec6e0b | 17 | std_msgs::Header header; |
akashvibhute | 0:30537dec6e0b | 18 | uint8_t joint_names_length; |
akashvibhute | 0:30537dec6e0b | 19 | char* st_joint_names; |
akashvibhute | 0:30537dec6e0b | 20 | char* * joint_names; |
akashvibhute | 0:30537dec6e0b | 21 | trajectory_msgs::JointTrajectoryPoint desired; |
akashvibhute | 0:30537dec6e0b | 22 | trajectory_msgs::JointTrajectoryPoint actual; |
akashvibhute | 0:30537dec6e0b | 23 | trajectory_msgs::JointTrajectoryPoint error; |
akashvibhute | 0:30537dec6e0b | 24 | |
akashvibhute | 0:30537dec6e0b | 25 | JointTrajectoryControllerState(): |
akashvibhute | 0:30537dec6e0b | 26 | header(), |
akashvibhute | 0:30537dec6e0b | 27 | joint_names_length(0), joint_names(NULL), |
akashvibhute | 0:30537dec6e0b | 28 | desired(), |
akashvibhute | 0:30537dec6e0b | 29 | actual(), |
akashvibhute | 0:30537dec6e0b | 30 | error() |
akashvibhute | 0:30537dec6e0b | 31 | { |
akashvibhute | 0:30537dec6e0b | 32 | } |
akashvibhute | 0:30537dec6e0b | 33 | |
akashvibhute | 0:30537dec6e0b | 34 | virtual int serialize(unsigned char *outbuffer) const |
akashvibhute | 0:30537dec6e0b | 35 | { |
akashvibhute | 0:30537dec6e0b | 36 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 37 | offset += this->header.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 38 | *(outbuffer + offset++) = joint_names_length; |
akashvibhute | 0:30537dec6e0b | 39 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 40 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 41 | *(outbuffer + offset++) = 0; |
akashvibhute | 0:30537dec6e0b | 42 | for( uint8_t i = 0; i < joint_names_length; i++){ |
akashvibhute | 0:30537dec6e0b | 43 | uint32_t length_joint_namesi = strlen(this->joint_names[i]); |
akashvibhute | 0:30537dec6e0b | 44 | memcpy(outbuffer + offset, &length_joint_namesi, sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 45 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 46 | memcpy(outbuffer + offset, this->joint_names[i], length_joint_namesi); |
akashvibhute | 0:30537dec6e0b | 47 | offset += length_joint_namesi; |
akashvibhute | 0:30537dec6e0b | 48 | } |
akashvibhute | 0:30537dec6e0b | 49 | offset += this->desired.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 50 | offset += this->actual.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 51 | offset += this->error.serialize(outbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 52 | return offset; |
akashvibhute | 0:30537dec6e0b | 53 | } |
akashvibhute | 0:30537dec6e0b | 54 | |
akashvibhute | 0:30537dec6e0b | 55 | virtual int deserialize(unsigned char *inbuffer) |
akashvibhute | 0:30537dec6e0b | 56 | { |
akashvibhute | 0:30537dec6e0b | 57 | int offset = 0; |
akashvibhute | 0:30537dec6e0b | 58 | offset += this->header.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 59 | uint8_t joint_names_lengthT = *(inbuffer + offset++); |
akashvibhute | 0:30537dec6e0b | 60 | if(joint_names_lengthT > joint_names_length) |
akashvibhute | 0:30537dec6e0b | 61 | this->joint_names = (char**)realloc(this->joint_names, joint_names_lengthT * sizeof(char*)); |
akashvibhute | 0:30537dec6e0b | 62 | offset += 3; |
akashvibhute | 0:30537dec6e0b | 63 | joint_names_length = joint_names_lengthT; |
akashvibhute | 0:30537dec6e0b | 64 | for( uint8_t i = 0; i < joint_names_length; i++){ |
akashvibhute | 0:30537dec6e0b | 65 | uint32_t length_st_joint_names; |
akashvibhute | 0:30537dec6e0b | 66 | memcpy(&length_st_joint_names, (inbuffer + offset), sizeof(uint32_t)); |
akashvibhute | 0:30537dec6e0b | 67 | offset += 4; |
akashvibhute | 0:30537dec6e0b | 68 | for(unsigned int k= offset; k< offset+length_st_joint_names; ++k){ |
akashvibhute | 0:30537dec6e0b | 69 | inbuffer[k-1]=inbuffer[k]; |
akashvibhute | 0:30537dec6e0b | 70 | } |
akashvibhute | 0:30537dec6e0b | 71 | inbuffer[offset+length_st_joint_names-1]=0; |
akashvibhute | 0:30537dec6e0b | 72 | this->st_joint_names = (char *)(inbuffer + offset-1); |
akashvibhute | 0:30537dec6e0b | 73 | offset += length_st_joint_names; |
akashvibhute | 0:30537dec6e0b | 74 | memcpy( &(this->joint_names[i]), &(this->st_joint_names), sizeof(char*)); |
akashvibhute | 0:30537dec6e0b | 75 | } |
akashvibhute | 0:30537dec6e0b | 76 | offset += this->desired.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 77 | offset += this->actual.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 78 | offset += this->error.deserialize(inbuffer + offset); |
akashvibhute | 0:30537dec6e0b | 79 | return offset; |
akashvibhute | 0:30537dec6e0b | 80 | } |
akashvibhute | 0:30537dec6e0b | 81 | |
akashvibhute | 0:30537dec6e0b | 82 | const char * getType(){ return "control_msgs/JointTrajectoryControllerState"; }; |
akashvibhute | 0:30537dec6e0b | 83 | const char * getMD5(){ return "10817c60c2486ef6b33e97dcd87f4474"; }; |
akashvibhute | 0:30537dec6e0b | 84 | |
akashvibhute | 0:30537dec6e0b | 85 | }; |
akashvibhute | 0:30537dec6e0b | 86 | |
akashvibhute | 0:30537dec6e0b | 87 | } |
akashvibhute | 0:30537dec6e0b | 88 | #endif |