ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

A few things jump out immediately:

scanData.header.seq = scanData.header.seq++;

Won't do what you expect (http://stackoverflow.com/questions/24853/what-is-the-difference-between-i-and-i)

for(int i = 0; i <= 144; i++){ scanData.ranges[i] = distances[i]; }

You can't just write into an array like this (http://wiki.ros.org/rosserial/Overview/Limitations#Arrays). You either need to allocate the array, and then move the data, or just set the array pointer to the appropriate destination:

scanData.ranges = &distances;

Don't forget to set the size as well:

scanData.ranges_size = 145;

A few things jump out immediately:

scanData.header.seq = scanData.header.seq++;

Won't do what you expect (http://stackoverflow.com/questions/24853/what-is-the-difference-between-i-and-i)

for(int i = 0; i <= 144; i++){ scanData.ranges[i] = distances[i]; }

You can't just write into an array like this (http://wiki.ros.org/rosserial/Overview/Limitations#Arrays). You either need to allocate the array, and then move the data, or just set the array pointer to the appropriate destination:

scanData.ranges = &distances;

Don't forget to set the size as well:

scanData.ranges_size scanData.ranges_length = 145;