Robotics StackExchange | Archived questions

Cannot read rosserial getParam()

Hi all. I'm trying to implement an Arduino sketch using a Mega2560 which sub/pub data to a RPi 3 with ROS Indigo compiled from source. Everything goes well and without any error.

I'm now trying to update the code, so all the parameters that the Arduino use (PID values, constants, etc.) are catched from the parameter server, configured from the launch file that starts everything. The problem is that altough I can see the parameters with "rosparam list" and "rosparam get", I am not able to read them using the Arduino Mega2560.

The code I use is:

void getParameters()
{
  float pid_left[3];
  float pid_right[3];
  float wheel_radius;
  float wheel_distance;
  int axes_distance;
  nh.getParam("~pid_left", pid_left, 3);
  nh.getParam("~pid_right", pid_right, 3);
  nh.getParam("~wheel_radius", &wheel_radius);
  nh.getParam("~wheel_distance", &wheel_distance);
  nh.getParam("~axes_distance", &axes_distance);
  for (int i = 0; i < 6; i++)
  {
    parameters.float_data[i] = pid_left[i];
    parameters.float_data[i + 3] = pid_right[i];
  }
  parameters.float_data[6] = wheel_radius;
  parameters.float_data[7] = wheel_distance;
  parameters.float_data[8] = axes_distance;
}

void startRos()
{
  nh.getHardware()->setBaud(57600);
  nh.initNode();
  while (!nh.connected())
  {
    nh.spinOnce();
  }
  delay(10);
  getParameters();
}

(I've deleted the default values part for readiness). And the output in the console is:

[ INFO] [1467801488.320667825]: Opening serial port.
[ INFO] [1467801488.321997921]: Starting session.
[INFO] [WallTime: 1467801488.713206] rosserial message_info_service node
[ WARN] [1467801489.323139261]: Sync with device lost.
[ WARN] [1467801490.324296609]: Sync with device lost.
[ INFO] [1467801490.327060089]: Attached client is using protocol VER2 (hydro)
[INFO] [WallTime: 1467801490.350732] Loading module to return info on std_msgs/Float32MultiArray.
[ WARN] [1467801490.352954118]: Received message with unrecognized topicId (6).
[ WARN] [1467801491.355344863]: Received message with unrecognized topicId (6).
[ WARN] [1467801492.362921960]: Received message with unrecognized topicId (6).
[ WARN] [1467801493.366514158]: Received message with unrecognized topicId (6).
[ WARN] [1467801493.366514158]: Received message with unrecognized topicId (6).

I have tried to add a timeout in the readings, making a loop and trying to read each parameter 10 times, but it always ends with the default value, and with that [WARN] appearing.

What I'm doing wrong?

Thanks

Asked by Agju on 2016-07-06 06:09:26 UTC

Comments

Answers

I just created a minimal example for rosserial_tivac: https://github.com/robosavvy/rosserial_tivac_tutorials/tree/master/getparam

Indeed it fails to get the parameter using rosserial_server's serial_node. However it seems to work with rosserial_python's serial_node.py.

rosserial_python:

rosrun rosserial_python serial_node.py _port:=/dev/ttyACM0
[INFO] [WallTime: 1467891171.957798] ROS Serial Python Node
[INFO] [WallTime: 1467891171.970288] Connecting to /dev/ttyACM0 at 57600 baud
[INFO] [WallTime: 1467891174.101582] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1467891174.102729] Setup publisher on param [std_msgs/Float32]

rosserial_server:

rosrun rosserial_server serial_node _my_param=1.0
[ INFO] [1467891309.190024440]: Opening serial port.
[ INFO] [1467891309.190750509]: Starting session.
[ INFO] [1467891309.192754634]: Attached client is using protocol VER2 (hydro)
[ INFO] [1467891309.213501578]: waitForService: Service [/message_info] has not been advertised, waiting...
[ WARN] [1467891331.743387558]: Failed to call message_info service. Proceeding without full message definition.
[ WARN] [1467891331.743583542]: Advertising on topic [/param] with an empty message definition.  Some tools (e.g. rosbag) may not work correctly.
[ WARN] [1467891331.744745683]: Received message with unrecognized topicId (6).

Edit: Ticket here: https://github.com/ros-drivers/rosserial/issues/229

Asked by vmatos on 2016-07-07 06:33:26 UTC

Comments