Skip to content

Commit

Permalink
✨ add battery_constraint_value param
Browse files Browse the repository at this point in the history
  • Loading branch information
Rezenders committed Mar 21, 2024
1 parent 01dc3b9 commit dc1a97d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 13 additions & 1 deletion suave_missions/launch/mission.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def generate_launch_description():
mission_type = LaunchConfiguration('mission_type')
result_filename = LaunchConfiguration('result_filename')
battery_constraint = LaunchConfiguration('battery_constraint')
battery_constraint_value = LaunchConfiguration('battery_constraint_value')

adaptation_manager_arg = DeclareLaunchArgument(
'adaptation_manager',
Expand Down Expand Up @@ -44,6 +45,11 @@ def generate_launch_description():
description='Desired battery functionality' +
'[True or False]'
)
battery_constraint_value_arg = DeclareLaunchArgument(
'battery_constraint_value',
default_value='0.2',
description='battery constraint value'
)

pkg_suave_path = get_package_share_directory(
'suave_missions')
Expand Down Expand Up @@ -81,7 +87,12 @@ def generate_launch_description():
package='suave_missions',
executable=mission_type,
name='mission_node',
parameters=[mission_config, {'battery_constraint': battery_constraint}],
parameters=[
mission_config,
{
'battery_constraint': battery_constraint,
'battery_constraint_value': battery_constraint_value,
}],
)

pkg_suave_path = get_package_share_directory('suave')
Expand Down Expand Up @@ -123,6 +134,7 @@ def generate_launch_description():
mission_type_arg,
result_filename_arg,
battery_constraint_arg,
battery_constraint_value_arg,
mission_metrics_node,
mission_metrics_node_override,
mission_node,
Expand Down
12 changes: 8 additions & 4 deletions suave_missions/suave_missions/inspection_mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def __init__(self, node_name='inspection_mission'):
callback_group=MutuallyExclusiveCallbackGroup()
)

self.declare_parameter('battery_constraint', False)

self.declare_parameter('battery_constraint', False)
self.declare_parameter('battery_constraint_value', 0.2)

def perform_mission(self):
self.get_logger().info("Pipeline inspection mission starting!!")
self.timer = self.create_rate(1)
Expand Down Expand Up @@ -86,8 +87,11 @@ def battery_level_cb(self, msg):
if status.message == 'QA status':
for value in status.values:
if value.key == 'battery_level':
if float(value.value) < 0.05:
self.get_logger().warn("low battery! Mission abort.")
constraint = self.get_parameter(
'battery_constraint_value').value
if float(value.value) < constraint:
self.get_logger().warn(
"Low battery! Mission abort.")
self.abort_mission = True
self.call_service(
self.save_mission_results_cli, Empty.Request()
Expand Down

0 comments on commit dc1a97d

Please sign in to comment.