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

Add manual mower control actions in AreaRecording mode #162

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

olliewalsh
Copy link
Collaborator

Previously users would call mower_comms setMowEnabled directly to enable the mower while in AreaRecording mode.
However this should not have been possible since AreaRecording::mower_enabled() always returned false.

mower_logic now confirms that the mower state is as expected, so bypassing it in this way no longer works.

Add actions to toggle AreaRecording::mower_enabled() instead.

@olliewalsh olliewalsh marked this pull request as draft October 14, 2024 00:58
Previously users would call mower_comms setMowEnabled directly to enable the
mower while in AreaRecording mode.
However this should not have been possible since
AreaRecording::mower_enabled() always returned false.

mower_logic now confirms that the mower state is as expected,
so bypassing it in this way no longer works.

Add actions to toggle AreaRecording::mower_enabled() instead.
@olliewalsh olliewalsh marked this pull request as ready for review October 14, 2024 01:18
Use 22.04 for build, pre-commit action fails on latest
@Apehaenger
Copy link
Collaborator

Quite thanks for the PR!
mow_enabled was a quite useful service while developing as well during assembly.

Just fetched and compiled, but unfortunately does now work as I expected 😢 (removed GPS messages)

Oct 15 12:43:27 Maehlanie openmower_launch[995]: [ INFO] [1728989007.135884492]: --------------------------------------
Oct 15 12:43:27 Maehlanie openmower_launch[995]: [ INFO] [1728989007.136100108]: - Entered state: AREA_RECORDING
Oct 15 12:43:27 Maehlanie openmower_launch[995]: [ INFO] [1728989007.136308020]: --------------------------------------
Oct 15 12:43:27 Maehlanie openmower_launch[1006]: [ INFO] [1728989007.150932327]: new actions registered: mower_logic:area_recording registered 12 actions.
Oct 15 12:43:27 Maehlanie openmower_launch[995]: [ INFO] [1728989007.154198177]: successfully registered actions for mower_logic:area_recording
Oct 15 12:43:27 Maehlanie openmower_launch[995]: [ INFO] [1728989007.162463657]: Starting recording area
Oct 15 12:43:27 Maehlanie openmower_launch[995]: [ INFO] [1728989007.162636754]: Subscribing to /joy for user input
Oct 15 12:43:34 Maehlanie openmower_launch[949]: [ INFO] [1728989014.247301264]: Setting mow enabled to -1
Oct 15 12:43:34 Maehlanie openmower_launch[995]: [ WARN] [1728989014.412352229]: #### om_mower_logic: setMowerEnabled(0, 0) call
Oct 15 12:43:34 Maehlanie openmower_launch[949]: [ INFO] [1728989014.420841717]: Setting mow enabled to 0
Oct 15 12:43:34 Maehlanie openmower_launch[995]: [ INFO] [1728989014.421100944]: successfully set mower enabled to 0 (direction 0)
Oct 15 12:43:34 Maehlanie openmower_launch[995]: [ WARN] [1728989014.421219798]: #### om_mower_logic: setMowerEnabled(0, 0) call completed within 0.00889661s
Oct 15 12:44:00 Maehlanie openmower_launch[949]: [ INFO] [1728989040.887257250]: Setting mow enabled to 1
Oct 15 12:44:00 Maehlanie openmower_launch[995]: [ WARN] [1728989040.912349533]: #### om_mower_logic: setMowerEnabled(0, 0) call
Oct 15 12:44:00 Maehlanie openmower_launch[949]: [ INFO] [1728989040.920927709]: Setting mow enabled to 0
Oct 15 12:44:00 Maehlanie openmower_launch[995]: [ INFO] [1728989040.921320341]: successfully set mower enabled to 0 (direction 0)
Oct 15 12:44:00 Maehlanie openmower_launch[995]: [ WARN] [1728989040.921570231]: #### om_mower_logic: setMowerEnabled(0, 0) call completed within 0.00920594s
Oct 15 12:44:24 Maehlanie openmower_launch[949]: [ INFO] [1728989064.537098896]: Setting mow enabled to 0

@olliewalsh
Copy link
Collaborator Author

Quite thanks for the PR! mow_enabled was a quite useful service while developing as well during assembly.

Just fetched and compiled, but unfortunately does now work as I expected 😢 (removed GPS messages)

Are you expecting calling the mower_service/mow_enabled service to work? It will, but mower_logic will call it right after you do and turn it off again. Need to call the action from this patch to tell mower_logic to enable mowing instead e.g:
rostopic pub -1 /xbot/action std_msgs/String mower_logic:area_recording/start_manual_mowing

@Apehaenger
Copy link
Collaborator

Are you expecting calling the mower_service/mow_enabled service to work? It will, but mower_logic will call it right after you do and turn it off again.

Yip, had expected it 😇

Need to call the action from this patch to tell mower_logic to enable mowing instead e.g: rostopic pub -1 /xbot/action std_msgs/String mower_logic:area_recording/start_manual_mowing

Quite thanks for the command, did not know that before 🤫 and now after checking the sources, I do see.
However, unfortunately does not work as (I) expected.
Mow motor start sometimes for a couple of seconds and then stops again. If it doesn't start on first try, I also wasn't able to start it even with multiple tries.

Is it expected to call the command with a rate i.e. rostopic pub -r 10 ...?

Now, the danger part: When failed to start, exited area-recording and went back to area-recording. That immediately started the mow motor again. This is somehow dangerous when used during assembling 😱
So better set manual_mowing = false; when leaving area-recording?

@olliewalsh
Copy link
Collaborator Author

Mow motor start sometimes for a couple of seconds and then stops again. If it doesn't start on first try, I also wasn't able to start it even with multiple tries.

Safety checks in mower_logic still apply, so if GPS drops I expect it will stop the mower, which might explain this - https://github.com/ClemensElflein/open_mower_ros/blob/main/src/mower_logic/src/mower_logic/mower_logic.cpp#L491

Also may need to keep the mower moving or mower_comms check will stop the mower https://github.com/ClemensElflein/open_mower_ros/blob/main/src/mower_comms/src/mower_comms.cpp#L114

If we want to allow mowing with bad/no GPS might need to create a new behavior class instead of using AreaRecording

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.

2 participants