ROS Serial library for Mbed platforms for ROS Indigo Igloo. Check http://wiki.ros.org/rosserial_mbed/ for more information

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher rtos_base_control rosserial_mbed_F64MA ROS-RTOS ... more

ROSSerial_mbed for Indigo 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

rosserial_mbed Hello World

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();
    }
}
Committer:
garyservin
Date:
Thu Mar 31 14:22:59 2016 +0000
Revision:
0:fd24f7ca9688
Initial commit, generated based on a clean indigo-desktop-full

Who changed what in which revision?

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