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

Enlargeable Config Packet #110

Merged

Conversation

Apehaenger
Copy link
Contributor

@Apehaenger Apehaenger commented Oct 7, 2024

Roadmap:

  • Decide for flexible config packet and struct
  • LowLevel (OpenMower Pico-FW)
    • Implement packet handling
    • config save in flash via LittleFS (rovo89) 😍
    • Implement config value handling
      • Charge & Battery
      • Hall sensor inputs
      • Emergency handling
      • Ignore_charging_current
      • Misc (ignore charging current, ...)
  • HighLevel (open_mower_ros) please see Enlargable Config Packet open_mower_ros#163
  • Test with old HL-FW
    🔨 = Currently working on

Test:

Each side (LowLevel-Pico / HighLevel-Raspi) should be upgrade-able without any compatibility issues.
But for getting the new configuration possibilities, both sides need to be updated.

LowLevel (Pico)

Firmware can be found within Actions.
Select the newest Enlargeable Config Packet workflow. Even if it has a red cross in front, it should contain the open-mower-pico-firmware package within the "Atrifacts" section (scroll down).

HighLevel (Raspi)

Docker image can be pulled via sudo podman pull ghcr.io/clemenselflein/open_mower_ros:pr-163
(don't forget to change your /boot/openmower/openmower_version.txt to 'pr-163')

Configuration workflow

Once HighLevel is up and detect a running LowLevel, it will send a "configuration wish-list" to LowLevel like:

Oct 30 17:37:08 Dolly openmower_launch[17587]: [ INFO] [1730306228.494246883]: Send ll_high_level_config packet 0x11
Oct 30 17:37:08 Dolly openmower_launch[17587]:          options{dfp_is_5v=0, background_sounds=0, ignore_charging_current=0},
Oct 30 17:37:08 Dolly openmower_launch[17587]:          v_charge_cutoff=-1.000000, i_charge_cutoff=-1.000000,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          v_battery_cutoff=-1.000000, v_battery_empty=24.000000, v_battery_full=28.000000,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          lift_period=65535, tilt_period=65535,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          shutdown_esc_max_pitch=255,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          language="en", volume=255
Oct 30 17:37:08 Dolly openmower_launch[17587]:          hall_configs="U, U, U, U, U, U, U, U, U, U"

LowLevel receive this "config packet", aligns it with his defaults values as well as his known hardware limits and answer with a config-response-packet containing the applied, adapted or default values, like:

Oct 30 17:37:08 Dolly openmower_launch[17587]: [ INFO] [1730306228.505676744]: Received ll_high_level_config packet 0x12
Oct 30 17:37:08 Dolly openmower_launch[17587]:          options{dfp_is_5v=0, background_sounds=0, ignore_charging_current=0},
Oct 30 17:37:08 Dolly openmower_launch[17587]:          v_charge_cutoff=30.000000, i_charge_cutoff=1.500000,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          v_battery_cutoff=29.000000, v_battery_empty=24.000000, v_battery_full=28.000000,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          lift_period=100, tilt_period=2500,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          shutdown_esc_max_pitch=0,
Oct 30 17:37:08 Dolly openmower_launch[17587]:          language="en", volume=80
Oct 30 17:37:08 Dolly openmower_launch[17587]:          hall_configs="!L, !L, !S, !S, I, I, I, I, I, I"

Configuration

Please check the sample config file regarding the possible new parameters, like Battery & Charge, Hall/Emergency or Ignore Charging Current.

@Apehaenger Apehaenger changed the title Config Packet Trailer Enlargeable Config Packet Oct 10, 2024
Firmware/LowLevel/include/debug.h Outdated Show resolved Hide resolved
Firmware/LowLevel/include/debug.h Outdated Show resolved Hide resolved
Firmware/LowLevel/include/debug.h Outdated Show resolved Hide resolved
Firmware/LowLevel/src/datatypes.h Outdated Show resolved Hide resolved
Firmware/LowLevel/include/config.h Outdated Show resolved Hide resolved
Firmware/LowLevel/src/datatypes.h Outdated Show resolved Hide resolved
Firmware/LowLevel/src/datatypes.h Outdated Show resolved Hide resolved
@rovo89
Copy link
Contributor

rovo89 commented Oct 12, 2024

Seems like you're not using anything from debug.h now, except the initialization. 🤔

@rovo89
Copy link
Contributor

rovo89 commented Oct 12, 2024

IGNORE_CHARGING_CURRENT could also become a setting I guess. Maybe we can have only a single build in the future?

@rovo89
Copy link
Contributor

rovo89 commented Oct 12, 2024

Seems like you're not using anything from debug.h now, except the initialization. 🤔

Ah, in main.cpp, there are many places with #ifdef USB_DEBUG DEBUG_SERIAL.println(...). Did you mean to replace those? But that would be unrelated to this PR. So in the interest of keeping this PR focused on the extended config, I'd suggest to undo the DEBUG_BEGIN change and remove debug.h. If you feel that it simplifies stuff, it can be introduced in another PR.

@Apehaenger
Copy link
Contributor Author

Seems like you're not using anything from debug.h now, except the initialization. 🤔

No, not anymore, since you deleted nv_config :-)

IGNORE_CHARGING_CURRENT could also become a setting I guess. Maybe we can have only a single build in the future?

I already had that discussion in a similar way a couple of weeks ago. I liked to move it to checkShouldCharge() and don't check for the current, but got stopped with something like "better no values" than "wrong values" (even if the relevant ppl know their hardware failure)... But wait... or do you mean those could configure/send i_charge_cutoff = 0 and we disable the cutoff logic based on the current?
No, I wouldn't do that. All ppl. could disable the charge logic by this. Yes, all people can also flash *_IGNORE_CHARGE_CURRENT, that's true 🤔 . Please ask @ClemensElflein for this, I wouldn't do that, simply because the name kindly sound dangerous and the normal healthy use will not install that version.

Seems like you're not using anything from debug.h now, except the initialization. 🤔

Ah, in main.cpp, there are many places with #ifdef USB_DEBUG DEBUG_SERIAL.println(...). Did you mean to replace those? But that would be unrelated to this PR. So in the interest of keeping this PR focused on the extended config, I'd suggest to undo the DEBUG_BEGIN change and remove debug.h. If you feel that it simplifies stuff, it can be introduced in another PR.

Will do with the next commit ;-)

@rovo89
Copy link
Contributor

rovo89 commented Oct 12, 2024

But wait... or do you mean those could configure/send i_charge_cutoff = 0 and we disable the cutoff logic based on the current?

I hadn't checked in much detail - just thought that we could try and reduce the number of build variants. 😉

IIUC, IGNORE_CHARGING_CURRENT acts as if the charging current sensor always reported -1.0A. That affects the value reported to ROS, the status LED, but also checkShouldCharge(). Since -1.0 will be lower than any configured i_charge_cutoff, this will never prevent charging.

I have no personal interest here. Again, I'm just looking at how this PR can be utilized, and since you asked for more settings, that was one that came to my mind. (Another one would be settings for for #97, but since that isn't merged yet, we can also add them there.)

From risk perspective, I guess it's no different from setting i_charge_cutoff to a huge value (or even Inf)?!? Except that IGNORE_CHARGING_CURRENT also makes sure that no random values are sent to ROS, which might be confusing in the UI. I think that was the "better no values than wrong values" part.

@Apehaenger
Copy link
Contributor Author

I have no personal interest here. Again, I'm just looking at how this PR can be utilized, and since you asked for more settings, that was one that came to my mind. (Another one would be settings for for #97, but since that isn't merged yet, we can also add them there.)

Fully clear and I'm grateful for getting such a detailed review and good hints!!
Regarding #97: Now that we try to have nothing unrelated in this PR, lets go on this way, even if it would be more clever to add SHUTDOWN_ESC_MAX_PITCH now, because the one who add that, has also to decide for the num of hall spares :-/

From risk perspective, I guess it's no different from setting i_charge_cutoff to a huge value (or even Inf)?!? Except that IGNORE_CHARGING_CURRENT also makes sure that no random values are sent to ROS, which might be confusing in the UI. I think that was the "better no values than wrong values" part.

Yes, and that time, my reasoning for moving the IGNORE implementation to checkShouldCharge() was the opposite, because a couple of ppl. use this IGNORE thingy for an increased battery charging over the fixed 1.5A and don't see if they charge with 2A or 3A. But that should be solved soon ;-)

@Apehaenger
Copy link
Contributor Author

Apehaenger commented Oct 14, 2024

Time for an intermediate result.
Tested the protocol together with ROS and made some alignments, nothing more except that I also implemented the last discussed stuff as well as that I added shutdown_esc_max_pitch config member. It get merged earlier or later anyway ;-)

Next, I'll check if LittleFS is working as expected.

ROS side's PR ClemensElflein/open_mower_ros#163

@Apehaenger
Copy link
Contributor Author

Please see here ClemensElflein/open_mower_ros#163 (comment) about state/description

@Apehaenger Apehaenger marked this pull request as ready for review October 26, 2024 19:15
@Apehaenger
Copy link
Contributor Author

Apehaenger commented Oct 26, 2024

In my opinion, all is done.
Did a couple of tests with old-LL/new-HL, new-LL/old-HL, new-LL/new-HL on C500 as well as SA600? mower.
Haven't found any issue.

Would love to see a generic review (also from @ClemensElflein) before asking for tester @ discord.

@karlranseierausrom
Copy link

May I already test? Is there an easy way to change the firmware version? I would like to check voltage and current settings to fit to my bigger battery.

@Apehaenger
Copy link
Contributor Author

Apehaenger commented Oct 27, 2024

May I already test? Is there an easy way to change the firmware version? I would like to check voltage and current settings to fit to my bigger battery.

Sure, testing is always welcome 😇

Pico-FW is here: https://github.com/ClemensElflein/OpenMower/actions/runs/11534325476/artifacts/2107987830
(if you don't know how to flash it, pls. contact me on discord)

ROS Image via: sudo podman pull ghcr.io/clemenselflein/open_mower_ros:pr-163
(don't forget to change your /boot/openmower/openmower_version.txt to pr-163)

Please check the sample config file regarding the required parameter: https://github.com/ClemensElflein/open_mower_ros/blob/38396194a4cc5d71de48d489fd35c19ca52f929a/config/mower_config.sh.example#L197-L210

You may watch the ll_high_level_config word in the openmower-log to follow up the configuration.

Copy link
Owner

@ClemensElflein ClemensElflein left a comment

Choose a reason for hiding this comment

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

LGTM

Firmware/LowLevel/src/datatypes.h Outdated Show resolved Hide resolved
Firmware/LowLevel/src/datatypes.h Outdated Show resolved Hide resolved
Firmware/LowLevel/src/datatypes.h Outdated Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Outdated Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Outdated Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Outdated Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Outdated Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Outdated Show resolved Hide resolved
Firmware/LowLevel/src/main.cpp Outdated Show resolved Hide resolved
@ClemensElflein ClemensElflein merged commit c9d557b into ClemensElflein:main Nov 15, 2024
3 of 4 checks passed
ClemensElflein added a commit to ClemensElflein/open_mower_ros that referenced this pull request Nov 15, 2024
In relation to ClemensElflein/OpenMower#110

Roadmap:

- [x] Decide for config protocol and struct
- [x] LowLevel (OpenMower Pico-FW) please see
ClemensElflein/OpenMower#110
- [x] HighLevel (open_mower_ros)
  - [x] Implement packet handling
  - [x] Implement config value handling
    - [x] Charge & Battery
    - [x] Hall sensor inputs
    - [x] Emergency
    - [x] Misc
- [x] Test with old LL-FW

<sub>:hammer: = Currently working on</sub>

---------

Co-authored-by: Clemens Elflein <[email protected]>
@Apehaenger Apehaenger deleted the feature/config-packet-trailer branch November 15, 2024 13:44
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.

4 participants