ROS Serial library for Mbed platforms for ROS Jade Turtle. Check http://wiki.ros.org/rosserial_mbed/ for more information.
Dependents: rosserial_mbed_hello_world_publisher_jade
ROSSerial_mbed for Jade Distribution
The Robot Operating System (ROS) is a flexible framework for writing robot software. It is a collection of tools, libraries, and conventions that aim to simplify the task of creating complex and robust robot behavior across a wide variety of robotic platforms.
The rosserial_mbed package allows to write ROS nodes on any mbed enabled devices and have them connected to a running ROS system on your computer using the serial port.
Hello World (example publisher)
Import programrosserial_mbed_hello_world_publisher_jade
rosserial_mbed Hello World example for jade distribution
Running the Code
Now, launch the roscore in a new terminal window:
Quote:
$ roscore
Next, run the rosserial client application that forwards your MBED messages to the rest of ROS. Make sure to use the correct serial port:
Quote:
$ rosrun rosserial_python serial_node.py /dev/ttyACM0
Finally, watch the greetings come in from your MBED by launching a new terminal window and entering :
Quote:
$ rostopic echo chatter
See Also
More examples
Blink
/* * rosserial Subscriber Example * Blinks an LED on callback */ #include "mbed.h" #include <ros.h> #include <std_msgs/Empty.h> ros::NodeHandle nh; DigitalOut myled(LED1); void messageCb(const std_msgs::Empty& toggle_msg){ myled = !myled; // blink the led } ros::Subscriber<std_msgs::Empty> sub("toggle_led", &messageCb); int main() { nh.initNode(); nh.subscribe(sub); while (1) { nh.spinOnce(); wait_ms(1); } }
Push
/* * Button Example for Rosserial */ #include "mbed.h" #include <ros.h> #include <std_msgs/Bool.h> PinName button = p20; ros::NodeHandle nh; std_msgs::Bool pushed_msg; ros::Publisher pub_button("pushed", &pushed_msg); DigitalIn button_pin(button); DigitalOut led_pin(LED1); bool last_reading; long last_debounce_time=0; long debounce_delay=50; bool published = true; Timer t; int main() { t.start(); nh.initNode(); nh.advertise(pub_button); //Enable the pullup resistor on the button button_pin.mode(PullUp); //The button is a normally button last_reading = ! button_pin; while (1) { bool reading = ! button_pin; if (last_reading!= reading) { last_debounce_time = t.read_ms(); published = false; } //if the button value has not changed for the debounce delay, we know its stable if ( !published && (t.read_ms() - last_debounce_time) > debounce_delay) { led_pin = reading; pushed_msg.data = reading; pub_button.publish(&pushed_msg); published = true; } last_reading = reading; nh.spinOnce(); } }
trajectory_msgs/JointTrajectoryPoint.h@0:a906bb7c7831, 2016-03-31 (annotated)
- Committer:
- garyservin
- Date:
- Thu Mar 31 23:23:15 2016 +0000
- Revision:
- 0:a906bb7c7831
ROS Serial library for Mbed platforms for ROS Jade Turtle. Check http://wiki.ros.org/rosserial_mbed/ for more information.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:a906bb7c7831 | 1 | #ifndef _ROS_trajectory_msgs_JointTrajectoryPoint_h |
garyservin | 0:a906bb7c7831 | 2 | #define _ROS_trajectory_msgs_JointTrajectoryPoint_h |
garyservin | 0:a906bb7c7831 | 3 | |
garyservin | 0:a906bb7c7831 | 4 | #include <stdint.h> |
garyservin | 0:a906bb7c7831 | 5 | #include <string.h> |
garyservin | 0:a906bb7c7831 | 6 | #include <stdlib.h> |
garyservin | 0:a906bb7c7831 | 7 | #include "ros/msg.h" |
garyservin | 0:a906bb7c7831 | 8 | #include "ros/duration.h" |
garyservin | 0:a906bb7c7831 | 9 | |
garyservin | 0:a906bb7c7831 | 10 | namespace trajectory_msgs |
garyservin | 0:a906bb7c7831 | 11 | { |
garyservin | 0:a906bb7c7831 | 12 | |
garyservin | 0:a906bb7c7831 | 13 | class JointTrajectoryPoint : public ros::Msg |
garyservin | 0:a906bb7c7831 | 14 | { |
garyservin | 0:a906bb7c7831 | 15 | public: |
garyservin | 0:a906bb7c7831 | 16 | uint8_t positions_length; |
garyservin | 0:a906bb7c7831 | 17 | double st_positions; |
garyservin | 0:a906bb7c7831 | 18 | double * positions; |
garyservin | 0:a906bb7c7831 | 19 | uint8_t velocities_length; |
garyservin | 0:a906bb7c7831 | 20 | double st_velocities; |
garyservin | 0:a906bb7c7831 | 21 | double * velocities; |
garyservin | 0:a906bb7c7831 | 22 | uint8_t accelerations_length; |
garyservin | 0:a906bb7c7831 | 23 | double st_accelerations; |
garyservin | 0:a906bb7c7831 | 24 | double * accelerations; |
garyservin | 0:a906bb7c7831 | 25 | uint8_t effort_length; |
garyservin | 0:a906bb7c7831 | 26 | double st_effort; |
garyservin | 0:a906bb7c7831 | 27 | double * effort; |
garyservin | 0:a906bb7c7831 | 28 | ros::Duration time_from_start; |
garyservin | 0:a906bb7c7831 | 29 | |
garyservin | 0:a906bb7c7831 | 30 | JointTrajectoryPoint(): |
garyservin | 0:a906bb7c7831 | 31 | positions_length(0), positions(NULL), |
garyservin | 0:a906bb7c7831 | 32 | velocities_length(0), velocities(NULL), |
garyservin | 0:a906bb7c7831 | 33 | accelerations_length(0), accelerations(NULL), |
garyservin | 0:a906bb7c7831 | 34 | effort_length(0), effort(NULL), |
garyservin | 0:a906bb7c7831 | 35 | time_from_start() |
garyservin | 0:a906bb7c7831 | 36 | { |
garyservin | 0:a906bb7c7831 | 37 | } |
garyservin | 0:a906bb7c7831 | 38 | |
garyservin | 0:a906bb7c7831 | 39 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:a906bb7c7831 | 40 | { |
garyservin | 0:a906bb7c7831 | 41 | int offset = 0; |
garyservin | 0:a906bb7c7831 | 42 | *(outbuffer + offset++) = positions_length; |
garyservin | 0:a906bb7c7831 | 43 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 44 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 45 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 46 | for( uint8_t i = 0; i < positions_length; i++){ |
garyservin | 0:a906bb7c7831 | 47 | union { |
garyservin | 0:a906bb7c7831 | 48 | double real; |
garyservin | 0:a906bb7c7831 | 49 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 50 | } u_positionsi; |
garyservin | 0:a906bb7c7831 | 51 | u_positionsi.real = this->positions[i]; |
garyservin | 0:a906bb7c7831 | 52 | *(outbuffer + offset + 0) = (u_positionsi.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 53 | *(outbuffer + offset + 1) = (u_positionsi.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 54 | *(outbuffer + offset + 2) = (u_positionsi.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 55 | *(outbuffer + offset + 3) = (u_positionsi.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 56 | *(outbuffer + offset + 4) = (u_positionsi.base >> (8 * 4)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 57 | *(outbuffer + offset + 5) = (u_positionsi.base >> (8 * 5)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 58 | *(outbuffer + offset + 6) = (u_positionsi.base >> (8 * 6)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 59 | *(outbuffer + offset + 7) = (u_positionsi.base >> (8 * 7)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 60 | offset += sizeof(this->positions[i]); |
garyservin | 0:a906bb7c7831 | 61 | } |
garyservin | 0:a906bb7c7831 | 62 | *(outbuffer + offset++) = velocities_length; |
garyservin | 0:a906bb7c7831 | 63 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 64 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 65 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 66 | for( uint8_t i = 0; i < velocities_length; i++){ |
garyservin | 0:a906bb7c7831 | 67 | union { |
garyservin | 0:a906bb7c7831 | 68 | double real; |
garyservin | 0:a906bb7c7831 | 69 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 70 | } u_velocitiesi; |
garyservin | 0:a906bb7c7831 | 71 | u_velocitiesi.real = this->velocities[i]; |
garyservin | 0:a906bb7c7831 | 72 | *(outbuffer + offset + 0) = (u_velocitiesi.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 73 | *(outbuffer + offset + 1) = (u_velocitiesi.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 74 | *(outbuffer + offset + 2) = (u_velocitiesi.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 75 | *(outbuffer + offset + 3) = (u_velocitiesi.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 76 | *(outbuffer + offset + 4) = (u_velocitiesi.base >> (8 * 4)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 77 | *(outbuffer + offset + 5) = (u_velocitiesi.base >> (8 * 5)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 78 | *(outbuffer + offset + 6) = (u_velocitiesi.base >> (8 * 6)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 79 | *(outbuffer + offset + 7) = (u_velocitiesi.base >> (8 * 7)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 80 | offset += sizeof(this->velocities[i]); |
garyservin | 0:a906bb7c7831 | 81 | } |
garyservin | 0:a906bb7c7831 | 82 | *(outbuffer + offset++) = accelerations_length; |
garyservin | 0:a906bb7c7831 | 83 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 84 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 85 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 86 | for( uint8_t i = 0; i < accelerations_length; i++){ |
garyservin | 0:a906bb7c7831 | 87 | union { |
garyservin | 0:a906bb7c7831 | 88 | double real; |
garyservin | 0:a906bb7c7831 | 89 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 90 | } u_accelerationsi; |
garyservin | 0:a906bb7c7831 | 91 | u_accelerationsi.real = this->accelerations[i]; |
garyservin | 0:a906bb7c7831 | 92 | *(outbuffer + offset + 0) = (u_accelerationsi.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 93 | *(outbuffer + offset + 1) = (u_accelerationsi.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 94 | *(outbuffer + offset + 2) = (u_accelerationsi.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 95 | *(outbuffer + offset + 3) = (u_accelerationsi.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 96 | *(outbuffer + offset + 4) = (u_accelerationsi.base >> (8 * 4)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 97 | *(outbuffer + offset + 5) = (u_accelerationsi.base >> (8 * 5)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 98 | *(outbuffer + offset + 6) = (u_accelerationsi.base >> (8 * 6)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 99 | *(outbuffer + offset + 7) = (u_accelerationsi.base >> (8 * 7)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 100 | offset += sizeof(this->accelerations[i]); |
garyservin | 0:a906bb7c7831 | 101 | } |
garyservin | 0:a906bb7c7831 | 102 | *(outbuffer + offset++) = effort_length; |
garyservin | 0:a906bb7c7831 | 103 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 104 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 105 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 106 | for( uint8_t i = 0; i < effort_length; i++){ |
garyservin | 0:a906bb7c7831 | 107 | union { |
garyservin | 0:a906bb7c7831 | 108 | double real; |
garyservin | 0:a906bb7c7831 | 109 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 110 | } u_efforti; |
garyservin | 0:a906bb7c7831 | 111 | u_efforti.real = this->effort[i]; |
garyservin | 0:a906bb7c7831 | 112 | *(outbuffer + offset + 0) = (u_efforti.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 113 | *(outbuffer + offset + 1) = (u_efforti.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 114 | *(outbuffer + offset + 2) = (u_efforti.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 115 | *(outbuffer + offset + 3) = (u_efforti.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 116 | *(outbuffer + offset + 4) = (u_efforti.base >> (8 * 4)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 117 | *(outbuffer + offset + 5) = (u_efforti.base >> (8 * 5)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 118 | *(outbuffer + offset + 6) = (u_efforti.base >> (8 * 6)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 119 | *(outbuffer + offset + 7) = (u_efforti.base >> (8 * 7)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 120 | offset += sizeof(this->effort[i]); |
garyservin | 0:a906bb7c7831 | 121 | } |
garyservin | 0:a906bb7c7831 | 122 | *(outbuffer + offset + 0) = (this->time_from_start.sec >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 123 | *(outbuffer + offset + 1) = (this->time_from_start.sec >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 124 | *(outbuffer + offset + 2) = (this->time_from_start.sec >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 125 | *(outbuffer + offset + 3) = (this->time_from_start.sec >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 126 | offset += sizeof(this->time_from_start.sec); |
garyservin | 0:a906bb7c7831 | 127 | *(outbuffer + offset + 0) = (this->time_from_start.nsec >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 128 | *(outbuffer + offset + 1) = (this->time_from_start.nsec >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 129 | *(outbuffer + offset + 2) = (this->time_from_start.nsec >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 130 | *(outbuffer + offset + 3) = (this->time_from_start.nsec >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 131 | offset += sizeof(this->time_from_start.nsec); |
garyservin | 0:a906bb7c7831 | 132 | return offset; |
garyservin | 0:a906bb7c7831 | 133 | } |
garyservin | 0:a906bb7c7831 | 134 | |
garyservin | 0:a906bb7c7831 | 135 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:a906bb7c7831 | 136 | { |
garyservin | 0:a906bb7c7831 | 137 | int offset = 0; |
garyservin | 0:a906bb7c7831 | 138 | uint8_t positions_lengthT = *(inbuffer + offset++); |
garyservin | 0:a906bb7c7831 | 139 | if(positions_lengthT > positions_length) |
garyservin | 0:a906bb7c7831 | 140 | this->positions = (double*)realloc(this->positions, positions_lengthT * sizeof(double)); |
garyservin | 0:a906bb7c7831 | 141 | offset += 3; |
garyservin | 0:a906bb7c7831 | 142 | positions_length = positions_lengthT; |
garyservin | 0:a906bb7c7831 | 143 | for( uint8_t i = 0; i < positions_length; i++){ |
garyservin | 0:a906bb7c7831 | 144 | union { |
garyservin | 0:a906bb7c7831 | 145 | double real; |
garyservin | 0:a906bb7c7831 | 146 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 147 | } u_st_positions; |
garyservin | 0:a906bb7c7831 | 148 | u_st_positions.base = 0; |
garyservin | 0:a906bb7c7831 | 149 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 150 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 151 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 152 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 153 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
garyservin | 0:a906bb7c7831 | 154 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
garyservin | 0:a906bb7c7831 | 155 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
garyservin | 0:a906bb7c7831 | 156 | u_st_positions.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
garyservin | 0:a906bb7c7831 | 157 | this->st_positions = u_st_positions.real; |
garyservin | 0:a906bb7c7831 | 158 | offset += sizeof(this->st_positions); |
garyservin | 0:a906bb7c7831 | 159 | memcpy( &(this->positions[i]), &(this->st_positions), sizeof(double)); |
garyservin | 0:a906bb7c7831 | 160 | } |
garyservin | 0:a906bb7c7831 | 161 | uint8_t velocities_lengthT = *(inbuffer + offset++); |
garyservin | 0:a906bb7c7831 | 162 | if(velocities_lengthT > velocities_length) |
garyservin | 0:a906bb7c7831 | 163 | this->velocities = (double*)realloc(this->velocities, velocities_lengthT * sizeof(double)); |
garyservin | 0:a906bb7c7831 | 164 | offset += 3; |
garyservin | 0:a906bb7c7831 | 165 | velocities_length = velocities_lengthT; |
garyservin | 0:a906bb7c7831 | 166 | for( uint8_t i = 0; i < velocities_length; i++){ |
garyservin | 0:a906bb7c7831 | 167 | union { |
garyservin | 0:a906bb7c7831 | 168 | double real; |
garyservin | 0:a906bb7c7831 | 169 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 170 | } u_st_velocities; |
garyservin | 0:a906bb7c7831 | 171 | u_st_velocities.base = 0; |
garyservin | 0:a906bb7c7831 | 172 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 173 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 174 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 175 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 176 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
garyservin | 0:a906bb7c7831 | 177 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
garyservin | 0:a906bb7c7831 | 178 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
garyservin | 0:a906bb7c7831 | 179 | u_st_velocities.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
garyservin | 0:a906bb7c7831 | 180 | this->st_velocities = u_st_velocities.real; |
garyservin | 0:a906bb7c7831 | 181 | offset += sizeof(this->st_velocities); |
garyservin | 0:a906bb7c7831 | 182 | memcpy( &(this->velocities[i]), &(this->st_velocities), sizeof(double)); |
garyservin | 0:a906bb7c7831 | 183 | } |
garyservin | 0:a906bb7c7831 | 184 | uint8_t accelerations_lengthT = *(inbuffer + offset++); |
garyservin | 0:a906bb7c7831 | 185 | if(accelerations_lengthT > accelerations_length) |
garyservin | 0:a906bb7c7831 | 186 | this->accelerations = (double*)realloc(this->accelerations, accelerations_lengthT * sizeof(double)); |
garyservin | 0:a906bb7c7831 | 187 | offset += 3; |
garyservin | 0:a906bb7c7831 | 188 | accelerations_length = accelerations_lengthT; |
garyservin | 0:a906bb7c7831 | 189 | for( uint8_t i = 0; i < accelerations_length; i++){ |
garyservin | 0:a906bb7c7831 | 190 | union { |
garyservin | 0:a906bb7c7831 | 191 | double real; |
garyservin | 0:a906bb7c7831 | 192 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 193 | } u_st_accelerations; |
garyservin | 0:a906bb7c7831 | 194 | u_st_accelerations.base = 0; |
garyservin | 0:a906bb7c7831 | 195 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 196 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 197 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 198 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 199 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
garyservin | 0:a906bb7c7831 | 200 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
garyservin | 0:a906bb7c7831 | 201 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
garyservin | 0:a906bb7c7831 | 202 | u_st_accelerations.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
garyservin | 0:a906bb7c7831 | 203 | this->st_accelerations = u_st_accelerations.real; |
garyservin | 0:a906bb7c7831 | 204 | offset += sizeof(this->st_accelerations); |
garyservin | 0:a906bb7c7831 | 205 | memcpy( &(this->accelerations[i]), &(this->st_accelerations), sizeof(double)); |
garyservin | 0:a906bb7c7831 | 206 | } |
garyservin | 0:a906bb7c7831 | 207 | uint8_t effort_lengthT = *(inbuffer + offset++); |
garyservin | 0:a906bb7c7831 | 208 | if(effort_lengthT > effort_length) |
garyservin | 0:a906bb7c7831 | 209 | this->effort = (double*)realloc(this->effort, effort_lengthT * sizeof(double)); |
garyservin | 0:a906bb7c7831 | 210 | offset += 3; |
garyservin | 0:a906bb7c7831 | 211 | effort_length = effort_lengthT; |
garyservin | 0:a906bb7c7831 | 212 | for( uint8_t i = 0; i < effort_length; i++){ |
garyservin | 0:a906bb7c7831 | 213 | union { |
garyservin | 0:a906bb7c7831 | 214 | double real; |
garyservin | 0:a906bb7c7831 | 215 | uint64_t base; |
garyservin | 0:a906bb7c7831 | 216 | } u_st_effort; |
garyservin | 0:a906bb7c7831 | 217 | u_st_effort.base = 0; |
garyservin | 0:a906bb7c7831 | 218 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 219 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 220 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 221 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 222 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4); |
garyservin | 0:a906bb7c7831 | 223 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5); |
garyservin | 0:a906bb7c7831 | 224 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6); |
garyservin | 0:a906bb7c7831 | 225 | u_st_effort.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7); |
garyservin | 0:a906bb7c7831 | 226 | this->st_effort = u_st_effort.real; |
garyservin | 0:a906bb7c7831 | 227 | offset += sizeof(this->st_effort); |
garyservin | 0:a906bb7c7831 | 228 | memcpy( &(this->effort[i]), &(this->st_effort), sizeof(double)); |
garyservin | 0:a906bb7c7831 | 229 | } |
garyservin | 0:a906bb7c7831 | 230 | this->time_from_start.sec = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:a906bb7c7831 | 231 | this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 232 | this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 233 | this->time_from_start.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 234 | offset += sizeof(this->time_from_start.sec); |
garyservin | 0:a906bb7c7831 | 235 | this->time_from_start.nsec = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:a906bb7c7831 | 236 | this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 237 | this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 238 | this->time_from_start.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 239 | offset += sizeof(this->time_from_start.nsec); |
garyservin | 0:a906bb7c7831 | 240 | return offset; |
garyservin | 0:a906bb7c7831 | 241 | } |
garyservin | 0:a906bb7c7831 | 242 | |
garyservin | 0:a906bb7c7831 | 243 | const char * getType(){ return "trajectory_msgs/JointTrajectoryPoint"; }; |
garyservin | 0:a906bb7c7831 | 244 | const char * getMD5(){ return "f3cd1e1c4d320c79d6985c904ae5dcd3"; }; |
garyservin | 0:a906bb7c7831 | 245 | |
garyservin | 0:a906bb7c7831 | 246 | }; |
garyservin | 0:a906bb7c7831 | 247 | |
garyservin | 0:a906bb7c7831 | 248 | } |
garyservin | 0:a906bb7c7831 | 249 | #endif |