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

Revision history [back]

click to hide/show revision 1
initial version

I have come to realize that rosserial cannot handle large amount of data. I have been able to resolve some of my issues. I think it would be useful to see the fake laser example complete for the arduino just as an example on how to serialize the data variables properly. Therefore, I have restricted the data size to five ranges and intensities and continues to see if I can make this work.

The Groovy/ Hydro issue is resolved

  • I can now see the individual variables transferred correctly

  • I still have problems with 1) The range and intensities arrays are not handled correctly 2) The program hangs up after ~ 18 data transfers (probably runs out of memory)

Suggestions - C

Terminal 1

cd@M755:~$ roscore ... logging to /home/cd/.ros/log/8b28ee40-218d-11e5-9c0a-48f8b391f66d/roslaunch-M755-2182.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://M755:54111/ ros_comm version 1.11.13

SUMMARY

PARAMETERS * /rosdistro: indigo * /rosversion: 1.11.13

NODES

auto-starting new master process[master]: started with pid [2238] ROS_MASTER_URI=http://M755:11311/

setting /run_id to 8b28ee40-218d-11e5-9c0a-48f8b391f66d process[rosout-1]: started with pid [2251] started core service [/rosout]

Terminal 2

cd@M755:~$ source /opt/ros/indigo/setup.bash cd@M755:~$ rosrun rosserial_python serial_node.py /dev/ttyACM0 [INFO] [WallTime: 1435932768.452098] ROS Serial Python Node [INFO] [WallTime: 1435932768.456914] Connecting to /dev/ttyACM0 at 57600 baud /opt/ros/indigo/lib/python2.7/dist-packages/rosserial_python/SerialClient.py:336: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information. self.pub_diagnostics = rospy.Publisher('/diagnostics', diagnostic_msgs.msg.DiagnosticArray) /opt/ros/indigo/lib/python2.7/dist-packages/rosserial_python/SerialClient.py:101: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information. self.publisher = rospy.Publisher(self.topic, self.message) [INFO] [WallTime: 1435932771.823503] Note: publish buffer size is 512 bytes [INFO] [WallTime: 1435932771.824101] Setup publisher on LaserData [sensor_msgs/LaserScan]

Terminal 3

cd@M755:~$ rostopic echo LaserData header: seq: 1 stamp: secs: 1435932785 nsecs: 11943992 frame_id: laser_frame angle_min: -1.57000005245 angle_max: 1.57000005245 angle_increment: 0.785000026226 time_increment: 10.0 scan_time: 4.0 range_min: 0.10000000149 range_max: 30.0 ranges: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

intensities: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

. . .


header: seq: 18 stamp: secs: 1435932802 nsecs: 189945055 frame_id: laser_frame angle_min: -1.57000005245 angle_max: 1.57000005245 angle_increment: 0.785000026226 time_increment: 10.0 scan_time: 4.0 range_min: 0.10000000149 range_max: 30.0 ranges: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

intensities: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

#include "math.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

// ROS includes
#include <ros.h>
#include <ros/time.h>
#include <sensor_msgs/LaserScan.h>

sensor_msgs::LaserScan CDLaser_msg;

//
float f_angle_min;
float f_angle_max;
float f_angle_increment;
float f_time_increment;
float f_scan_time;
float f_range_min;
float f_range_max;
float f_ranges[5]; // max of 30 measuremenst
float f_intensities[5];

int publisher_timer;

ros:: Publisher pub_Laser("LaserData", &CDLaser_msg);
ros::NodeHandle nh;

void setup() 
{
  nh.initNode();
  nh.advertise(pub_Laser);

  f_angle_min = -1.57;
  f_angle_max = 1.57;
  f_angle_increment = 0.785;  // 3.14/4   - 5 measurement points
  f_time_increment = 10;
  f_scan_time = 4;
  f_range_min = 0.1;
  f_range_max = 30;

  CDLaser_msg.ranges_length = 5;
  CDLaser_msg.intensities_length = 5;

  // create the test data
  for (int z = 0 ; z<5; z++)
  {
    f_ranges[z] = z;
    f_intensities[z] = z*z;
  }
}

void loop() 
{
  if (millis() > publisher_timer)
  {
    CDLaser_msg.header.stamp = nh.now();
    CDLaser_msg.header.frame_id = "laser_frame";
    CDLaser_msg.angle_min = f_angle_min;
    CDLaser_msg.angle_max = f_angle_max;
    CDLaser_msg.angle_increment = f_angle_increment;
    CDLaser_msg.time_increment = f_time_increment;
    CDLaser_msg.scan_time = f_scan_time;
    CDLaser_msg.range_min = f_range_min;
    CDLaser_msg.range_max = f_range_max;

    for (int z = 0 ; z<5; z++)
    {
      CDLaser_msg.ranges[z] = f_ranges[z];
    }

    for (int z = 0 ; z<5; z++)
    {
      CDLaser_msg.intensities[z] = f_intensities[z];
    }

    publisher_timer = millis() + 1000;
    pub_Laser.publish(&CDLaser_msg);
  }
  nh.spinOnce();
  delay(500);
}

I have come to realize that rosserial cannot handle large amount of data. I have been able to resolve some of my issues. I think it would be useful to see the fake laser example complete for the arduino just as an example on how to serialize the data variables properly. Therefore, I have restricted the data size to five ranges and intensities and continues to see if I can make this work.

The Groovy/ Hydro issue is resolved

  • I can now see the individual variables transferred correctly

  • I still have problems with 1) The range and intensities arrays are not handled correctly 2) The program hangs up after ~ 18 data transfers (probably runs out of memory)

Suggestions - C

Terminal 1

cd@M755:~$ roscore ... logging to /home/cd/.ros/log/8b28ee40-218d-11e5-9c0a-48f8b391f66d/roslaunch-M755-2182.log Checking log directory for disk usage. This may take awhile. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://M755:54111/ ros_comm version 1.11.13

SUMMARY

PARAMETERS * /rosdistro: indigo * /rosversion: 1.11.13

NODES

auto-starting new master process[master]: started with pid [2238] ROS_MASTER_URI=http://M755:11311/

setting /run_id to 8b28ee40-218d-11e5-9c0a-48f8b391f66d process[rosout-1]: started with pid [2251] started core service [/rosout]

Terminal 2

cd@M755:~$ source /opt/ros/indigo/setup.bash cd@M755:~$ rosrun rosserial_python serial_node.py /dev/ttyACM0 [INFO] [WallTime: 1435932768.452098] ROS Serial Python Node [INFO] [WallTime: 1435932768.456914] Connecting to /dev/ttyACM0 at 57600 baud /opt/ros/indigo/lib/python2.7/dist-packages/rosserial_python/SerialClient.py:336: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information. self.pub_diagnostics = rospy.Publisher('/diagnostics', diagnostic_msgs.msg.DiagnosticArray) /opt/ros/indigo/lib/python2.7/dist-packages/rosserial_python/SerialClient.py:101: SyntaxWarning: The publisher should be created with an explicit keyword argument 'queue_size'. Please see http://wiki.ros.org/rospy/Overview/Publishers%20and%20Subscribers for more information. self.publisher = rospy.Publisher(self.topic, self.message) [INFO] [WallTime: 1435932771.823503] Note: publish buffer size is 512 bytes [INFO] [WallTime: 1435932771.824101] Setup publisher on LaserData [sensor_msgs/LaserScan]

Terminal 3

cd@M755:~$ rostopic echo LaserData header: seq: 1 stamp: secs: 1435932785 nsecs: 11943992 frame_id: laser_frame angle_min: -1.57000005245 angle_max: 1.57000005245 angle_increment: 0.785000026226 time_increment: 10.0 scan_time: 4.0 range_min: 0.10000000149 range_max: 30.0 ranges: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

intensities: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

. . .


header: seq: 18 stamp: secs: 1435932802 nsecs: 189945055 frame_id: laser_frame angle_min: -1.57000005245 angle_max: 1.57000005245 angle_increment: 0.785000026226 time_increment: 10.0 scan_time: 4.0 range_min: 0.10000000149 range_max: 30.0 ranges: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

intensities: [0.0, 1.0, 4.0, 9.00011920928955, 1.5519318162641656e-36]

#include "math.h"
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

// ROS includes
#include <ros.h>
#include <ros/time.h>
#include <sensor_msgs/LaserScan.h>

sensor_msgs::LaserScan CDLaser_msg;

//
float f_angle_min;
float f_angle_max;
float f_angle_increment;
float f_time_increment;
float f_scan_time;
float f_range_min;
float f_range_max;
float f_ranges[5]; // max of 30 measuremenst
float f_intensities[5];

int publisher_timer;

ros:: Publisher pub_Laser("LaserData", &CDLaser_msg);
ros::NodeHandle nh;

void setup() 
{
  nh.initNode();
  nh.advertise(pub_Laser);

  f_angle_min = -1.57;
  f_angle_max = 1.57;
  f_angle_increment = 0.785;  // 3.14/4   - 5 measurement points
  f_time_increment = 10;
  f_scan_time = 4;
  f_range_min = 0.1;
  f_range_max = 30;

  CDLaser_msg.ranges_length = 5;
  CDLaser_msg.intensities_length = 5;

  // create the test data
  for (int z = 0 ; z<5; z++)
  {
    f_ranges[z] = z;
    f_intensities[z] = z*z;
  }
}

void loop() 
{
  if (millis() > publisher_timer)
  {
    CDLaser_msg.header.stamp = nh.now();
    CDLaser_msg.header.frame_id = "laser_frame";
    CDLaser_msg.angle_min = f_angle_min;
    CDLaser_msg.angle_max = f_angle_max;
    CDLaser_msg.angle_increment = f_angle_increment;
    CDLaser_msg.time_increment = f_time_increment;
    CDLaser_msg.scan_time = f_scan_time;
    CDLaser_msg.range_min = f_range_min;
    CDLaser_msg.range_max = f_range_max;

    for (int z = 0 ; z<5; z++)
    {
      CDLaser_msg.ranges[z] = f_ranges[z];
    }

    for (int z = 0 ; z<5; z++)
    {
      CDLaser_msg.intensities[z] = f_intensities[z];
    }

    publisher_timer = millis() + 1000;
    pub_Laser.publish(&CDLaser_msg);
  }
  nh.spinOnce();
  delay(500);
}

I have fixed the array problem , However the program still stops after 22 cycles, the data transfer on the ROS side looks like

---
header: 
  seq: 22
  stamp: 
    secs: 1436325247
    nsecs: 107458902
  frame_id: laser_frame
angle_min: -1.57000005245
angle_max: 1.57000005245
angle_increment: 0.785000026226
time_increment: 10.0
scan_time: 4.0
range_min: 0.10000000149
range_max: 30.0
ranges: [0.0, 1.0, 2.0, 3.0, 4.0]
intensities: [0.0, 1.0, 4.0, 9.0, 16.0]
---

The loop portion of the program now looks like

void loop() 
{
  if (millis() > publisher_timer)
  {
    CDLaser_msg.header.stamp = nh.now();
    CDLaser_msg.header.frame_id = "laser_frame";
    CDLaser_msg.angle_min = f_angle_min;
    CDLaser_msg.angle_max = f_angle_max;
    CDLaser_msg.angle_increment = f_angle_increment;
    CDLaser_msg.time_increment = f_time_increment;
    CDLaser_msg.scan_time = f_scan_time;
    CDLaser_msg.range_min = f_range_min;
    CDLaser_msg.range_max = f_range_max;

    CDLaser_msg.ranges = &f_ranges[0];
    CDLaser_msg.intensities = &f_intensities[0];

    publisher_timer = millis() + 1000;
    pub_Laser.publish(&CDLaser_msg);
  }
  nh.spinOnce();
  delay(500);
}