Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System modes inference #50

Merged
merged 4 commits into from
Sep 30, 2020
Merged

System modes inference #50

merged 4 commits into from
Sep 30, 2020

Conversation

jginesclavero
Copy link
Contributor

System modes inference

Please, accept first my previous PR #48

This PR adds the rules to the pilot_modes to support the inference and adaptation of the system_modes:

  • I have tested adaptation of the system_modes in case of laser failure.

  • I have modified the dummy metacontroller to read the logs of the battery and change the mode to ENERGY_SAVING.

Future works

  • Modify the dummy metacontroller to take Diagnostics msgs instead of logs.

@@ -35,6 +36,7 @@ class LaserResender : public rclcpp_lifecycle::LifecycleNode
LaserResender()
: rclcpp_lifecycle::LifecycleNode("laser_resender")
{
declare_parameter("node_name");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intention of this node_name here? Could be a better id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following the Arne suggestions in micro-ROS/system_modes#45 (comment) I have defined a fake parameter.

Currently, there has to be a parameter, because otherwise the mode is invisible from the outside and can't be inferred in any way.

You may want to introduce a simple fake parameter, that is a bool for example or - to make it a bit easier to understand - a string parameter that holds the name of the mode. We stumbled upon this question before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

laser_resender/src/laser_resender_node.cpp Show resolved Hide resolved
mros_contingencies_sim/package.xml Show resolved Hide resolved
cli = self.create_client(ChangeMode, '/'+node_name+'/change_mode')
while not cli.wait_for_service(timeout_sec=1.0):
print('service not available, waiting again...')
req = ChangeMode.Request()
req.node_name = node_name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes an error with newer versions of system_modes:

ros2 run metacontroller_pilot metacontroller
Traceback (most recent call last):
  File "/home/parallels/pilot_urjc_ws/install/metacontroller_pilot/lib/metacontroller_pilot/metacontroller", line 11, in <module>
    load_entry_point('metacontroller-pilot', 'console_scripts', 'metacontroller')()
  File "/home/parallels/pilot_urjc_ws/build/metacontroller_pilot/metacontroller_pilot/metacontroller_sim.py", line 67, in main
    node.change_mode("pilot", '__DEFAULT__')
  File "/home/parallels/pilot_urjc_ws/build/metacontroller_pilot/metacontroller_pilot/metacontroller_sim.py", line 47, in change_mode
    req.node_name = node_name
AttributeError: 'ChangeMode_Request' object has no attribute 'node_name'

See micro-ROS/system_modes#24

Suggested change
req.node_name = node_name

Copy link
Contributor Author

@jginesclavero jginesclavero Sep 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using the feature/rules branch, and this field is necessary. I have changed the dependencies.repos file to download this branch instead of master

@jginesclavero
Copy link
Contributor Author

I have added the changes to solve these issues in #51

@fmrico fmrico merged commit edb72c4 into master Sep 30, 2020
@jginesclavero jginesclavero deleted the system-modes-inference branch October 7, 2020 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants