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:55:04 2019 -0300
Revision:
1:da82487f547e
Parent:
0:04ac6be8229a
Add missing round() method

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gary Servin 0:04ac6be8229a 1 #ifndef _ROS_control_msgs_PidState_h
Gary Servin 0:04ac6be8229a 2 #define _ROS_control_msgs_PidState_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 "std_msgs/Header.h"
Gary Servin 0:04ac6be8229a 9 #include "ros/duration.h"
Gary Servin 0:04ac6be8229a 10
Gary Servin 0:04ac6be8229a 11 namespace control_msgs
Gary Servin 0:04ac6be8229a 12 {
Gary Servin 0:04ac6be8229a 13
Gary Servin 0:04ac6be8229a 14 class PidState : public ros::Msg
Gary Servin 0:04ac6be8229a 15 {
Gary Servin 0:04ac6be8229a 16 public:
Gary Servin 0:04ac6be8229a 17 typedef std_msgs::Header _header_type;
Gary Servin 0:04ac6be8229a 18 _header_type header;
Gary Servin 0:04ac6be8229a 19 typedef ros::Duration _timestep_type;
Gary Servin 0:04ac6be8229a 20 _timestep_type timestep;
Gary Servin 0:04ac6be8229a 21 typedef double _error_type;
Gary Servin 0:04ac6be8229a 22 _error_type error;
Gary Servin 0:04ac6be8229a 23 typedef double _error_dot_type;
Gary Servin 0:04ac6be8229a 24 _error_dot_type error_dot;
Gary Servin 0:04ac6be8229a 25 typedef double _p_error_type;
Gary Servin 0:04ac6be8229a 26 _p_error_type p_error;
Gary Servin 0:04ac6be8229a 27 typedef double _i_error_type;
Gary Servin 0:04ac6be8229a 28 _i_error_type i_error;
Gary Servin 0:04ac6be8229a 29 typedef double _d_error_type;
Gary Servin 0:04ac6be8229a 30 _d_error_type d_error;
Gary Servin 0:04ac6be8229a 31 typedef double _p_term_type;
Gary Servin 0:04ac6be8229a 32 _p_term_type p_term;
Gary Servin 0:04ac6be8229a 33 typedef double _i_term_type;
Gary Servin 0:04ac6be8229a 34 _i_term_type i_term;
Gary Servin 0:04ac6be8229a 35 typedef double _d_term_type;
Gary Servin 0:04ac6be8229a 36 _d_term_type d_term;
Gary Servin 0:04ac6be8229a 37 typedef double _i_max_type;
Gary Servin 0:04ac6be8229a 38 _i_max_type i_max;
Gary Servin 0:04ac6be8229a 39 typedef double _i_min_type;
Gary Servin 0:04ac6be8229a 40 _i_min_type i_min;
Gary Servin 0:04ac6be8229a 41 typedef double _output_type;
Gary Servin 0:04ac6be8229a 42 _output_type output;
Gary Servin 0:04ac6be8229a 43
Gary Servin 0:04ac6be8229a 44 PidState():
Gary Servin 0:04ac6be8229a 45 header(),
Gary Servin 0:04ac6be8229a 46 timestep(),
Gary Servin 0:04ac6be8229a 47 error(0),
Gary Servin 0:04ac6be8229a 48 error_dot(0),
Gary Servin 0:04ac6be8229a 49 p_error(0),
Gary Servin 0:04ac6be8229a 50 i_error(0),
Gary Servin 0:04ac6be8229a 51 d_error(0),
Gary Servin 0:04ac6be8229a 52 p_term(0),
Gary Servin 0:04ac6be8229a 53 i_term(0),
Gary Servin 0:04ac6be8229a 54 d_term(0),
Gary Servin 0:04ac6be8229a 55 i_max(0),
Gary Servin 0:04ac6be8229a 56 i_min(0),
Gary Servin 0:04ac6be8229a 57 output(0)
Gary Servin 0:04ac6be8229a 58 {
Gary Servin 0:04ac6be8229a 59 }
Gary Servin 0:04ac6be8229a 60
Gary Servin 0:04ac6be8229a 61 virtual int serialize(unsigned char *outbuffer) const
Gary Servin 0:04ac6be8229a 62 {
Gary Servin 0:04ac6be8229a 63 int offset = 0;
Gary Servin 0:04ac6be8229a 64 offset += this->header.serialize(outbuffer + offset);
Gary Servin 0:04ac6be8229a 65 *(outbuffer + offset + 0) = (this->timestep.sec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 66 *(outbuffer + offset + 1) = (this->timestep.sec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 67 *(outbuffer + offset + 2) = (this->timestep.sec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 68 *(outbuffer + offset + 3) = (this->timestep.sec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 69 offset += sizeof(this->timestep.sec);
Gary Servin 0:04ac6be8229a 70 *(outbuffer + offset + 0) = (this->timestep.nsec >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 71 *(outbuffer + offset + 1) = (this->timestep.nsec >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 72 *(outbuffer + offset + 2) = (this->timestep.nsec >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 73 *(outbuffer + offset + 3) = (this->timestep.nsec >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 74 offset += sizeof(this->timestep.nsec);
Gary Servin 0:04ac6be8229a 75 union {
Gary Servin 0:04ac6be8229a 76 double real;
Gary Servin 0:04ac6be8229a 77 uint64_t base;
Gary Servin 0:04ac6be8229a 78 } u_error;
Gary Servin 0:04ac6be8229a 79 u_error.real = this->error;
Gary Servin 0:04ac6be8229a 80 *(outbuffer + offset + 0) = (u_error.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 81 *(outbuffer + offset + 1) = (u_error.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 82 *(outbuffer + offset + 2) = (u_error.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 83 *(outbuffer + offset + 3) = (u_error.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 84 *(outbuffer + offset + 4) = (u_error.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 85 *(outbuffer + offset + 5) = (u_error.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 86 *(outbuffer + offset + 6) = (u_error.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 87 *(outbuffer + offset + 7) = (u_error.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 88 offset += sizeof(this->error);
Gary Servin 0:04ac6be8229a 89 union {
Gary Servin 0:04ac6be8229a 90 double real;
Gary Servin 0:04ac6be8229a 91 uint64_t base;
Gary Servin 0:04ac6be8229a 92 } u_error_dot;
Gary Servin 0:04ac6be8229a 93 u_error_dot.real = this->error_dot;
Gary Servin 0:04ac6be8229a 94 *(outbuffer + offset + 0) = (u_error_dot.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 95 *(outbuffer + offset + 1) = (u_error_dot.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 96 *(outbuffer + offset + 2) = (u_error_dot.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 97 *(outbuffer + offset + 3) = (u_error_dot.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 98 *(outbuffer + offset + 4) = (u_error_dot.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 99 *(outbuffer + offset + 5) = (u_error_dot.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 100 *(outbuffer + offset + 6) = (u_error_dot.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 101 *(outbuffer + offset + 7) = (u_error_dot.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 102 offset += sizeof(this->error_dot);
Gary Servin 0:04ac6be8229a 103 union {
Gary Servin 0:04ac6be8229a 104 double real;
Gary Servin 0:04ac6be8229a 105 uint64_t base;
Gary Servin 0:04ac6be8229a 106 } u_p_error;
Gary Servin 0:04ac6be8229a 107 u_p_error.real = this->p_error;
Gary Servin 0:04ac6be8229a 108 *(outbuffer + offset + 0) = (u_p_error.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 109 *(outbuffer + offset + 1) = (u_p_error.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 110 *(outbuffer + offset + 2) = (u_p_error.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 111 *(outbuffer + offset + 3) = (u_p_error.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 112 *(outbuffer + offset + 4) = (u_p_error.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 113 *(outbuffer + offset + 5) = (u_p_error.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 114 *(outbuffer + offset + 6) = (u_p_error.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 115 *(outbuffer + offset + 7) = (u_p_error.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 116 offset += sizeof(this->p_error);
Gary Servin 0:04ac6be8229a 117 union {
Gary Servin 0:04ac6be8229a 118 double real;
Gary Servin 0:04ac6be8229a 119 uint64_t base;
Gary Servin 0:04ac6be8229a 120 } u_i_error;
Gary Servin 0:04ac6be8229a 121 u_i_error.real = this->i_error;
Gary Servin 0:04ac6be8229a 122 *(outbuffer + offset + 0) = (u_i_error.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 123 *(outbuffer + offset + 1) = (u_i_error.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 124 *(outbuffer + offset + 2) = (u_i_error.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 125 *(outbuffer + offset + 3) = (u_i_error.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 126 *(outbuffer + offset + 4) = (u_i_error.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 127 *(outbuffer + offset + 5) = (u_i_error.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 128 *(outbuffer + offset + 6) = (u_i_error.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 129 *(outbuffer + offset + 7) = (u_i_error.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 130 offset += sizeof(this->i_error);
Gary Servin 0:04ac6be8229a 131 union {
Gary Servin 0:04ac6be8229a 132 double real;
Gary Servin 0:04ac6be8229a 133 uint64_t base;
Gary Servin 0:04ac6be8229a 134 } u_d_error;
Gary Servin 0:04ac6be8229a 135 u_d_error.real = this->d_error;
Gary Servin 0:04ac6be8229a 136 *(outbuffer + offset + 0) = (u_d_error.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 137 *(outbuffer + offset + 1) = (u_d_error.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 138 *(outbuffer + offset + 2) = (u_d_error.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 139 *(outbuffer + offset + 3) = (u_d_error.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 140 *(outbuffer + offset + 4) = (u_d_error.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 141 *(outbuffer + offset + 5) = (u_d_error.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 142 *(outbuffer + offset + 6) = (u_d_error.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 143 *(outbuffer + offset + 7) = (u_d_error.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 144 offset += sizeof(this->d_error);
Gary Servin 0:04ac6be8229a 145 union {
Gary Servin 0:04ac6be8229a 146 double real;
Gary Servin 0:04ac6be8229a 147 uint64_t base;
Gary Servin 0:04ac6be8229a 148 } u_p_term;
Gary Servin 0:04ac6be8229a 149 u_p_term.real = this->p_term;
Gary Servin 0:04ac6be8229a 150 *(outbuffer + offset + 0) = (u_p_term.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 151 *(outbuffer + offset + 1) = (u_p_term.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 152 *(outbuffer + offset + 2) = (u_p_term.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 153 *(outbuffer + offset + 3) = (u_p_term.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 154 *(outbuffer + offset + 4) = (u_p_term.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 155 *(outbuffer + offset + 5) = (u_p_term.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 156 *(outbuffer + offset + 6) = (u_p_term.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 157 *(outbuffer + offset + 7) = (u_p_term.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 158 offset += sizeof(this->p_term);
Gary Servin 0:04ac6be8229a 159 union {
Gary Servin 0:04ac6be8229a 160 double real;
Gary Servin 0:04ac6be8229a 161 uint64_t base;
Gary Servin 0:04ac6be8229a 162 } u_i_term;
Gary Servin 0:04ac6be8229a 163 u_i_term.real = this->i_term;
Gary Servin 0:04ac6be8229a 164 *(outbuffer + offset + 0) = (u_i_term.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 165 *(outbuffer + offset + 1) = (u_i_term.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 166 *(outbuffer + offset + 2) = (u_i_term.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 167 *(outbuffer + offset + 3) = (u_i_term.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 168 *(outbuffer + offset + 4) = (u_i_term.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 169 *(outbuffer + offset + 5) = (u_i_term.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 170 *(outbuffer + offset + 6) = (u_i_term.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 171 *(outbuffer + offset + 7) = (u_i_term.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 172 offset += sizeof(this->i_term);
Gary Servin 0:04ac6be8229a 173 union {
Gary Servin 0:04ac6be8229a 174 double real;
Gary Servin 0:04ac6be8229a 175 uint64_t base;
Gary Servin 0:04ac6be8229a 176 } u_d_term;
Gary Servin 0:04ac6be8229a 177 u_d_term.real = this->d_term;
Gary Servin 0:04ac6be8229a 178 *(outbuffer + offset + 0) = (u_d_term.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 179 *(outbuffer + offset + 1) = (u_d_term.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 180 *(outbuffer + offset + 2) = (u_d_term.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 181 *(outbuffer + offset + 3) = (u_d_term.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 182 *(outbuffer + offset + 4) = (u_d_term.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 183 *(outbuffer + offset + 5) = (u_d_term.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 184 *(outbuffer + offset + 6) = (u_d_term.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 185 *(outbuffer + offset + 7) = (u_d_term.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 186 offset += sizeof(this->d_term);
Gary Servin 0:04ac6be8229a 187 union {
Gary Servin 0:04ac6be8229a 188 double real;
Gary Servin 0:04ac6be8229a 189 uint64_t base;
Gary Servin 0:04ac6be8229a 190 } u_i_max;
Gary Servin 0:04ac6be8229a 191 u_i_max.real = this->i_max;
Gary Servin 0:04ac6be8229a 192 *(outbuffer + offset + 0) = (u_i_max.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 193 *(outbuffer + offset + 1) = (u_i_max.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 194 *(outbuffer + offset + 2) = (u_i_max.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 195 *(outbuffer + offset + 3) = (u_i_max.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 196 *(outbuffer + offset + 4) = (u_i_max.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 197 *(outbuffer + offset + 5) = (u_i_max.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 198 *(outbuffer + offset + 6) = (u_i_max.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 199 *(outbuffer + offset + 7) = (u_i_max.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 200 offset += sizeof(this->i_max);
Gary Servin 0:04ac6be8229a 201 union {
Gary Servin 0:04ac6be8229a 202 double real;
Gary Servin 0:04ac6be8229a 203 uint64_t base;
Gary Servin 0:04ac6be8229a 204 } u_i_min;
Gary Servin 0:04ac6be8229a 205 u_i_min.real = this->i_min;
Gary Servin 0:04ac6be8229a 206 *(outbuffer + offset + 0) = (u_i_min.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 207 *(outbuffer + offset + 1) = (u_i_min.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 208 *(outbuffer + offset + 2) = (u_i_min.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 209 *(outbuffer + offset + 3) = (u_i_min.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 210 *(outbuffer + offset + 4) = (u_i_min.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 211 *(outbuffer + offset + 5) = (u_i_min.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 212 *(outbuffer + offset + 6) = (u_i_min.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 213 *(outbuffer + offset + 7) = (u_i_min.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 214 offset += sizeof(this->i_min);
Gary Servin 0:04ac6be8229a 215 union {
Gary Servin 0:04ac6be8229a 216 double real;
Gary Servin 0:04ac6be8229a 217 uint64_t base;
Gary Servin 0:04ac6be8229a 218 } u_output;
Gary Servin 0:04ac6be8229a 219 u_output.real = this->output;
Gary Servin 0:04ac6be8229a 220 *(outbuffer + offset + 0) = (u_output.base >> (8 * 0)) & 0xFF;
Gary Servin 0:04ac6be8229a 221 *(outbuffer + offset + 1) = (u_output.base >> (8 * 1)) & 0xFF;
Gary Servin 0:04ac6be8229a 222 *(outbuffer + offset + 2) = (u_output.base >> (8 * 2)) & 0xFF;
Gary Servin 0:04ac6be8229a 223 *(outbuffer + offset + 3) = (u_output.base >> (8 * 3)) & 0xFF;
Gary Servin 0:04ac6be8229a 224 *(outbuffer + offset + 4) = (u_output.base >> (8 * 4)) & 0xFF;
Gary Servin 0:04ac6be8229a 225 *(outbuffer + offset + 5) = (u_output.base >> (8 * 5)) & 0xFF;
Gary Servin 0:04ac6be8229a 226 *(outbuffer + offset + 6) = (u_output.base >> (8 * 6)) & 0xFF;
Gary Servin 0:04ac6be8229a 227 *(outbuffer + offset + 7) = (u_output.base >> (8 * 7)) & 0xFF;
Gary Servin 0:04ac6be8229a 228 offset += sizeof(this->output);
Gary Servin 0:04ac6be8229a 229 return offset;
Gary Servin 0:04ac6be8229a 230 }
Gary Servin 0:04ac6be8229a 231
Gary Servin 0:04ac6be8229a 232 virtual int deserialize(unsigned char *inbuffer)
Gary Servin 0:04ac6be8229a 233 {
Gary Servin 0:04ac6be8229a 234 int offset = 0;
Gary Servin 0:04ac6be8229a 235 offset += this->header.deserialize(inbuffer + offset);
Gary Servin 0:04ac6be8229a 236 this->timestep.sec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 237 this->timestep.sec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 238 this->timestep.sec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 239 this->timestep.sec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 240 offset += sizeof(this->timestep.sec);
Gary Servin 0:04ac6be8229a 241 this->timestep.nsec = ((uint32_t) (*(inbuffer + offset)));
Gary Servin 0:04ac6be8229a 242 this->timestep.nsec |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 243 this->timestep.nsec |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 244 this->timestep.nsec |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 245 offset += sizeof(this->timestep.nsec);
Gary Servin 0:04ac6be8229a 246 union {
Gary Servin 0:04ac6be8229a 247 double real;
Gary Servin 0:04ac6be8229a 248 uint64_t base;
Gary Servin 0:04ac6be8229a 249 } u_error;
Gary Servin 0:04ac6be8229a 250 u_error.base = 0;
Gary Servin 0:04ac6be8229a 251 u_error.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 252 u_error.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 253 u_error.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 254 u_error.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 255 u_error.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 256 u_error.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 257 u_error.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 258 u_error.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 259 this->error = u_error.real;
Gary Servin 0:04ac6be8229a 260 offset += sizeof(this->error);
Gary Servin 0:04ac6be8229a 261 union {
Gary Servin 0:04ac6be8229a 262 double real;
Gary Servin 0:04ac6be8229a 263 uint64_t base;
Gary Servin 0:04ac6be8229a 264 } u_error_dot;
Gary Servin 0:04ac6be8229a 265 u_error_dot.base = 0;
Gary Servin 0:04ac6be8229a 266 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 267 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 268 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 269 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 270 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 271 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 272 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 273 u_error_dot.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 274 this->error_dot = u_error_dot.real;
Gary Servin 0:04ac6be8229a 275 offset += sizeof(this->error_dot);
Gary Servin 0:04ac6be8229a 276 union {
Gary Servin 0:04ac6be8229a 277 double real;
Gary Servin 0:04ac6be8229a 278 uint64_t base;
Gary Servin 0:04ac6be8229a 279 } u_p_error;
Gary Servin 0:04ac6be8229a 280 u_p_error.base = 0;
Gary Servin 0:04ac6be8229a 281 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 282 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 283 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 284 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 285 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 286 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 287 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 288 u_p_error.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 289 this->p_error = u_p_error.real;
Gary Servin 0:04ac6be8229a 290 offset += sizeof(this->p_error);
Gary Servin 0:04ac6be8229a 291 union {
Gary Servin 0:04ac6be8229a 292 double real;
Gary Servin 0:04ac6be8229a 293 uint64_t base;
Gary Servin 0:04ac6be8229a 294 } u_i_error;
Gary Servin 0:04ac6be8229a 295 u_i_error.base = 0;
Gary Servin 0:04ac6be8229a 296 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 297 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 298 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 299 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 300 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 301 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 302 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 303 u_i_error.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 304 this->i_error = u_i_error.real;
Gary Servin 0:04ac6be8229a 305 offset += sizeof(this->i_error);
Gary Servin 0:04ac6be8229a 306 union {
Gary Servin 0:04ac6be8229a 307 double real;
Gary Servin 0:04ac6be8229a 308 uint64_t base;
Gary Servin 0:04ac6be8229a 309 } u_d_error;
Gary Servin 0:04ac6be8229a 310 u_d_error.base = 0;
Gary Servin 0:04ac6be8229a 311 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 312 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 313 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 314 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 315 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 316 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 317 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 318 u_d_error.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 319 this->d_error = u_d_error.real;
Gary Servin 0:04ac6be8229a 320 offset += sizeof(this->d_error);
Gary Servin 0:04ac6be8229a 321 union {
Gary Servin 0:04ac6be8229a 322 double real;
Gary Servin 0:04ac6be8229a 323 uint64_t base;
Gary Servin 0:04ac6be8229a 324 } u_p_term;
Gary Servin 0:04ac6be8229a 325 u_p_term.base = 0;
Gary Servin 0:04ac6be8229a 326 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 327 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 328 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 329 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 330 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 331 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 332 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 333 u_p_term.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 334 this->p_term = u_p_term.real;
Gary Servin 0:04ac6be8229a 335 offset += sizeof(this->p_term);
Gary Servin 0:04ac6be8229a 336 union {
Gary Servin 0:04ac6be8229a 337 double real;
Gary Servin 0:04ac6be8229a 338 uint64_t base;
Gary Servin 0:04ac6be8229a 339 } u_i_term;
Gary Servin 0:04ac6be8229a 340 u_i_term.base = 0;
Gary Servin 0:04ac6be8229a 341 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 342 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 343 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 344 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 345 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 346 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 347 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 348 u_i_term.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 349 this->i_term = u_i_term.real;
Gary Servin 0:04ac6be8229a 350 offset += sizeof(this->i_term);
Gary Servin 0:04ac6be8229a 351 union {
Gary Servin 0:04ac6be8229a 352 double real;
Gary Servin 0:04ac6be8229a 353 uint64_t base;
Gary Servin 0:04ac6be8229a 354 } u_d_term;
Gary Servin 0:04ac6be8229a 355 u_d_term.base = 0;
Gary Servin 0:04ac6be8229a 356 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 357 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 358 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 359 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 360 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 361 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 362 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 363 u_d_term.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 364 this->d_term = u_d_term.real;
Gary Servin 0:04ac6be8229a 365 offset += sizeof(this->d_term);
Gary Servin 0:04ac6be8229a 366 union {
Gary Servin 0:04ac6be8229a 367 double real;
Gary Servin 0:04ac6be8229a 368 uint64_t base;
Gary Servin 0:04ac6be8229a 369 } u_i_max;
Gary Servin 0:04ac6be8229a 370 u_i_max.base = 0;
Gary Servin 0:04ac6be8229a 371 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 372 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 373 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 374 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 375 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 376 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 377 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 378 u_i_max.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 379 this->i_max = u_i_max.real;
Gary Servin 0:04ac6be8229a 380 offset += sizeof(this->i_max);
Gary Servin 0:04ac6be8229a 381 union {
Gary Servin 0:04ac6be8229a 382 double real;
Gary Servin 0:04ac6be8229a 383 uint64_t base;
Gary Servin 0:04ac6be8229a 384 } u_i_min;
Gary Servin 0:04ac6be8229a 385 u_i_min.base = 0;
Gary Servin 0:04ac6be8229a 386 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 387 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 388 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 389 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 390 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 391 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 392 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 393 u_i_min.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 394 this->i_min = u_i_min.real;
Gary Servin 0:04ac6be8229a 395 offset += sizeof(this->i_min);
Gary Servin 0:04ac6be8229a 396 union {
Gary Servin 0:04ac6be8229a 397 double real;
Gary Servin 0:04ac6be8229a 398 uint64_t base;
Gary Servin 0:04ac6be8229a 399 } u_output;
Gary Servin 0:04ac6be8229a 400 u_output.base = 0;
Gary Servin 0:04ac6be8229a 401 u_output.base |= ((uint64_t) (*(inbuffer + offset + 0))) << (8 * 0);
Gary Servin 0:04ac6be8229a 402 u_output.base |= ((uint64_t) (*(inbuffer + offset + 1))) << (8 * 1);
Gary Servin 0:04ac6be8229a 403 u_output.base |= ((uint64_t) (*(inbuffer + offset + 2))) << (8 * 2);
Gary Servin 0:04ac6be8229a 404 u_output.base |= ((uint64_t) (*(inbuffer + offset + 3))) << (8 * 3);
Gary Servin 0:04ac6be8229a 405 u_output.base |= ((uint64_t) (*(inbuffer + offset + 4))) << (8 * 4);
Gary Servin 0:04ac6be8229a 406 u_output.base |= ((uint64_t) (*(inbuffer + offset + 5))) << (8 * 5);
Gary Servin 0:04ac6be8229a 407 u_output.base |= ((uint64_t) (*(inbuffer + offset + 6))) << (8 * 6);
Gary Servin 0:04ac6be8229a 408 u_output.base |= ((uint64_t) (*(inbuffer + offset + 7))) << (8 * 7);
Gary Servin 0:04ac6be8229a 409 this->output = u_output.real;
Gary Servin 0:04ac6be8229a 410 offset += sizeof(this->output);
Gary Servin 0:04ac6be8229a 411 return offset;
Gary Servin 0:04ac6be8229a 412 }
Gary Servin 0:04ac6be8229a 413
Gary Servin 0:04ac6be8229a 414 const char * getType(){ return "control_msgs/PidState"; };
Gary Servin 0:04ac6be8229a 415 const char * getMD5(){ return "b138ec00e886c10e73f27e8712252ea6"; };
Gary Servin 0:04ac6be8229a 416
Gary Servin 0:04ac6be8229a 417 };
Gary Servin 0:04ac6be8229a 418
Gary Servin 0:04ac6be8229a 419 }
Gary Servin 0:04ac6be8229a 420 #endif