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

AP_Torqeedo: add support for two motors #26494

Merged
merged 3 commits into from
May 8, 2024

Conversation

rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented Mar 13, 2024

This PR adds a frontend/backend split to the AP_Torqeedo library allowing up to two motors to be used and also opening the door for supporting higher powered Torqeedo motors in the future (they use a CAN protocol). Changes in this PR include:

  • TRQD parameters become TRQ1 and TRQ2. Parameter conversions are included and tested
  • New TRQx_SERVO_FN parameters allow the user to specify if the motor output should use the Throttle, ThrottleLeft or ThrottleRight servo output. This means we can support two motors for use on Ackermann or skid-steering vehicles.
  • Logging has a new "I" (for instance) field. Units and multipliers were also added in order to allow the GCSs to properly display the output separated by instance.
  • Most functionality has simply been moved to a new AP_Torqeedo_TQBus backend. Note that each TRQBus backend gets its own thread. Previously the single thread was called "torqeedo", now the two threads are named "torqeedo0" and "torqeedo1".

Points for discussion:

  • The AP_BatteryMonitor_Torqeedo backends assume a one-to-one mapping between battery monitor instasnce an AP_Torqeedo instance (e.g. BATT_MONITOR get voltage, current from TRQ1, BATT2_MONITOR from TRQ2) but ideally it would be nice if the 1st Torqeedo battery monitor pulled from TRQ1, the 2nd Torqeedo battery monitor pulled from TRQ2 but I don't think we have a good way to do this yet
  • The parameter conversion had to be done at the vehicle level (e.g. Rover). This is consistent with how the PRX* parameter conversion was done by @rishabsingh3003 but ideally I would have preferred to put this into the AP_Torqeedo library. Try as I might I could not get this to work.
  • While moving the parameters to a new AP_Torqeedo_Params class I struggled a bit to take the defaults from the AP_Torqeedo class so I ended up setting the defaults just using integers. I suspect there's a better way to do this.

This has been fairly thoroughly tested in SITL but still needs testing on real hardware.

Parameter conversion test:
param-conversion-test

Logging test:
torqeedo-logging-ok

This replaces PR #24302 and resolves issue #24216

There are community discussions here and here.

@xianglunkai
Copy link
Contributor

Due to the shift in work focus, I am unable to focus solely on researching unmanned ships. However, studying unmanned ships is truly a joyful experience

@tridge tridge merged commit 2867b0c into ArduPilot:master May 8, 2024
91 checks passed
@rmackay9 rmackay9 deleted the torqeedo-multi2 branch May 8, 2024 10:34
@Hwurzburg Hwurzburg added the WikiNeeded needs wiki update label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants