ROS Serial library for Mbed platforms for ROS Melodic Morenia. Check http://wiki.ros.org/rosserial_mbed/ for more information.
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(); } }
sensor_msgs/LaserScan.h@0:04ac6be8229a, 2019-11-08 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
Gary Servin |
0:04ac6be8229a | 1 | #ifndef _ROS_sensor_msgs_LaserScan_h |
Gary Servin |
0:04ac6be8229a | 2 | #define _ROS_sensor_msgs_LaserScan_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 | |
Gary Servin |
0:04ac6be8229a | 10 | namespace sensor_msgs |
Gary Servin |
0:04ac6be8229a | 11 | { |
Gary Servin |
0:04ac6be8229a | 12 | |
Gary Servin |
0:04ac6be8229a | 13 | class LaserScan : public ros::Msg |
Gary Servin |
0:04ac6be8229a | 14 | { |
Gary Servin |
0:04ac6be8229a | 15 | public: |
Gary Servin |
0:04ac6be8229a | 16 | typedef std_msgs::Header _header_type; |
Gary Servin |
0:04ac6be8229a | 17 | _header_type header; |
Gary Servin |
0:04ac6be8229a | 18 | typedef float _angle_min_type; |
Gary Servin |
0:04ac6be8229a | 19 | _angle_min_type angle_min; |
Gary Servin |
0:04ac6be8229a | 20 | typedef float _angle_max_type; |
Gary Servin |
0:04ac6be8229a | 21 | _angle_max_type angle_max; |
Gary Servin |
0:04ac6be8229a | 22 | typedef float _angle_increment_type; |
Gary Servin |
0:04ac6be8229a | 23 | _angle_increment_type angle_increment; |
Gary Servin |
0:04ac6be8229a | 24 | typedef float _time_increment_type; |
Gary Servin |
0:04ac6be8229a | 25 | _time_increment_type time_increment; |
Gary Servin |
0:04ac6be8229a | 26 | typedef float _scan_time_type; |
Gary Servin |
0:04ac6be8229a | 27 | _scan_time_type scan_time; |
Gary Servin |
0:04ac6be8229a | 28 | typedef float _range_min_type; |
Gary Servin |
0:04ac6be8229a | 29 | _range_min_type range_min; |
Gary Servin |
0:04ac6be8229a | 30 | typedef float _range_max_type; |
Gary Servin |
0:04ac6be8229a | 31 | _range_max_type range_max; |
Gary Servin |
0:04ac6be8229a | 32 | uint32_t ranges_length; |
Gary Servin |
0:04ac6be8229a | 33 | typedef float _ranges_type; |
Gary Servin |
0:04ac6be8229a | 34 | _ranges_type st_ranges; |
Gary Servin |
0:04ac6be8229a | 35 | _ranges_type * ranges; |
Gary Servin |
0:04ac6be8229a | 36 | uint32_t intensities_length; |
Gary Servin |
0:04ac6be8229a | 37 | typedef float _intensities_type; |
Gary Servin |
0:04ac6be8229a | 38 | _intensities_type st_intensities; |
Gary Servin |
0:04ac6be8229a | 39 | _intensities_type * intensities; |
Gary Servin |
0:04ac6be8229a | 40 | |
Gary Servin |
0:04ac6be8229a | 41 | LaserScan(): |
Gary Servin |
0:04ac6be8229a | 42 | header(), |
Gary Servin |
0:04ac6be8229a | 43 | angle_min(0), |
Gary Servin |
0:04ac6be8229a | 44 | angle_max(0), |
Gary Servin |
0:04ac6be8229a | 45 | angle_increment(0), |
Gary Servin |
0:04ac6be8229a | 46 | time_increment(0), |
Gary Servin |
0:04ac6be8229a | 47 | scan_time(0), |
Gary Servin |
0:04ac6be8229a | 48 | range_min(0), |
Gary Servin |
0:04ac6be8229a | 49 | range_max(0), |
Gary Servin |
0:04ac6be8229a | 50 | ranges_length(0), ranges(NULL), |
Gary Servin |
0:04ac6be8229a | 51 | intensities_length(0), intensities(NULL) |
Gary Servin |
0:04ac6be8229a | 52 | { |
Gary Servin |
0:04ac6be8229a | 53 | } |
Gary Servin |
0:04ac6be8229a | 54 | |
Gary Servin |
0:04ac6be8229a | 55 | virtual int serialize(unsigned char *outbuffer) const |
Gary Servin |
0:04ac6be8229a | 56 | { |
Gary Servin |
0:04ac6be8229a | 57 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 58 | offset += this->header.serialize(outbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 59 | union { |
Gary Servin |
0:04ac6be8229a | 60 | float real; |
Gary Servin |
0:04ac6be8229a | 61 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 62 | } u_angle_min; |
Gary Servin |
0:04ac6be8229a | 63 | u_angle_min.real = this->angle_min; |
Gary Servin |
0:04ac6be8229a | 64 | *(outbuffer + offset + 0) = (u_angle_min.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 65 | *(outbuffer + offset + 1) = (u_angle_min.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 66 | *(outbuffer + offset + 2) = (u_angle_min.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 67 | *(outbuffer + offset + 3) = (u_angle_min.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 68 | offset += sizeof(this->angle_min); |
Gary Servin |
0:04ac6be8229a | 69 | union { |
Gary Servin |
0:04ac6be8229a | 70 | float real; |
Gary Servin |
0:04ac6be8229a | 71 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 72 | } u_angle_max; |
Gary Servin |
0:04ac6be8229a | 73 | u_angle_max.real = this->angle_max; |
Gary Servin |
0:04ac6be8229a | 74 | *(outbuffer + offset + 0) = (u_angle_max.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 75 | *(outbuffer + offset + 1) = (u_angle_max.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 76 | *(outbuffer + offset + 2) = (u_angle_max.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 77 | *(outbuffer + offset + 3) = (u_angle_max.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 78 | offset += sizeof(this->angle_max); |
Gary Servin |
0:04ac6be8229a | 79 | union { |
Gary Servin |
0:04ac6be8229a | 80 | float real; |
Gary Servin |
0:04ac6be8229a | 81 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 82 | } u_angle_increment; |
Gary Servin |
0:04ac6be8229a | 83 | u_angle_increment.real = this->angle_increment; |
Gary Servin |
0:04ac6be8229a | 84 | *(outbuffer + offset + 0) = (u_angle_increment.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 85 | *(outbuffer + offset + 1) = (u_angle_increment.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 86 | *(outbuffer + offset + 2) = (u_angle_increment.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 87 | *(outbuffer + offset + 3) = (u_angle_increment.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 88 | offset += sizeof(this->angle_increment); |
Gary Servin |
0:04ac6be8229a | 89 | union { |
Gary Servin |
0:04ac6be8229a | 90 | float real; |
Gary Servin |
0:04ac6be8229a | 91 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 92 | } u_time_increment; |
Gary Servin |
0:04ac6be8229a | 93 | u_time_increment.real = this->time_increment; |
Gary Servin |
0:04ac6be8229a | 94 | *(outbuffer + offset + 0) = (u_time_increment.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 95 | *(outbuffer + offset + 1) = (u_time_increment.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 96 | *(outbuffer + offset + 2) = (u_time_increment.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 97 | *(outbuffer + offset + 3) = (u_time_increment.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 98 | offset += sizeof(this->time_increment); |
Gary Servin |
0:04ac6be8229a | 99 | union { |
Gary Servin |
0:04ac6be8229a | 100 | float real; |
Gary Servin |
0:04ac6be8229a | 101 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 102 | } u_scan_time; |
Gary Servin |
0:04ac6be8229a | 103 | u_scan_time.real = this->scan_time; |
Gary Servin |
0:04ac6be8229a | 104 | *(outbuffer + offset + 0) = (u_scan_time.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 105 | *(outbuffer + offset + 1) = (u_scan_time.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 106 | *(outbuffer + offset + 2) = (u_scan_time.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 107 | *(outbuffer + offset + 3) = (u_scan_time.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 108 | offset += sizeof(this->scan_time); |
Gary Servin |
0:04ac6be8229a | 109 | union { |
Gary Servin |
0:04ac6be8229a | 110 | float real; |
Gary Servin |
0:04ac6be8229a | 111 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 112 | } u_range_min; |
Gary Servin |
0:04ac6be8229a | 113 | u_range_min.real = this->range_min; |
Gary Servin |
0:04ac6be8229a | 114 | *(outbuffer + offset + 0) = (u_range_min.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 115 | *(outbuffer + offset + 1) = (u_range_min.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 116 | *(outbuffer + offset + 2) = (u_range_min.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 117 | *(outbuffer + offset + 3) = (u_range_min.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 118 | offset += sizeof(this->range_min); |
Gary Servin |
0:04ac6be8229a | 119 | union { |
Gary Servin |
0:04ac6be8229a | 120 | float real; |
Gary Servin |
0:04ac6be8229a | 121 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 122 | } u_range_max; |
Gary Servin |
0:04ac6be8229a | 123 | u_range_max.real = this->range_max; |
Gary Servin |
0:04ac6be8229a | 124 | *(outbuffer + offset + 0) = (u_range_max.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 125 | *(outbuffer + offset + 1) = (u_range_max.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 126 | *(outbuffer + offset + 2) = (u_range_max.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 127 | *(outbuffer + offset + 3) = (u_range_max.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 128 | offset += sizeof(this->range_max); |
Gary Servin |
0:04ac6be8229a | 129 | *(outbuffer + offset + 0) = (this->ranges_length >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 130 | *(outbuffer + offset + 1) = (this->ranges_length >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 131 | *(outbuffer + offset + 2) = (this->ranges_length >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 132 | *(outbuffer + offset + 3) = (this->ranges_length >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 133 | offset += sizeof(this->ranges_length); |
Gary Servin |
0:04ac6be8229a | 134 | for( uint32_t i = 0; i < ranges_length; i++){ |
Gary Servin |
0:04ac6be8229a | 135 | union { |
Gary Servin |
0:04ac6be8229a | 136 | float real; |
Gary Servin |
0:04ac6be8229a | 137 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 138 | } u_rangesi; |
Gary Servin |
0:04ac6be8229a | 139 | u_rangesi.real = this->ranges[i]; |
Gary Servin |
0:04ac6be8229a | 140 | *(outbuffer + offset + 0) = (u_rangesi.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 141 | *(outbuffer + offset + 1) = (u_rangesi.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 142 | *(outbuffer + offset + 2) = (u_rangesi.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 143 | *(outbuffer + offset + 3) = (u_rangesi.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 144 | offset += sizeof(this->ranges[i]); |
Gary Servin |
0:04ac6be8229a | 145 | } |
Gary Servin |
0:04ac6be8229a | 146 | *(outbuffer + offset + 0) = (this->intensities_length >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 147 | *(outbuffer + offset + 1) = (this->intensities_length >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 148 | *(outbuffer + offset + 2) = (this->intensities_length >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 149 | *(outbuffer + offset + 3) = (this->intensities_length >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 150 | offset += sizeof(this->intensities_length); |
Gary Servin |
0:04ac6be8229a | 151 | for( uint32_t i = 0; i < intensities_length; i++){ |
Gary Servin |
0:04ac6be8229a | 152 | union { |
Gary Servin |
0:04ac6be8229a | 153 | float real; |
Gary Servin |
0:04ac6be8229a | 154 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 155 | } u_intensitiesi; |
Gary Servin |
0:04ac6be8229a | 156 | u_intensitiesi.real = this->intensities[i]; |
Gary Servin |
0:04ac6be8229a | 157 | *(outbuffer + offset + 0) = (u_intensitiesi.base >> (8 * 0)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 158 | *(outbuffer + offset + 1) = (u_intensitiesi.base >> (8 * 1)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 159 | *(outbuffer + offset + 2) = (u_intensitiesi.base >> (8 * 2)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 160 | *(outbuffer + offset + 3) = (u_intensitiesi.base >> (8 * 3)) & 0xFF; |
Gary Servin |
0:04ac6be8229a | 161 | offset += sizeof(this->intensities[i]); |
Gary Servin |
0:04ac6be8229a | 162 | } |
Gary Servin |
0:04ac6be8229a | 163 | return offset; |
Gary Servin |
0:04ac6be8229a | 164 | } |
Gary Servin |
0:04ac6be8229a | 165 | |
Gary Servin |
0:04ac6be8229a | 166 | virtual int deserialize(unsigned char *inbuffer) |
Gary Servin |
0:04ac6be8229a | 167 | { |
Gary Servin |
0:04ac6be8229a | 168 | int offset = 0; |
Gary Servin |
0:04ac6be8229a | 169 | offset += this->header.deserialize(inbuffer + offset); |
Gary Servin |
0:04ac6be8229a | 170 | union { |
Gary Servin |
0:04ac6be8229a | 171 | float real; |
Gary Servin |
0:04ac6be8229a | 172 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 173 | } u_angle_min; |
Gary Servin |
0:04ac6be8229a | 174 | u_angle_min.base = 0; |
Gary Servin |
0:04ac6be8229a | 175 | u_angle_min.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 176 | u_angle_min.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 177 | u_angle_min.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 178 | u_angle_min.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 179 | this->angle_min = u_angle_min.real; |
Gary Servin |
0:04ac6be8229a | 180 | offset += sizeof(this->angle_min); |
Gary Servin |
0:04ac6be8229a | 181 | union { |
Gary Servin |
0:04ac6be8229a | 182 | float real; |
Gary Servin |
0:04ac6be8229a | 183 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 184 | } u_angle_max; |
Gary Servin |
0:04ac6be8229a | 185 | u_angle_max.base = 0; |
Gary Servin |
0:04ac6be8229a | 186 | u_angle_max.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 187 | u_angle_max.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 188 | u_angle_max.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 189 | u_angle_max.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 190 | this->angle_max = u_angle_max.real; |
Gary Servin |
0:04ac6be8229a | 191 | offset += sizeof(this->angle_max); |
Gary Servin |
0:04ac6be8229a | 192 | union { |
Gary Servin |
0:04ac6be8229a | 193 | float real; |
Gary Servin |
0:04ac6be8229a | 194 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 195 | } u_angle_increment; |
Gary Servin |
0:04ac6be8229a | 196 | u_angle_increment.base = 0; |
Gary Servin |
0:04ac6be8229a | 197 | u_angle_increment.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 198 | u_angle_increment.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 199 | u_angle_increment.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 200 | u_angle_increment.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 201 | this->angle_increment = u_angle_increment.real; |
Gary Servin |
0:04ac6be8229a | 202 | offset += sizeof(this->angle_increment); |
Gary Servin |
0:04ac6be8229a | 203 | union { |
Gary Servin |
0:04ac6be8229a | 204 | float real; |
Gary Servin |
0:04ac6be8229a | 205 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 206 | } u_time_increment; |
Gary Servin |
0:04ac6be8229a | 207 | u_time_increment.base = 0; |
Gary Servin |
0:04ac6be8229a | 208 | u_time_increment.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 209 | u_time_increment.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 210 | u_time_increment.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 211 | u_time_increment.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 212 | this->time_increment = u_time_increment.real; |
Gary Servin |
0:04ac6be8229a | 213 | offset += sizeof(this->time_increment); |
Gary Servin |
0:04ac6be8229a | 214 | union { |
Gary Servin |
0:04ac6be8229a | 215 | float real; |
Gary Servin |
0:04ac6be8229a | 216 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 217 | } u_scan_time; |
Gary Servin |
0:04ac6be8229a | 218 | u_scan_time.base = 0; |
Gary Servin |
0:04ac6be8229a | 219 | u_scan_time.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 220 | u_scan_time.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 221 | u_scan_time.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 222 | u_scan_time.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 223 | this->scan_time = u_scan_time.real; |
Gary Servin |
0:04ac6be8229a | 224 | offset += sizeof(this->scan_time); |
Gary Servin |
0:04ac6be8229a | 225 | union { |
Gary Servin |
0:04ac6be8229a | 226 | float real; |
Gary Servin |
0:04ac6be8229a | 227 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 228 | } u_range_min; |
Gary Servin |
0:04ac6be8229a | 229 | u_range_min.base = 0; |
Gary Servin |
0:04ac6be8229a | 230 | u_range_min.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 231 | u_range_min.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 232 | u_range_min.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 233 | u_range_min.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 234 | this->range_min = u_range_min.real; |
Gary Servin |
0:04ac6be8229a | 235 | offset += sizeof(this->range_min); |
Gary Servin |
0:04ac6be8229a | 236 | union { |
Gary Servin |
0:04ac6be8229a | 237 | float real; |
Gary Servin |
0:04ac6be8229a | 238 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 239 | } u_range_max; |
Gary Servin |
0:04ac6be8229a | 240 | u_range_max.base = 0; |
Gary Servin |
0:04ac6be8229a | 241 | u_range_max.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 242 | u_range_max.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 243 | u_range_max.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 244 | u_range_max.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 245 | this->range_max = u_range_max.real; |
Gary Servin |
0:04ac6be8229a | 246 | offset += sizeof(this->range_max); |
Gary Servin |
0:04ac6be8229a | 247 | uint32_t ranges_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 248 | ranges_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 249 | ranges_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 250 | ranges_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 251 | offset += sizeof(this->ranges_length); |
Gary Servin |
0:04ac6be8229a | 252 | if(ranges_lengthT > ranges_length) |
Gary Servin |
0:04ac6be8229a | 253 | this->ranges = (float*)realloc(this->ranges, ranges_lengthT * sizeof(float)); |
Gary Servin |
0:04ac6be8229a | 254 | ranges_length = ranges_lengthT; |
Gary Servin |
0:04ac6be8229a | 255 | for( uint32_t i = 0; i < ranges_length; i++){ |
Gary Servin |
0:04ac6be8229a | 256 | union { |
Gary Servin |
0:04ac6be8229a | 257 | float real; |
Gary Servin |
0:04ac6be8229a | 258 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 259 | } u_st_ranges; |
Gary Servin |
0:04ac6be8229a | 260 | u_st_ranges.base = 0; |
Gary Servin |
0:04ac6be8229a | 261 | u_st_ranges.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 262 | u_st_ranges.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 263 | u_st_ranges.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 264 | u_st_ranges.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 265 | this->st_ranges = u_st_ranges.real; |
Gary Servin |
0:04ac6be8229a | 266 | offset += sizeof(this->st_ranges); |
Gary Servin |
0:04ac6be8229a | 267 | memcpy( &(this->ranges[i]), &(this->st_ranges), sizeof(float)); |
Gary Servin |
0:04ac6be8229a | 268 | } |
Gary Servin |
0:04ac6be8229a | 269 | uint32_t intensities_lengthT = ((uint32_t) (*(inbuffer + offset))); |
Gary Servin |
0:04ac6be8229a | 270 | intensities_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 271 | intensities_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 272 | intensities_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 273 | offset += sizeof(this->intensities_length); |
Gary Servin |
0:04ac6be8229a | 274 | if(intensities_lengthT > intensities_length) |
Gary Servin |
0:04ac6be8229a | 275 | this->intensities = (float*)realloc(this->intensities, intensities_lengthT * sizeof(float)); |
Gary Servin |
0:04ac6be8229a | 276 | intensities_length = intensities_lengthT; |
Gary Servin |
0:04ac6be8229a | 277 | for( uint32_t i = 0; i < intensities_length; i++){ |
Gary Servin |
0:04ac6be8229a | 278 | union { |
Gary Servin |
0:04ac6be8229a | 279 | float real; |
Gary Servin |
0:04ac6be8229a | 280 | uint32_t base; |
Gary Servin |
0:04ac6be8229a | 281 | } u_st_intensities; |
Gary Servin |
0:04ac6be8229a | 282 | u_st_intensities.base = 0; |
Gary Servin |
0:04ac6be8229a | 283 | u_st_intensities.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0); |
Gary Servin |
0:04ac6be8229a | 284 | u_st_intensities.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
Gary Servin |
0:04ac6be8229a | 285 | u_st_intensities.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
Gary Servin |
0:04ac6be8229a | 286 | u_st_intensities.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
Gary Servin |
0:04ac6be8229a | 287 | this->st_intensities = u_st_intensities.real; |
Gary Servin |
0:04ac6be8229a | 288 | offset += sizeof(this->st_intensities); |
Gary Servin |
0:04ac6be8229a | 289 | memcpy( &(this->intensities[i]), &(this->st_intensities), sizeof(float)); |
Gary Servin |
0:04ac6be8229a | 290 | } |
Gary Servin |
0:04ac6be8229a | 291 | return offset; |
Gary Servin |
0:04ac6be8229a | 292 | } |
Gary Servin |
0:04ac6be8229a | 293 | |
Gary Servin |
0:04ac6be8229a | 294 | const char * getType(){ return "sensor_msgs/LaserScan"; }; |
Gary Servin |
0:04ac6be8229a | 295 | const char * getMD5(){ return "90c7ef2dc6895d81024acba2ac42f369"; }; |
Gary Servin |
0:04ac6be8229a | 296 | |
Gary Servin |
0:04ac6be8229a | 297 | }; |
Gary Servin |
0:04ac6be8229a | 298 | |
Gary Servin |
0:04ac6be8229a | 299 | } |
Gary Servin |
0:04ac6be8229a | 300 | #endif |