Skip to content

Commit e252a51

Browse files
author
Yara Shahin
committed
fix compatibility errors
1 parent 968fe0f commit e252a51

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

battery_state_broadcaster/src/battery_state_broadcaster.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,21 @@ controller_interface::CallbackReturn BatteryStateBroadcaster::on_activate(
225225
return controller_interface::CallbackReturn::FAILURE;
226226
}
227227

228-
param_listener_->refresh_dynamic_parameters();
229-
230228
// get parameters from the listener in case they were updated
229+
param_listener_->refresh_dynamic_parameters();
231230
params_ = param_listener_->get_params();
232-
auto combined_power_supply_technology = static_cast<uint8_t>(
233-
params_.state_joints_map.at(params_.state_joints.at(0)).power_supply_technology);
231+
232+
uint8_t combined_power_supply_technology;
233+
if (!params_.sensor_name.empty())
234+
{
235+
sums_.design_capacity_sum = static_cast<float>(params_.design_capacity);
236+
combined_power_supply_technology = static_cast<uint8_t>(params_.power_supply_technology);
237+
}
238+
else
239+
{
240+
combined_power_supply_technology = static_cast<uint8_t>(
241+
params_.state_joints_map.at(params_.state_joints.at(0)).power_supply_technology);
242+
}
234243
std::string combined_location = "";
235244
std::string combined_serial_number = "";
236245

@@ -268,12 +277,6 @@ controller_interface::CallbackReturn BatteryStateBroadcaster::on_activate(
268277
combined_serial_number += battery_state.serial_number + ", ";
269278
}
270279

271-
if (!params_.sensor_name.empty())
272-
{
273-
sums_.design_capacity_sum = static_cast<float>(params_.design_capacity);
274-
combined_power_supply_technology = static_cast<uint8_t>(params_.power_supply_technology);
275-
}
276-
277280
// handle aggregate battery state initialization
278281
auto & battery_state_msg = battery_state_realtime_publisher_->msg_;
279282

battery_state_broadcaster/src/battery_state_broadcaster.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ battery_state_broadcaster:
1717
type: string_array,
1818
description: "List of joints from which battery state interfaces will be read.",
1919
read_only: true,
20+
default_value: [],
2021
validation: {
2122
unique<>: null
2223
}

0 commit comments

Comments
 (0)