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(); } }
visualization_msgs/Marker.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_visualization_msgs_Marker_h |
garyservin | 0:a906bb7c7831 | 2 | #define _ROS_visualization_msgs_Marker_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 "std_msgs/Header.h" |
garyservin | 0:a906bb7c7831 | 9 | #include "geometry_msgs/Pose.h" |
garyservin | 0:a906bb7c7831 | 10 | #include "geometry_msgs/Vector3.h" |
garyservin | 0:a906bb7c7831 | 11 | #include "std_msgs/ColorRGBA.h" |
garyservin | 0:a906bb7c7831 | 12 | #include "ros/duration.h" |
garyservin | 0:a906bb7c7831 | 13 | #include "geometry_msgs/Point.h" |
garyservin | 0:a906bb7c7831 | 14 | |
garyservin | 0:a906bb7c7831 | 15 | namespace visualization_msgs |
garyservin | 0:a906bb7c7831 | 16 | { |
garyservin | 0:a906bb7c7831 | 17 | |
garyservin | 0:a906bb7c7831 | 18 | class Marker : public ros::Msg |
garyservin | 0:a906bb7c7831 | 19 | { |
garyservin | 0:a906bb7c7831 | 20 | public: |
garyservin | 0:a906bb7c7831 | 21 | std_msgs::Header header; |
garyservin | 0:a906bb7c7831 | 22 | const char* ns; |
garyservin | 0:a906bb7c7831 | 23 | int32_t id; |
garyservin | 0:a906bb7c7831 | 24 | int32_t type; |
garyservin | 0:a906bb7c7831 | 25 | int32_t action; |
garyservin | 0:a906bb7c7831 | 26 | geometry_msgs::Pose pose; |
garyservin | 0:a906bb7c7831 | 27 | geometry_msgs::Vector3 scale; |
garyservin | 0:a906bb7c7831 | 28 | std_msgs::ColorRGBA color; |
garyservin | 0:a906bb7c7831 | 29 | ros::Duration lifetime; |
garyservin | 0:a906bb7c7831 | 30 | bool frame_locked; |
garyservin | 0:a906bb7c7831 | 31 | uint8_t points_length; |
garyservin | 0:a906bb7c7831 | 32 | geometry_msgs::Point st_points; |
garyservin | 0:a906bb7c7831 | 33 | geometry_msgs::Point * points; |
garyservin | 0:a906bb7c7831 | 34 | uint8_t colors_length; |
garyservin | 0:a906bb7c7831 | 35 | std_msgs::ColorRGBA st_colors; |
garyservin | 0:a906bb7c7831 | 36 | std_msgs::ColorRGBA * colors; |
garyservin | 0:a906bb7c7831 | 37 | const char* text; |
garyservin | 0:a906bb7c7831 | 38 | const char* mesh_resource; |
garyservin | 0:a906bb7c7831 | 39 | bool mesh_use_embedded_materials; |
garyservin | 0:a906bb7c7831 | 40 | enum { ARROW = 0 }; |
garyservin | 0:a906bb7c7831 | 41 | enum { CUBE = 1 }; |
garyservin | 0:a906bb7c7831 | 42 | enum { SPHERE = 2 }; |
garyservin | 0:a906bb7c7831 | 43 | enum { CYLINDER = 3 }; |
garyservin | 0:a906bb7c7831 | 44 | enum { LINE_STRIP = 4 }; |
garyservin | 0:a906bb7c7831 | 45 | enum { LINE_LIST = 5 }; |
garyservin | 0:a906bb7c7831 | 46 | enum { CUBE_LIST = 6 }; |
garyservin | 0:a906bb7c7831 | 47 | enum { SPHERE_LIST = 7 }; |
garyservin | 0:a906bb7c7831 | 48 | enum { POINTS = 8 }; |
garyservin | 0:a906bb7c7831 | 49 | enum { TEXT_VIEW_FACING = 9 }; |
garyservin | 0:a906bb7c7831 | 50 | enum { MESH_RESOURCE = 10 }; |
garyservin | 0:a906bb7c7831 | 51 | enum { TRIANGLE_LIST = 11 }; |
garyservin | 0:a906bb7c7831 | 52 | enum { ADD = 0 }; |
garyservin | 0:a906bb7c7831 | 53 | enum { MODIFY = 0 }; |
garyservin | 0:a906bb7c7831 | 54 | enum { DELETE = 2 }; |
garyservin | 0:a906bb7c7831 | 55 | enum { DELETEALL = 3 }; |
garyservin | 0:a906bb7c7831 | 56 | |
garyservin | 0:a906bb7c7831 | 57 | Marker(): |
garyservin | 0:a906bb7c7831 | 58 | header(), |
garyservin | 0:a906bb7c7831 | 59 | ns(""), |
garyservin | 0:a906bb7c7831 | 60 | id(0), |
garyservin | 0:a906bb7c7831 | 61 | type(0), |
garyservin | 0:a906bb7c7831 | 62 | action(0), |
garyservin | 0:a906bb7c7831 | 63 | pose(), |
garyservin | 0:a906bb7c7831 | 64 | scale(), |
garyservin | 0:a906bb7c7831 | 65 | color(), |
garyservin | 0:a906bb7c7831 | 66 | lifetime(), |
garyservin | 0:a906bb7c7831 | 67 | frame_locked(0), |
garyservin | 0:a906bb7c7831 | 68 | points_length(0), points(NULL), |
garyservin | 0:a906bb7c7831 | 69 | colors_length(0), colors(NULL), |
garyservin | 0:a906bb7c7831 | 70 | text(""), |
garyservin | 0:a906bb7c7831 | 71 | mesh_resource(""), |
garyservin | 0:a906bb7c7831 | 72 | mesh_use_embedded_materials(0) |
garyservin | 0:a906bb7c7831 | 73 | { |
garyservin | 0:a906bb7c7831 | 74 | } |
garyservin | 0:a906bb7c7831 | 75 | |
garyservin | 0:a906bb7c7831 | 76 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:a906bb7c7831 | 77 | { |
garyservin | 0:a906bb7c7831 | 78 | int offset = 0; |
garyservin | 0:a906bb7c7831 | 79 | offset += this->header.serialize(outbuffer + offset); |
garyservin | 0:a906bb7c7831 | 80 | uint32_t length_ns = strlen(this->ns); |
garyservin | 0:a906bb7c7831 | 81 | memcpy(outbuffer + offset, &length_ns, sizeof(uint32_t)); |
garyservin | 0:a906bb7c7831 | 82 | offset += 4; |
garyservin | 0:a906bb7c7831 | 83 | memcpy(outbuffer + offset, this->ns, length_ns); |
garyservin | 0:a906bb7c7831 | 84 | offset += length_ns; |
garyservin | 0:a906bb7c7831 | 85 | union { |
garyservin | 0:a906bb7c7831 | 86 | int32_t real; |
garyservin | 0:a906bb7c7831 | 87 | uint32_t base; |
garyservin | 0:a906bb7c7831 | 88 | } u_id; |
garyservin | 0:a906bb7c7831 | 89 | u_id.real = this->id; |
garyservin | 0:a906bb7c7831 | 90 | *(outbuffer + offset + 0) = (u_id.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 91 | *(outbuffer + offset + 1) = (u_id.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 92 | *(outbuffer + offset + 2) = (u_id.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 93 | *(outbuffer + offset + 3) = (u_id.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 94 | offset += sizeof(this->id); |
garyservin | 0:a906bb7c7831 | 95 | union { |
garyservin | 0:a906bb7c7831 | 96 | int32_t real; |
garyservin | 0:a906bb7c7831 | 97 | uint32_t base; |
garyservin | 0:a906bb7c7831 | 98 | } u_type; |
garyservin | 0:a906bb7c7831 | 99 | u_type.real = this->type; |
garyservin | 0:a906bb7c7831 | 100 | *(outbuffer + offset + 0) = (u_type.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 101 | *(outbuffer + offset + 1) = (u_type.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 102 | *(outbuffer + offset + 2) = (u_type.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 103 | *(outbuffer + offset + 3) = (u_type.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 104 | offset += sizeof(this->type); |
garyservin | 0:a906bb7c7831 | 105 | union { |
garyservin | 0:a906bb7c7831 | 106 | int32_t real; |
garyservin | 0:a906bb7c7831 | 107 | uint32_t base; |
garyservin | 0:a906bb7c7831 | 108 | } u_action; |
garyservin | 0:a906bb7c7831 | 109 | u_action.real = this->action; |
garyservin | 0:a906bb7c7831 | 110 | *(outbuffer + offset + 0) = (u_action.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 111 | *(outbuffer + offset + 1) = (u_action.base >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 112 | *(outbuffer + offset + 2) = (u_action.base >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 113 | *(outbuffer + offset + 3) = (u_action.base >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 114 | offset += sizeof(this->action); |
garyservin | 0:a906bb7c7831 | 115 | offset += this->pose.serialize(outbuffer + offset); |
garyservin | 0:a906bb7c7831 | 116 | offset += this->scale.serialize(outbuffer + offset); |
garyservin | 0:a906bb7c7831 | 117 | offset += this->color.serialize(outbuffer + offset); |
garyservin | 0:a906bb7c7831 | 118 | *(outbuffer + offset + 0) = (this->lifetime.sec >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 119 | *(outbuffer + offset + 1) = (this->lifetime.sec >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 120 | *(outbuffer + offset + 2) = (this->lifetime.sec >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 121 | *(outbuffer + offset + 3) = (this->lifetime.sec >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 122 | offset += sizeof(this->lifetime.sec); |
garyservin | 0:a906bb7c7831 | 123 | *(outbuffer + offset + 0) = (this->lifetime.nsec >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 124 | *(outbuffer + offset + 1) = (this->lifetime.nsec >> (8 * 1)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 125 | *(outbuffer + offset + 2) = (this->lifetime.nsec >> (8 * 2)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 126 | *(outbuffer + offset + 3) = (this->lifetime.nsec >> (8 * 3)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 127 | offset += sizeof(this->lifetime.nsec); |
garyservin | 0:a906bb7c7831 | 128 | union { |
garyservin | 0:a906bb7c7831 | 129 | bool real; |
garyservin | 0:a906bb7c7831 | 130 | uint8_t base; |
garyservin | 0:a906bb7c7831 | 131 | } u_frame_locked; |
garyservin | 0:a906bb7c7831 | 132 | u_frame_locked.real = this->frame_locked; |
garyservin | 0:a906bb7c7831 | 133 | *(outbuffer + offset + 0) = (u_frame_locked.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 134 | offset += sizeof(this->frame_locked); |
garyservin | 0:a906bb7c7831 | 135 | *(outbuffer + offset++) = points_length; |
garyservin | 0:a906bb7c7831 | 136 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 137 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 138 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 139 | for( uint8_t i = 0; i < points_length; i++){ |
garyservin | 0:a906bb7c7831 | 140 | offset += this->points[i].serialize(outbuffer + offset); |
garyservin | 0:a906bb7c7831 | 141 | } |
garyservin | 0:a906bb7c7831 | 142 | *(outbuffer + offset++) = colors_length; |
garyservin | 0:a906bb7c7831 | 143 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 144 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 145 | *(outbuffer + offset++) = 0; |
garyservin | 0:a906bb7c7831 | 146 | for( uint8_t i = 0; i < colors_length; i++){ |
garyservin | 0:a906bb7c7831 | 147 | offset += this->colors[i].serialize(outbuffer + offset); |
garyservin | 0:a906bb7c7831 | 148 | } |
garyservin | 0:a906bb7c7831 | 149 | uint32_t length_text = strlen(this->text); |
garyservin | 0:a906bb7c7831 | 150 | memcpy(outbuffer + offset, &length_text, sizeof(uint32_t)); |
garyservin | 0:a906bb7c7831 | 151 | offset += 4; |
garyservin | 0:a906bb7c7831 | 152 | memcpy(outbuffer + offset, this->text, length_text); |
garyservin | 0:a906bb7c7831 | 153 | offset += length_text; |
garyservin | 0:a906bb7c7831 | 154 | uint32_t length_mesh_resource = strlen(this->mesh_resource); |
garyservin | 0:a906bb7c7831 | 155 | memcpy(outbuffer + offset, &length_mesh_resource, sizeof(uint32_t)); |
garyservin | 0:a906bb7c7831 | 156 | offset += 4; |
garyservin | 0:a906bb7c7831 | 157 | memcpy(outbuffer + offset, this->mesh_resource, length_mesh_resource); |
garyservin | 0:a906bb7c7831 | 158 | offset += length_mesh_resource; |
garyservin | 0:a906bb7c7831 | 159 | union { |
garyservin | 0:a906bb7c7831 | 160 | bool real; |
garyservin | 0:a906bb7c7831 | 161 | uint8_t base; |
garyservin | 0:a906bb7c7831 | 162 | } u_mesh_use_embedded_materials; |
garyservin | 0:a906bb7c7831 | 163 | u_mesh_use_embedded_materials.real = this->mesh_use_embedded_materials; |
garyservin | 0:a906bb7c7831 | 164 | *(outbuffer + offset + 0) = (u_mesh_use_embedded_materials.base >> (8 * 0)) & 0xFF; |
garyservin | 0:a906bb7c7831 | 165 | offset += sizeof(this->mesh_use_embedded_materials); |
garyservin | 0:a906bb7c7831 | 166 | return offset; |
garyservin | 0:a906bb7c7831 | 167 | } |
garyservin | 0:a906bb7c7831 | 168 | |
garyservin | 0:a906bb7c7831 | 169 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:a906bb7c7831 | 170 | { |
garyservin | 0:a906bb7c7831 | 171 | int offset = 0; |
garyservin | 0:a906bb7c7831 | 172 | offset += this->header.deserialize(inbuffer + offset); |
garyservin | 0:a906bb7c7831 | 173 | uint32_t length_ns; |
garyservin | 0:a906bb7c7831 | 174 | memcpy(&length_ns, (inbuffer + offset), sizeof(uint32_t)); |
garyservin | 0:a906bb7c7831 | 175 | offset += 4; |
garyservin | 0:a906bb7c7831 | 176 | for(unsigned int k= offset; k< offset+length_ns; ++k){ |
garyservin | 0:a906bb7c7831 | 177 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:a906bb7c7831 | 178 | } |
garyservin | 0:a906bb7c7831 | 179 | inbuffer[offset+length_ns-1]=0; |
garyservin | 0:a906bb7c7831 | 180 | this->ns = (char *)(inbuffer + offset-1); |
garyservin | 0:a906bb7c7831 | 181 | offset += length_ns; |
garyservin | 0:a906bb7c7831 | 182 | union { |
garyservin | 0:a906bb7c7831 | 183 | int32_t real; |
garyservin | 0:a906bb7c7831 | 184 | uint32_t base; |
garyservin | 0:a906bb7c7831 | 185 | } u_id; |
garyservin | 0:a906bb7c7831 | 186 | u_id.base = 0; |
garyservin | 0:a906bb7c7831 | 187 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 188 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 189 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 190 | u_id.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 191 | this->id = u_id.real; |
garyservin | 0:a906bb7c7831 | 192 | offset += sizeof(this->id); |
garyservin | 0:a906bb7c7831 | 193 | union { |
garyservin | 0:a906bb7c7831 | 194 | int32_t real; |
garyservin | 0:a906bb7c7831 | 195 | uint32_t base; |
garyservin | 0:a906bb7c7831 | 196 | } u_type; |
garyservin | 0:a906bb7c7831 | 197 | u_type.base = 0; |
garyservin | 0:a906bb7c7831 | 198 | u_type.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 199 | u_type.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 200 | u_type.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 201 | u_type.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 202 | this->type = u_type.real; |
garyservin | 0:a906bb7c7831 | 203 | offset += sizeof(this->type); |
garyservin | 0:a906bb7c7831 | 204 | union { |
garyservin | 0:a906bb7c7831 | 205 | int32_t real; |
garyservin | 0:a906bb7c7831 | 206 | uint32_t base; |
garyservin | 0:a906bb7c7831 | 207 | } u_action; |
garyservin | 0:a906bb7c7831 | 208 | u_action.base = 0; |
garyservin | 0:a906bb7c7831 | 209 | u_action.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 210 | u_action.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 211 | u_action.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 212 | u_action.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 213 | this->action = u_action.real; |
garyservin | 0:a906bb7c7831 | 214 | offset += sizeof(this->action); |
garyservin | 0:a906bb7c7831 | 215 | offset += this->pose.deserialize(inbuffer + offset); |
garyservin | 0:a906bb7c7831 | 216 | offset += this->scale.deserialize(inbuffer + offset); |
garyservin | 0:a906bb7c7831 | 217 | offset += this->color.deserialize(inbuffer + offset); |
garyservin | 0:a906bb7c7831 | 218 | this->lifetime.sec = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:a906bb7c7831 | 219 | this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 220 | this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 221 | this->lifetime.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 222 | offset += sizeof(this->lifetime.sec); |
garyservin | 0:a906bb7c7831 | 223 | this->lifetime.nsec = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:a906bb7c7831 | 224 | this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:a906bb7c7831 | 225 | this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:a906bb7c7831 | 226 | this->lifetime.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:a906bb7c7831 | 227 | offset += sizeof(this->lifetime.nsec); |
garyservin | 0:a906bb7c7831 | 228 | union { |
garyservin | 0:a906bb7c7831 | 229 | bool real; |
garyservin | 0:a906bb7c7831 | 230 | uint8_t base; |
garyservin | 0:a906bb7c7831 | 231 | } u_frame_locked; |
garyservin | 0:a906bb7c7831 | 232 | u_frame_locked.base = 0; |
garyservin | 0:a906bb7c7831 | 233 | u_frame_locked.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 234 | this->frame_locked = u_frame_locked.real; |
garyservin | 0:a906bb7c7831 | 235 | offset += sizeof(this->frame_locked); |
garyservin | 0:a906bb7c7831 | 236 | uint8_t points_lengthT = *(inbuffer + offset++); |
garyservin | 0:a906bb7c7831 | 237 | if(points_lengthT > points_length) |
garyservin | 0:a906bb7c7831 | 238 | this->points = (geometry_msgs::Point*)realloc(this->points, points_lengthT * sizeof(geometry_msgs::Point)); |
garyservin | 0:a906bb7c7831 | 239 | offset += 3; |
garyservin | 0:a906bb7c7831 | 240 | points_length = points_lengthT; |
garyservin | 0:a906bb7c7831 | 241 | for( uint8_t i = 0; i < points_length; i++){ |
garyservin | 0:a906bb7c7831 | 242 | offset += this->st_points.deserialize(inbuffer + offset); |
garyservin | 0:a906bb7c7831 | 243 | memcpy( &(this->points[i]), &(this->st_points), sizeof(geometry_msgs::Point)); |
garyservin | 0:a906bb7c7831 | 244 | } |
garyservin | 0:a906bb7c7831 | 245 | uint8_t colors_lengthT = *(inbuffer + offset++); |
garyservin | 0:a906bb7c7831 | 246 | if(colors_lengthT > colors_length) |
garyservin | 0:a906bb7c7831 | 247 | this->colors = (std_msgs::ColorRGBA*)realloc(this->colors, colors_lengthT * sizeof(std_msgs::ColorRGBA)); |
garyservin | 0:a906bb7c7831 | 248 | offset += 3; |
garyservin | 0:a906bb7c7831 | 249 | colors_length = colors_lengthT; |
garyservin | 0:a906bb7c7831 | 250 | for( uint8_t i = 0; i < colors_length; i++){ |
garyservin | 0:a906bb7c7831 | 251 | offset += this->st_colors.deserialize(inbuffer + offset); |
garyservin | 0:a906bb7c7831 | 252 | memcpy( &(this->colors[i]), &(this->st_colors), sizeof(std_msgs::ColorRGBA)); |
garyservin | 0:a906bb7c7831 | 253 | } |
garyservin | 0:a906bb7c7831 | 254 | uint32_t length_text; |
garyservin | 0:a906bb7c7831 | 255 | memcpy(&length_text, (inbuffer + offset), sizeof(uint32_t)); |
garyservin | 0:a906bb7c7831 | 256 | offset += 4; |
garyservin | 0:a906bb7c7831 | 257 | for(unsigned int k= offset; k< offset+length_text; ++k){ |
garyservin | 0:a906bb7c7831 | 258 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:a906bb7c7831 | 259 | } |
garyservin | 0:a906bb7c7831 | 260 | inbuffer[offset+length_text-1]=0; |
garyservin | 0:a906bb7c7831 | 261 | this->text = (char *)(inbuffer + offset-1); |
garyservin | 0:a906bb7c7831 | 262 | offset += length_text; |
garyservin | 0:a906bb7c7831 | 263 | uint32_t length_mesh_resource; |
garyservin | 0:a906bb7c7831 | 264 | memcpy(&length_mesh_resource, (inbuffer + offset), sizeof(uint32_t)); |
garyservin | 0:a906bb7c7831 | 265 | offset += 4; |
garyservin | 0:a906bb7c7831 | 266 | for(unsigned int k= offset; k< offset+length_mesh_resource; ++k){ |
garyservin | 0:a906bb7c7831 | 267 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:a906bb7c7831 | 268 | } |
garyservin | 0:a906bb7c7831 | 269 | inbuffer[offset+length_mesh_resource-1]=0; |
garyservin | 0:a906bb7c7831 | 270 | this->mesh_resource = (char *)(inbuffer + offset-1); |
garyservin | 0:a906bb7c7831 | 271 | offset += length_mesh_resource; |
garyservin | 0:a906bb7c7831 | 272 | union { |
garyservin | 0:a906bb7c7831 | 273 | bool real; |
garyservin | 0:a906bb7c7831 | 274 | uint8_t base; |
garyservin | 0:a906bb7c7831 | 275 | } u_mesh_use_embedded_materials; |
garyservin | 0:a906bb7c7831 | 276 | u_mesh_use_embedded_materials.base = 0; |
garyservin | 0:a906bb7c7831 | 277 | u_mesh_use_embedded_materials.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:a906bb7c7831 | 278 | this->mesh_use_embedded_materials = u_mesh_use_embedded_materials.real; |
garyservin | 0:a906bb7c7831 | 279 | offset += sizeof(this->mesh_use_embedded_materials); |
garyservin | 0:a906bb7c7831 | 280 | return offset; |
garyservin | 0:a906bb7c7831 | 281 | } |
garyservin | 0:a906bb7c7831 | 282 | |
garyservin | 0:a906bb7c7831 | 283 | const char * getType(){ return "visualization_msgs/Marker"; }; |
garyservin | 0:a906bb7c7831 | 284 | const char * getMD5(){ return "4048c9de2a16f4ae8e0538085ebf1b97"; }; |
garyservin | 0:a906bb7c7831 | 285 | |
garyservin | 0:a906bb7c7831 | 286 | }; |
garyservin | 0:a906bb7c7831 | 287 | |
garyservin | 0:a906bb7c7831 | 288 | } |
garyservin | 0:a906bb7c7831 | 289 | #endif |