Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[ROS2] How to check for incoming param type?

If I receive a parameter update and want to check if its the correct type, how could I do this?
Because if I set a param over cmd line and write 1 instead of 1.0, no exception is thrown when receiving the param with false type.

void handleChangedParameters( const rcl_interfaces::msg::ParameterEvent::SharedPtr& event )
   {
      for ( auto& changed_parameter : event->changed_parameters )
      {
         auto paramName = changed_parameter.name;
         if ( paramName == controllerFrequency )
         {
            log_info(" is integer: {}", changed_parameter.value. == XXX  ? "true" : "false" )
            updateFrequencyParam( changed_parameter.value.integer_value );
         }
      }
   }