ros::NodeHandle::getParam causing error when CORE2 is flashed

Hello,

I am trying to pass some parameters to my serial node through the following node definition:

    <node pkg="rosbot-maze-navigator" type="serial_bridge.sh" name="bridge" output="screen">
        <param name="base_frame" value="$(arg BASE_FRAME)"/>
        <param name="odom_frame" value="$(arg ODOM_FRAME)"/>
        <param name="odometry_reset_topic" value="$(arg ODOMETRY_RESET_TOPIC)"/>
        <param name="pose_topic" value="$(arg POSE_TOPIC)"/>
        <param name="baudrate" value="$(arg SERIAL_BAUDRATE)"/>
        <param name="spin_rate" value="$(arg SERIAL_SPINRATE)"/>
    </node>

To be able to access these parameters from the node, I am using the following method:

char *base_frame;
[...]
node_handle.getParam("base_frame", &base_frame);

The code successfully gets built & CORE2 gets flashed. However, with the following warning:

C:/Users/erinc/.vscode/extensions/husarion.husarion-1.5.28/sdk/include/hROS/ros/node_handle.h: In instantiation of 'bool ros::NodeHandle_<Hardware, MAX_SUBSCRIBERS, MAX_PUBLISHERS, INPUT_SIZE, OUTPUT_SIZE>::getParam(const char*, char**, int) [with Hardware = hROSHardware; int MAX_SUBSCRIBERS = 25; int MAX_PUBLISHERS = 25; int INPUT_SIZE = 512; int OUTPUT_SIZE = 512]':
D:\Projects\rosbot-labyrinth\main.cpp:77:51:   required from here
C:/Users/erinc/.vscode/extensions/husarion.husarion-1.5.28/sdk/include/hROS/ros/node_handle.h:530:22: warning: comparison between
signed and unsigned integer expressions [-Wsign-compare]
           if (length == req_param_resp.strings_length){
                      ^

I don’t think this warning causes the problem, but the LEDs start to flash when I flash CORE2 with the mentioned code.

What can be wrong with this call? Is there a correct way to access serial node parameters?

Thanks,
Erinc

Hello Erinc,

There are some steps to set parameter on CORE2, first parameter for CORE2 sholud be set globally, outside of node scope:

  <param name="base_frame" value="$(arg BASE_FRAME)"/>
  <param name="odom_frame" value="$(arg ODOM_FRAME)"/>
  <param name="odometry_reset_topic" value="$(arg ODOMETRY_RESET_TOPIC)"/>
  <param name="pose_topic" value="$(arg POSE_TOPIC)"/>
  <param name="spin_rate" value="$(arg SERIAL_SPINRATE)"/>

  <node pkg="rosbot-maze-navigator" type="serial_bridge.sh" name="bridge" output="screen">    
      <param name="baudrate" value="$(arg SERIAL_BAUDRATE)"/>
  </node>

Then to retrieve parameters:

float paramter[1];
// wait until node is connected
while (!nh.connected())
{
	nh.spinOnce();
}

// retrieve params
if (!nh.getParam("param_name", parameter, 1))
{
	//default values
	parameter[0] = 1;
}

You can find more details regarding parameters in rosserial documentation

Regards,
Łukasz

1 Like