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