Skip to content

Commit 91772e0

Browse files
authored
Fix/Feature: Valence Battery Update/Fix (#227) (#278)
* Only add battery estimator when no battery driver * Update valence arguments * Fix valence launch filename * Remove duplicate definition * Add robot namespace argument
1 parent 30e1095 commit 91772e0

File tree

1 file changed

+16
-14
lines changed
  • clearpath_generator_robot/clearpath_generator_robot/launch

1 file changed

+16
-14
lines changed

clearpath_generator_robot/clearpath_generator_robot/launch/generator.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -261,27 +261,25 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
261261
if (self.clearpath_config.platform.battery.model in
262262
[BatteryConfig.VALENCE_U24_12XP, BatteryConfig.VALENCE_U27_12XP]):
263263

264-
can_dev = 'can1'
265-
bms_id = '0'
266-
267264
launch_args = self.clearpath_config.platform.battery.launch_args
268265

269-
if launch_args:
270-
if 'can_device' in launch_args:
271-
can_dev = launch_args['can_device']
272-
if 'bms_id' in launch_args:
273-
bms_id = launch_args['bms_id']
274-
275-
bms_launch_args = [
276-
('namespace', self.namespace),
277-
('can_device', can_dev),
278-
('bms_id', bms_id),
266+
valence_launch_args = [
267+
('robot_namespace', self.namespace),
268+
('namespace', f'{self.namespace}/platform/bms'),
269+
('interface', 'can1'),
270+
('bms_id', '0')
279271
]
280272

273+
for i in range(len(valence_launch_args)):
274+
key = valence_launch_args[i][0]
275+
if key in launch_args:
276+
val = launch_args[key]
277+
valence_launch_args[i] = (key, str(val))
278+
281279
self.bms_launch_file = LaunchFile(
282280
'bms',
283281
package=Package('valence_bms_driver'),
284-
args=bms_launch_args
282+
args=valence_launch_args
285283
)
286284
# Inventus BMS
287285
elif (self.clearpath_config.platform.battery.model in
@@ -461,6 +459,10 @@ def __init__(self, setup_path: str = '/etc/clearpath/') -> None:
461459
):
462460
common_platform_components.append(self.base_station_node)
463461

462+
# Only add estimator when no BMS is present
463+
if self.bms_launch_file is None:
464+
common_platform_components.append(self.battery_state_estimator)
465+
464466
if len(self.can_bridges) > 0:
465467
common_platform_components.extend(self.can_bridges)
466468

0 commit comments

Comments
 (0)