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

Dependencies:   BufferedSerial

Dependents:   rosserial_mbed_hello_world_publisher_melodic Motortest Nucleo_vr_servo_project NucleoFM ... more

ROSSerial_mbed for Melodic 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_melodic

rosserial_mbed Hello World example for Melodic Morenia 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();
    }
}
Committer:
Gary Servin
Date:
Fri Nov 08 14:38:09 2019 -0300
Revision:
0:04ac6be8229a
Initial commit, generated based on a clean melodic-desktop-full

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gary Servin 0:04ac6be8229a 1 #ifndef _ROS_rosgraph_msgs_TopicStatistics_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_rosgraph_msgs_TopicStatistics_h
Gary Servin 0:04ac6be8229a 3
Gary Servin 0:04ac6be8229a 4 #include <stdint.h>
Gary Servin 0:04ac6be8229a 5 #include <string.h>
Gary Servin 0:04ac6be8229a 6 #include <stdlib.h>
Gary Servin 0:04ac6be8229a 7 #include "ros/msg.h"
Gary Servin 0:04ac6be8229a 8 #include "ros/time.h"
Gary Servin 0:04ac6be8229a 9 #include "ros/duration.h"
Gary Servin 0:04ac6be8229a 10
Gary Servin 0:04ac6be8229a 11 namespace rosgraph_msgs
Gary Servin 0:04ac6be8229a 12 {
Gary Servin 0:04ac6be8229a 13
Gary Servin 0:04ac6be8229a 14 class TopicStatistics : public ros::Msg
Gary Servin 0:04ac6be8229a 15 {
Gary Servin 0:04ac6be8229a 16 public:
Gary Servin 0:04ac6be8229a 17 typedef const char* _topic_type;
Gary Servin 0:04ac6be8229a 18 _topic_type topic;
Gary Servin 0:04ac6be8229a 19 typedef const char* _node_pub_type;
Gary Servin 0:04ac6be8229a 20 _node_pub_type node_pub;
Gary Servin 0:04ac6be8229a 21 typedef const char* _node_sub_type;
Gary Servin 0:04ac6be8229a 22 _node_sub_type node_sub;
Gary Servin 0:04ac6be8229a 23 typedef ros::Time _window_start_type;
Gary Servin 0:04ac6be8229a 24 _window_start_type window_start;
Gary Servin 0:04ac6be8229a 25 typedef ros::Time _window_stop_type;
Gary Servin 0:04ac6be8229a 26 _window_stop_type window_stop;
Gary Servin 0:04ac6be8229a 27 typedef int32_t _delivered_msgs_type;
Gary Servin 0:04ac6be8229a 28 _delivered_msgs_type delivered_msgs;
Gary Servin 0:04ac6be8229a 29 typedef int32_t _dropped_msgs_type;
Gary Servin 0:04ac6be8229a 30 _dropped_msgs_type dropped_msgs;
Gary Servin 0:04ac6be8229a 31 typedef int32_t _traffic_type;
Gary Servin 0:04ac6be8229a 32 _traffic_type traffic;
Gary Servin 0:04ac6be8229a 33 typedef ros::Duration _period_mean_type;
Gary Servin 0:04ac6be8229a 34 _period_mean_type period_mean;
Gary Servin 0:04ac6be8229a 35 typedef ros::Duration _period_stddev_type;
Gary Servin 0:04ac6be8229a 36 _period_stddev_type period_stddev;
Gary Servin 0:04ac6be8229a 37 typedef ros::Duration _period_max_type;
Gary Servin 0:04ac6be8229a 38 _period_max_type period_max;
Gary Servin 0:04ac6be8229a 39 typedef ros::Duration _stamp_age_mean_type;
Gary Servin 0:04ac6be8229a 40 _stamp_age_mean_type stamp_age_mean;
Gary Servin 0:04ac6be8229a 41 typedef ros::Duration _stamp_age_stddev_type;
Gary Servin 0:04ac6be8229a 42 _stamp_age_stddev_type stamp_age_stddev;
Gary Servin 0:04ac6be8229a 43 typedef ros::Duration _stamp_age_max_type;
Gary Servin 0:04ac6be8229a 44 _stamp_age_max_type stamp_age_max;
Gary Servin 0:04ac6be8229a 45
Gary Servin 0:04ac6be8229a 46 TopicStatistics():
Gary Servin 0:04ac6be8229a 47 topic(""),
Gary Servin 0:04ac6be8229a 48 node_pub(""),
Gary Servin 0:04ac6be8229a 49 node_sub(""),
Gary Servin 0:04ac6be8229a 50 window_start(),
Gary Servin 0:04ac6be8229a 51 window_stop(),
Gary Servin 0:04ac6be8229a 52 delivered_msgs(0),
Gary Servin 0:04ac6be8229a 53 dropped_msgs(0),
Gary Servin 0:04ac6be8229a 54 traffic(0),
Gary Servin 0:04ac6be8229a 55 period_mean(),
Gary Servin 0:04ac6be8229a 56 period_stddev(),
Gary Servin 0:04ac6be8229a 57 period_max(),
Gary Servin 0:04ac6be8229a 58 stamp_age_mean(),
Gary Servin 0:04ac6be8229a 59 stamp_age_stddev(),
Gary Servin 0:04ac6be8229a 60 stamp_age_max()
Gary Servin 0:04ac6be8229a 61 {
Gary Servin 0:04ac6be8229a 62 }
Gary Servin 0:04ac6be8229a 63
Gary Servin 0:04ac6be8229a 64 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 65 {
Gary Servin 0:04ac6be8229a 66 int offset = 0;
Gary Servin 0:04ac6be8229a 67 uint32_t length_topic = strlen(this->topic);
Gary Servin 0:04ac6be8229a 68 varToArr(outbuffer + offset, length_topic);
Gary Servin 0:04ac6be8229a 69 offset += 4;
Gary Servin 0:04ac6be8229a 70 memcpy(outbuffer + offset, this->topic, length_topic);
Gary Servin 0:04ac6be8229a 71 offset += length_topic;
Gary Servin 0:04ac6be8229a 72 uint32_t length_node_pub = strlen(this->node_pub);
Gary Servin 0:04ac6be8229a 73 varToArr(outbuffer + offset, length_node_pub);
Gary Servin 0:04ac6be8229a 74 offset += 4;
Gary Servin 0:04ac6be8229a 75 memcpy(outbuffer + offset, this->node_pub, length_node_pub);
Gary Servin 0:04ac6be8229a 76 offset += length_node_pub;
Gary Servin 0:04ac6be8229a 77 uint32_t length_node_sub = strlen(this->node_sub);
Gary Servin 0:04ac6be8229a 78 varToArr(outbuffer + offset, length_node_sub);
Gary Servin 0:04ac6be8229a 79 offset += 4;
Gary Servin 0:04ac6be8229a 80 memcpy(outbuffer + offset, this->node_sub, length_node_sub);
Gary Servin 0:04ac6be8229a 81 offset += length_node_sub;
Gary Servin 0:04ac6be8229a 82 *(outbuffer + offset + 0) = (this->window_start.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 83 *(outbuffer + offset + 1) = (this->window_start.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 84 *(outbuffer + offset + 2) = (this->window_start.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 85 *(outbuffer + offset + 3) = (this->window_start.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 86 offset += sizeof(this->window_start.sec);
Gary Servin 0:04ac6be8229a 87 *(outbuffer + offset + 0) = (this->window_start.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 88 *(outbuffer + offset + 1) = (this->window_start.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 89 *(outbuffer + offset + 2) = (this->window_start.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 90 *(outbuffer + offset + 3) = (this->window_start.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 91 offset += sizeof(this->window_start.nsec);
Gary Servin 0:04ac6be8229a 92 *(outbuffer + offset + 0) = (this->window_stop.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 93 *(outbuffer + offset + 1) = (this->window_stop.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 94 *(outbuffer + offset + 2) = (this->window_stop.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 95 *(outbuffer + offset + 3) = (this->window_stop.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 96 offset += sizeof(this->window_stop.sec);
Gary Servin 0:04ac6be8229a 97 *(outbuffer + offset + 0) = (this->window_stop.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 98 *(outbuffer + offset + 1) = (this->window_stop.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 99 *(outbuffer + offset + 2) = (this->window_stop.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 100 *(outbuffer + offset + 3) = (this->window_stop.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 101 offset += sizeof(this->window_stop.nsec);
Gary Servin 0:04ac6be8229a 102 union {
Gary Servin 0:04ac6be8229a 103 int32_t real;
Gary Servin 0:04ac6be8229a 104 uint32_t base;
Gary Servin 0:04ac6be8229a 105 } u_delivered_msgs;
Gary Servin 0:04ac6be8229a 106 u_delivered_msgs.real = this->delivered_msgs;
Gary Servin 0:04ac6be8229a 107 *(outbuffer + offset + 0) = (u_delivered_msgs.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 108 *(outbuffer + offset + 1) = (u_delivered_msgs.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 109 *(outbuffer + offset + 2) = (u_delivered_msgs.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 110 *(outbuffer + offset + 3) = (u_delivered_msgs.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 111 offset += sizeof(this->delivered_msgs);
Gary Servin 0:04ac6be8229a 112 union {
Gary Servin 0:04ac6be8229a 113 int32_t real;
Gary Servin 0:04ac6be8229a 114 uint32_t base;
Gary Servin 0:04ac6be8229a 115 } u_dropped_msgs;
Gary Servin 0:04ac6be8229a 116 u_dropped_msgs.real = this->dropped_msgs;
Gary Servin 0:04ac6be8229a 117 *(outbuffer + offset + 0) = (u_dropped_msgs.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 118 *(outbuffer + offset + 1) = (u_dropped_msgs.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 119 *(outbuffer + offset + 2) = (u_dropped_msgs.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 120 *(outbuffer + offset + 3) = (u_dropped_msgs.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 121 offset += sizeof(this->dropped_msgs);
Gary Servin 0:04ac6be8229a 122 union {
Gary Servin 0:04ac6be8229a 123 int32_t real;
Gary Servin 0:04ac6be8229a 124 uint32_t base;
Gary Servin 0:04ac6be8229a 125 } u_traffic;
Gary Servin 0:04ac6be8229a 126 u_traffic.real = this->traffic;
Gary Servin 0:04ac6be8229a 127 *(outbuffer + offset + 0) = (u_traffic.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 128 *(outbuffer + offset + 1) = (u_traffic.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 129 *(outbuffer + offset + 2) = (u_traffic.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 130 *(outbuffer + offset + 3) = (u_traffic.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 131 offset += sizeof(this->traffic);
Gary Servin 0:04ac6be8229a 132 *(outbuffer + offset + 0) = (this->period_mean.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 133 *(outbuffer + offset + 1) = (this->period_mean.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 134 *(outbuffer + offset + 2) = (this->period_mean.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 135 *(outbuffer + offset + 3) = (this->period_mean.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 136 offset += sizeof(this->period_mean.sec);
Gary Servin 0:04ac6be8229a 137 *(outbuffer + offset + 0) = (this->period_mean.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 138 *(outbuffer + offset + 1) = (this->period_mean.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 139 *(outbuffer + offset + 2) = (this->period_mean.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 140 *(outbuffer + offset + 3) = (this->period_mean.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 141 offset += sizeof(this->period_mean.nsec);
Gary Servin 0:04ac6be8229a 142 *(outbuffer + offset + 0) = (this->period_stddev.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 143 *(outbuffer + offset + 1) = (this->period_stddev.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 144 *(outbuffer + offset + 2) = (this->period_stddev.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 145 *(outbuffer + offset + 3) = (this->period_stddev.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 146 offset += sizeof(this->period_stddev.sec);
Gary Servin 0:04ac6be8229a 147 *(outbuffer + offset + 0) = (this->period_stddev.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 148 *(outbuffer + offset + 1) = (this->period_stddev.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 149 *(outbuffer + offset + 2) = (this->period_stddev.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 150 *(outbuffer + offset + 3) = (this->period_stddev.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 151 offset += sizeof(this->period_stddev.nsec);
Gary Servin 0:04ac6be8229a 152 *(outbuffer + offset + 0) = (this->period_max.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 153 *(outbuffer + offset + 1) = (this->period_max.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 154 *(outbuffer + offset + 2) = (this->period_max.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 155 *(outbuffer + offset + 3) = (this->period_max.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 156 offset += sizeof(this->period_max.sec);
Gary Servin 0:04ac6be8229a 157 *(outbuffer + offset + 0) = (this->period_max.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 158 *(outbuffer + offset + 1) = (this->period_max.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 159 *(outbuffer + offset + 2) = (this->period_max.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 160 *(outbuffer + offset + 3) = (this->period_max.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 161 offset += sizeof(this->period_max.nsec);
Gary Servin 0:04ac6be8229a 162 *(outbuffer + offset + 0) = (this->stamp_age_mean.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 163 *(outbuffer + offset + 1) = (this->stamp_age_mean.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 164 *(outbuffer + offset + 2) = (this->stamp_age_mean.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 165 *(outbuffer + offset + 3) = (this->stamp_age_mean.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 166 offset += sizeof(this->stamp_age_mean.sec);
Gary Servin 0:04ac6be8229a 167 *(outbuffer + offset + 0) = (this->stamp_age_mean.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 168 *(outbuffer + offset + 1) = (this->stamp_age_mean.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 169 *(outbuffer + offset + 2) = (this->stamp_age_mean.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 170 *(outbuffer + offset + 3) = (this->stamp_age_mean.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 171 offset += sizeof(this->stamp_age_mean.nsec);
Gary Servin 0:04ac6be8229a 172 *(outbuffer + offset + 0) = (this->stamp_age_stddev.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 173 *(outbuffer + offset + 1) = (this->stamp_age_stddev.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 174 *(outbuffer + offset + 2) = (this->stamp_age_stddev.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 175 *(outbuffer + offset + 3) = (this->stamp_age_stddev.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 176 offset += sizeof(this->stamp_age_stddev.sec);
Gary Servin 0:04ac6be8229a 177 *(outbuffer + offset + 0) = (this->stamp_age_stddev.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 178 *(outbuffer + offset + 1) = (this->stamp_age_stddev.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 179 *(outbuffer + offset + 2) = (this->stamp_age_stddev.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 180 *(outbuffer + offset + 3) = (this->stamp_age_stddev.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 181 offset += sizeof(this->stamp_age_stddev.nsec);
Gary Servin 0:04ac6be8229a 182 *(outbuffer + offset + 0) = (this->stamp_age_max.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 183 *(outbuffer + offset + 1) = (this->stamp_age_max.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 184 *(outbuffer + offset + 2) = (this->stamp_age_max.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 185 *(outbuffer + offset + 3) = (this->stamp_age_max.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 186 offset += sizeof(this->stamp_age_max.sec);
Gary Servin 0:04ac6be8229a 187 *(outbuffer + offset + 0) = (this->stamp_age_max.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 188 *(outbuffer + offset + 1) = (this->stamp_age_max.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 189 *(outbuffer + offset + 2) = (this->stamp_age_max.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 190 *(outbuffer + offset + 3) = (this->stamp_age_max.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 191 offset += sizeof(this->stamp_age_max.nsec);
Gary Servin 0:04ac6be8229a 192 return offset;
Gary Servin 0:04ac6be8229a 193 }
Gary Servin 0:04ac6be8229a 194
Gary Servin 0:04ac6be8229a 195 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 196 {
Gary Servin 0:04ac6be8229a 197 int offset = 0;
Gary Servin 0:04ac6be8229a 198 uint32_t length_topic;
Gary Servin 0:04ac6be8229a 199 arrToVar(length_topic, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 200 offset += 4;
Gary Servin 0:04ac6be8229a 201 for(unsigned int k= offset; k< offset+length_topic; ++k){
Gary Servin 0:04ac6be8229a 202 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 203 }
Gary Servin 0:04ac6be8229a 204 inbuffer[offset+length_topic-1]=0;
Gary Servin 0:04ac6be8229a 205 this->topic = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 206 offset += length_topic;
Gary Servin 0:04ac6be8229a 207 uint32_t length_node_pub;
Gary Servin 0:04ac6be8229a 208 arrToVar(length_node_pub, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 209 offset += 4;
Gary Servin 0:04ac6be8229a 210 for(unsigned int k= offset; k< offset+length_node_pub; ++k){
Gary Servin 0:04ac6be8229a 211 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 212 }
Gary Servin 0:04ac6be8229a 213 inbuffer[offset+length_node_pub-1]=0;
Gary Servin 0:04ac6be8229a 214 this->node_pub = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 215 offset += length_node_pub;
Gary Servin 0:04ac6be8229a 216 uint32_t length_node_sub;
Gary Servin 0:04ac6be8229a 217 arrToVar(length_node_sub, (inbuffer + offset));
Gary Servin 0:04ac6be8229a 218 offset += 4;
Gary Servin 0:04ac6be8229a 219 for(unsigned int k= offset; k< offset+length_node_sub; ++k){
Gary Servin 0:04ac6be8229a 220 inbuffer[k-1]=inbuffer[k];
Gary Servin 0:04ac6be8229a 221 }
Gary Servin 0:04ac6be8229a 222 inbuffer[offset+length_node_sub-1]=0;
Gary Servin 0:04ac6be8229a 223 this->node_sub = (char *)(inbuffer + offset-1);
Gary Servin 0:04ac6be8229a 224 offset += length_node_sub;
Gary Servin 0:04ac6be8229a 225 this->window_start.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 226 this->window_start.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 227 this->window_start.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 228 this->window_start.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 229 offset += sizeof(this->window_start.sec);
Gary Servin 0:04ac6be8229a 230 this->window_start.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 231 this->window_start.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 232 this->window_start.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 233 this->window_start.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 234 offset += sizeof(this->window_start.nsec);
Gary Servin 0:04ac6be8229a 235 this->window_stop.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 236 this->window_stop.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 237 this->window_stop.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 238 this->window_stop.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 239 offset += sizeof(this->window_stop.sec);
Gary Servin 0:04ac6be8229a 240 this->window_stop.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 241 this->window_stop.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 242 this->window_stop.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 243 this->window_stop.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 244 offset += sizeof(this->window_stop.nsec);
Gary Servin 0:04ac6be8229a 245 union {
Gary Servin 0:04ac6be8229a 246 int32_t real;
Gary Servin 0:04ac6be8229a 247 uint32_t base;
Gary Servin 0:04ac6be8229a 248 } u_delivered_msgs;
Gary Servin 0:04ac6be8229a 249 u_delivered_msgs.base = 0;
Gary Servin 0:04ac6be8229a 250 u_delivered_msgs.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 251 u_delivered_msgs.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 252 u_delivered_msgs.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 253 u_delivered_msgs.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 254 this->delivered_msgs = u_delivered_msgs.real;
Gary Servin 0:04ac6be8229a 255 offset += sizeof(this->delivered_msgs);
Gary Servin 0:04ac6be8229a 256 union {
Gary Servin 0:04ac6be8229a 257 int32_t real;
Gary Servin 0:04ac6be8229a 258 uint32_t base;
Gary Servin 0:04ac6be8229a 259 } u_dropped_msgs;
Gary Servin 0:04ac6be8229a 260 u_dropped_msgs.base = 0;
Gary Servin 0:04ac6be8229a 261 u_dropped_msgs.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 262 u_dropped_msgs.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 263 u_dropped_msgs.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 264 u_dropped_msgs.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 265 this->dropped_msgs = u_dropped_msgs.real;
Gary Servin 0:04ac6be8229a 266 offset += sizeof(this->dropped_msgs);
Gary Servin 0:04ac6be8229a 267 union {
Gary Servin 0:04ac6be8229a 268 int32_t real;
Gary Servin 0:04ac6be8229a 269 uint32_t base;
Gary Servin 0:04ac6be8229a 270 } u_traffic;
Gary Servin 0:04ac6be8229a 271 u_traffic.base = 0;
Gary Servin 0:04ac6be8229a 272 u_traffic.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 273 u_traffic.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 274 u_traffic.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 275 u_traffic.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 276 this->traffic = u_traffic.real;
Gary Servin 0:04ac6be8229a 277 offset += sizeof(this->traffic);
Gary Servin 0:04ac6be8229a 278 this->period_mean.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 279 this->period_mean.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 280 this->period_mean.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 281 this->period_mean.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 282 offset += sizeof(this->period_mean.sec);
Gary Servin 0:04ac6be8229a 283 this->period_mean.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 284 this->period_mean.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 285 this->period_mean.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 286 this->period_mean.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 287 offset += sizeof(this->period_mean.nsec);
Gary Servin 0:04ac6be8229a 288 this->period_stddev.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 289 this->period_stddev.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 290 this->period_stddev.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 291 this->period_stddev.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 292 offset += sizeof(this->period_stddev.sec);
Gary Servin 0:04ac6be8229a 293 this->period_stddev.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 294 this->period_stddev.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 295 this->period_stddev.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 296 this->period_stddev.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 297 offset += sizeof(this->period_stddev.nsec);
Gary Servin 0:04ac6be8229a 298 this->period_max.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 299 this->period_max.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 300 this->period_max.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 301 this->period_max.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 302 offset += sizeof(this->period_max.sec);
Gary Servin 0:04ac6be8229a 303 this->period_max.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 304 this->period_max.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 305 this->period_max.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 306 this->period_max.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 307 offset += sizeof(this->period_max.nsec);
Gary Servin 0:04ac6be8229a 308 this->stamp_age_mean.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 309 this->stamp_age_mean.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 310 this->stamp_age_mean.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 311 this->stamp_age_mean.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 312 offset += sizeof(this->stamp_age_mean.sec);
Gary Servin 0:04ac6be8229a 313 this->stamp_age_mean.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 314 this->stamp_age_mean.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 315 this->stamp_age_mean.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 316 this->stamp_age_mean.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 317 offset += sizeof(this->stamp_age_mean.nsec);
Gary Servin 0:04ac6be8229a 318 this->stamp_age_stddev.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 319 this->stamp_age_stddev.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 320 this->stamp_age_stddev.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 321 this->stamp_age_stddev.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 322 offset += sizeof(this->stamp_age_stddev.sec);
Gary Servin 0:04ac6be8229a 323 this->stamp_age_stddev.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 324 this->stamp_age_stddev.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 325 this->stamp_age_stddev.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 326 this->stamp_age_stddev.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 327 offset += sizeof(this->stamp_age_stddev.nsec);
Gary Servin 0:04ac6be8229a 328 this->stamp_age_max.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 329 this->stamp_age_max.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 330 this->stamp_age_max.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 331 this->stamp_age_max.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 332 offset += sizeof(this->stamp_age_max.sec);
Gary Servin 0:04ac6be8229a 333 this->stamp_age_max.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 334 this->stamp_age_max.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 335 this->stamp_age_max.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 336 this->stamp_age_max.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 337 offset += sizeof(this->stamp_age_max.nsec);
Gary Servin 0:04ac6be8229a 338 return offset;
Gary Servin 0:04ac6be8229a 339 }
Gary Servin 0:04ac6be8229a 340
Gary Servin 0:04ac6be8229a 341 const char * getType(){ return "rosgraph_msgs/TopicStatistics"; };
Gary Servin 0:04ac6be8229a 342 const char * getMD5(){ return "10152ed868c5097a5e2e4a89d7daa710"; };
Gary Servin 0:04ac6be8229a 343
Gary Servin 0:04ac6be8229a 344 };
Gary Servin 0:04ac6be8229a 345
Gary Servin 0:04ac6be8229a 346 }
Gary Servin 0:04ac6be8229a 347 #endif