Skip to content

Commit 1c04d62

Browse files
cesar-lopez-marjacobperronchristophebedard
authored
Fix/galactic/load parameters (#692)
* Fix runtime exception thrown when parameter override not provided (#675) The templated declare_parameter method needs an override (or default value) since it returns the actual parameter value, otherwise we get an exception. To correctly declare a parameter without a default value, we should use a different signature. Related upstream issue: ros2/rclcpp#1691 Signed-off-by: Jacob Perron <[email protected]> * Fix different time sources error (#679) Signed-off-by: Christophe Bedard <[email protected]> Co-authored-by: Jacob Perron <[email protected]> Co-authored-by: Christophe Bedard <[email protected]>
1 parent 46e035f commit 1c04d62

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/filter_base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace robot_localization
4747
FilterBase::FilterBase()
4848
: initialized_(false), use_control_(false),
4949
use_dynamic_process_noise_covariance_(false), control_timeout_(0, 0u),
50-
last_measurement_time_(0, 0, RCL_ROS_TIME), latest_control_time_(0),
50+
last_measurement_time_(0, 0, RCL_ROS_TIME), latest_control_time_(0, 0, RCL_ROS_TIME),
5151
sensor_timeout_(0, 0u), debug_stream_(nullptr),
5252
acceleration_gains_(TWIST_SIZE, 0.0),
5353
acceleration_limits_(TWIST_SIZE, 0.0),

src/ros_filter.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void RosFilter<T>::loadParams()
819819
// Try to resolve tf_prefix
820820
std::string tf_prefix = "";
821821
std::string tf_prefix_path = "";
822-
this->declare_parameter<std::string>("tf_prefix");
822+
this->declare_parameter("tf_prefix", rclcpp::PARAMETER_STRING);
823823
if (this->get_parameter("tf_prefix", tf_prefix_path)) {
824824
// Append the tf prefix in a tf2-friendly manner
825825
filter_utilities::appendPrefix(tf_prefix, map_frame_id_);
@@ -887,7 +887,7 @@ void RosFilter<T>::loadParams()
887887
control_timeout = this->declare_parameter("control_timeout", 0.0);
888888

889889
if (use_control_) {
890-
this->declare_parameter<std::vector<bool>>("control_config");
890+
this->declare_parameter("control_config", rclcpp::PARAMETER_BOOL_ARRAY);
891891
if (this->get_parameter("control_config", control_update_vector)) {
892892
if (control_update_vector.size() != TWIST_SIZE) {
893893
std::cerr << "Control configuration must be of size " << TWIST_SIZE <<
@@ -903,7 +903,7 @@ void RosFilter<T>::loadParams()
903903
use_control_ = false;
904904
}
905905

906-
this->declare_parameter<std::vector<double>>("acceleration_limits");
906+
this->declare_parameter("acceleration_limits", rclcpp::PARAMETER_DOUBLE_ARRAY);
907907
if (this->get_parameter("acceleration_limits", acceleration_limits)) {
908908
if (acceleration_limits.size() != TWIST_SIZE) {
909909
std::cerr << "Acceleration configuration must be of size " << TWIST_SIZE <<
@@ -919,7 +919,7 @@ void RosFilter<T>::loadParams()
919919
acceleration_limits.resize(TWIST_SIZE, 1.0);
920920
}
921921

922-
this->declare_parameter<std::vector<double>>("acceleration_gains");
922+
this->declare_parameter("acceleration_gains", rclcpp::PARAMETER_DOUBLE_ARRAY);
923923
if (this->get_parameter("acceleration_gains", acceleration_gains)) {
924924
const int size = acceleration_gains.size();
925925
if (size != TWIST_SIZE) {
@@ -933,7 +933,7 @@ void RosFilter<T>::loadParams()
933933
}
934934
}
935935

936-
this->declare_parameter<std::vector<double>>("deceleration_limits");
936+
this->declare_parameter("deceleration_limits", rclcpp::PARAMETER_DOUBLE_ARRAY);
937937
if (this->get_parameter("deceleration_limits", deceleration_limits)) {
938938
if (deceleration_limits.size() != TWIST_SIZE) {
939939
std::cerr << "Deceleration configuration must be of size " << TWIST_SIZE <<
@@ -949,7 +949,7 @@ void RosFilter<T>::loadParams()
949949
deceleration_limits = acceleration_limits;
950950
}
951951

952-
this->declare_parameter<std::vector<double>>("deceleration_gains");
952+
this->declare_parameter("deceleration_gains", rclcpp::PARAMETER_DOUBLE_ARRAY);
953953
if (this->get_parameter("deceleration_gains", deceleration_gains)) {
954954
const int size = deceleration_gains.size();
955955
if (size != TWIST_SIZE) {
@@ -981,7 +981,7 @@ void RosFilter<T>::loadParams()
981981
dynamic_process_noise_covariance);
982982

983983
std::vector<double> initial_state;
984-
this->declare_parameter<std::vector<double>>("initial_state");
984+
this->declare_parameter("initial_state", rclcpp::PARAMETER_DOUBLE_ARRAY);
985985
if (this->get_parameter("initial_state", initial_state)) {
986986
if (initial_state.size() != STATE_SIZE) {
987987
std::cerr << "Initial state must be of size " << STATE_SIZE <<
@@ -1070,7 +1070,7 @@ void RosFilter<T>::loadParams()
10701070
ss << "odom" << topic_ind++;
10711071
std::string odom_topic_name = ss.str();
10721072
std::string odom_topic;
1073-
this->declare_parameter<std::string>(odom_topic_name);
1073+
this->declare_parameter(odom_topic_name, rclcpp::PARAMETER_STRING);
10741074

10751075
rclcpp::Parameter parameter;
10761076
if (this->get_parameter(odom_topic_name, parameter)) {
@@ -1220,7 +1220,7 @@ void RosFilter<T>::loadParams()
12201220
ss << "pose" << topic_ind++;
12211221
std::string pose_topic_name = ss.str();
12221222
std::string pose_topic;
1223-
this->declare_parameter<std::string>(pose_topic_name);
1223+
this->declare_parameter(pose_topic_name, rclcpp::PARAMETER_STRING);
12241224

12251225
rclcpp::Parameter parameter;
12261226
if (this->get_parameter(pose_topic_name, parameter)) {
@@ -1337,7 +1337,7 @@ void RosFilter<T>::loadParams()
13371337
ss << "twist" << topic_ind++;
13381338
std::string twist_topic_name = ss.str();
13391339
std::string twist_topic;
1340-
this->declare_parameter<std::string>(twist_topic_name);
1340+
this->declare_parameter(twist_topic_name, rclcpp::PARAMETER_STRING);
13411341

13421342
rclcpp::Parameter parameter;
13431343
if (this->get_parameter(twist_topic_name, parameter)) {
@@ -1418,7 +1418,7 @@ void RosFilter<T>::loadParams()
14181418
ss << "imu" << topic_ind++;
14191419
std::string imu_topic_name = ss.str();
14201420
std::string imu_topic;
1421-
this->declare_parameter<std::string>(imu_topic_name);
1421+
this->declare_parameter(imu_topic_name, rclcpp::PARAMETER_STRING);
14221422

14231423
rclcpp::Parameter parameter;
14241424
if (this->get_parameter(imu_topic_name, parameter)) {
@@ -1727,7 +1727,7 @@ void RosFilter<T>::loadParams()
17271727
process_noise_covariance.setZero();
17281728
std::vector<double> process_noise_covar_flat;
17291729

1730-
this->declare_parameter<std::vector<double>>("process_noise_covariance");
1730+
this->declare_parameter("process_noise_covariance", rclcpp::PARAMETER_DOUBLE_ARRAY);
17311731
if (this->get_parameter(
17321732
"process_noise_covariance",
17331733
process_noise_covar_flat))
@@ -1754,7 +1754,7 @@ void RosFilter<T>::loadParams()
17541754
initial_estimate_error_covariance.setZero();
17551755
std::vector<double> estimate_error_covar_flat;
17561756

1757-
this->declare_parameter<std::vector<double>>("initial_estimate_covariance");
1757+
this->declare_parameter("initial_estimate_covariance", rclcpp::PARAMETER_DOUBLE_ARRAY);
17581758
if (this->get_parameter(
17591759
"initial_estimate_covariance",
17601760
estimate_error_covar_flat))

0 commit comments

Comments
 (0)