robosoft-ai / SMACC2

An Event-Driven, Asynchronous, Behavioral State Machine Library for ROS2 (Robotic Operating System) applications written in C++
https://smacc.dev
Apache License 2.0
223 stars 36 forks source link

exception at init when passing a signal_detector_loop_freq parameter #514

Closed NicolasM0 closed 1 year ago

NicolasM0 commented 1 year ago

issue My state machine was working fine on foxy. I am migrating to humble and I get an error while launching my node: I cannot define a custom signal_detector_loop_frequency.

ros2 run bird_sm bird_sm_node --ros-args -p signal_detector_loop_freq:=100.0

[INFO] [1686669908.812311630] [BirdSm]: Creating State Machine Base: /BirdSm
terminate called after throwing an instance of 'rclcpp::exceptions::ParameterAlreadyDeclaredException'
  what():  parameter 'signal_detector_loop_freq' has already been declared
[ros2run]: Aborted

proposal I fixed that issue by testing the parameter before the declaration. I don't know if this is a good way to do it and if this is a behavior change between foxy and humble or if I missed something.

tests

ros2 run bird_sm bird_sm_node --ros-args -p signal_detector_loop_freq:=100.0 --> Works fine with the desired frequency

ros2 run bird_sm bird_sm_node --> Works with the default frequency 20Hz

ros2 run bird_sm bird_sm_node --ros-args -p signal_detector_loop_freq:=100 return an error but this is expected:

*[INFO] [1686665345.603937129] [BirdSm]: Creating State Machine Base: /BirdSm
terminate called after throwing an instance of 'rclcpp::exceptions::InvalidParameterTypeException'
  what():  parameter 'signal_detector_loop_freq' has invalid type: expected [double] got [integer]
[ros2run]: Aborted

┆Issue is synchronized with this Jira Task by Unito

pabloinigoblasco commented 1 year ago

Hello. I tried to recreate your problem with sm_atomic. I tested in both, latest source humble commit and also from ros-humble-smacc2 binary repo package.

Both cases work. Please try testing your command above with sm_atomic.

ros2 run sm_atomic sm_atomic_node --ros-args -p signal_detector_loop_freq:=100.0