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

Cannot read rosserial getParam()

asked 2016-07-06 06:09:26 -0500

Agju gravatar image

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-07-07 06:33:26 -0500

vmatos gravatar image

updated 2016-07-07 10:03:47 -0500

I just created a minimal example for rosserial_tivac : https://github.com/robosavvy/rosseria...

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/rosser...

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2016-07-06 06:09:26 -0500

Seen: 1,923 times

Last updated: Jul 07 '16