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_DDS: Joystick Support 2 #28145

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

tizianofiorenzani
Copy link
Contributor

I noticed that this Pull Request has been stuck for one year.
#25334

Tagging @srmainwaring and @Ryanf55.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 18, 2024

Please add some tests (automated), or some instructions on how to test this in CLI. Once we've got those and we're happy, the commit history can be cleaned up.

Nice job cleaning up all the previous actions. Looking good.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 18, 2024

We also need some idea on how this will interract if you are also sending normal RC input (SBUS from RC transmitter for example). If that gives complete authority to the companion computer, whether the two inputs fight, or something else.

@tizianofiorenzani
Copy link
Contributor Author

@Ryanf55 I am working on the tests. For the RC, we might check whether the Radio is connected before overriding its channels. This would prevent any conflict and prioritize RC at all time.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 18, 2024

Yep. It's worth reviewing this wiki and seeing whether we want to make DDS act in a similar way of "no pulses" and re-use the existing failover logic.
https://ardupilot.org/copter/docs/common-multiple-rx.html#failsafe-and-changeover
It's not clear how ArduPilot ranks the priority of two active receivers if they are both providing pules.

@tizianofiorenzani
Copy link
Contributor Author

The RcChannel already handles overrides:

  • If a valid value is passed (>0 and <UINT16_MAX), the channel is overwritten.
  • If 0 is passed, the channel is released (falls back to RC).
  • There is a FS_RADIO_RC_OVERRIDE_TIMEOUT_MS=1s timeout for each channel. So if you keep commanding UINT16_MAX, the channel will eventually fall back to RC after 1s.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 18, 2024

Looks good, adding in the teleop joy instructions could be nice for this PR. I can dump it into the wiki.

Can you clean up the history and fix your git config user.name to not be =?

@tizianofiorenzani
Copy link
Contributor Author

@Ryanf55 of course, I forgot to update my laptop configuration.
Also, I have changed the code such that an input joystick value >= UINT16_MAX disables the channel override.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 19, 2024

Needs update to libraries/AP_DDS/README.md

@tizianofiorenzani tizianofiorenzani force-pushed the wips/wip-dds-joy branch 2 times, most recently from abf4ee0 to 8ae1a17 Compare September 19, 2024 19:32
@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 20, 2024

I force pushed with clean history. Can you share which email you want to attribute the work to?

I also

  • Ran astyle (./Tools/scripts/run_astyle.py
  • Edited the commit message to squash to one commit with the AP_DDS: prefix that is required

@Ryanf55 Ryanf55 force-pushed the wips/wip-dds-joy branch 2 times, most recently from a99f25c to 325f686 Compare September 20, 2024 05:57
Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Functionally seems to work fine. It clamps to -1/1 through the linear interpolate nicely. I think it's OK to silently clamp. NaN discards.
image

I think it might be nicer in the readme to give a command for a right turn and climb in FBWB.

@tizianofiorenzani
Copy link
Contributor Author

@Ryanf55 The test is pushed and working now, run it with:
colcon test --packages-select ardupilot_dds_tests --event-handlers=console_cohesion+ --pytest-args -k test_joy_msg_received.

I also updated the Readme, I think we are good to go once CI has passed.

@tizianofiorenzani
Copy link
Contributor Author

@Ryanf55 I just noticed that when I passed the astyle on the Readme, it really messed it up. I will need to restore it and push it again.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 21, 2024

  • ./Tools/scripts/run_astyle.py

How did you run astyle? This doesn't run on the README. astyle is a C++ formatter, not a markdown formatter.

@tizianofiorenzani
Copy link
Contributor Author

As a simple test, you can

  • run the ros2_sitl, quadcopter is fine, then takeoff.
  • On a new terminal, start sending joystick axes with ros2 topic pub /ap/joy sensor_msgs/msg/Joy "{axes: [0.0, 0.0, 0.0, 0.0]}"
  • Set the vehicle in LOITER mode
  • change the published joystick to ros2 topic pub /ap/joy sensor_msgs/msg/Joy "{axes: [0.5, 0.0, 0.0, 0.0]}" and you will see the vehicle moving sideways.

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Nice, looks good! Remove dead code and squash all your commits to one AP_DDS: ... commit.

@tizianofiorenzani
Copy link
Contributor Author

sitl-plane test fails. I don't know how to test it locally, here it's what is says:

2024-09-21T21:16:51.5884422Z >>>> FAILED STEP: test.Plane at Sat Sep 21 21:16:51 2024
2024-09-21T21:16:51.5885040Z Failure Summary:
2024-09-21T21:16:51.5885407Z test.Plane:
2024-09-21T21:16:51.5887138Z DeadreckoningNoAirSpeed (Test deadreckoning support with no airspeed sensor) (Failed to get EKF.flags=16) (see /tmp/buildlogs/ArduPlane-DeadreckoningNoAirSpeed.txt) (duration 10.50739574432373 s)

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 21, 2024

sitl-plane test fails. I don't know how to test it locally, here it's what is says:

2024-09-21T21:16:51.5884422Z >>>> FAILED STEP: test.Plane at Sat Sep 21 21:16:51 2024 2024-09-21T21:16:51.5885040Z Failure Summary: 2024-09-21T21:16:51.5885407Z test.Plane: 2024-09-21T21:16:51.5887138Z DeadreckoningNoAirSpeed (Test deadreckoning support with no airspeed sensor) (Failed to get EKF.flags=16) (see /tmp/buildlogs/ArduPlane-DeadreckoningNoAirSpeed.txt) (duration 10.50739574432373 s)

Some tests are flaky. Don't worry about those passing till you have the commit history clean, and I'll rerun the flaky unrelated tests.

@tizianofiorenzani
Copy link
Contributor Author

@Ryanf55 I rebased and cleaned up the history, leaving one single commit after your previous approval.

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Sep 23, 2024

I tagged for dev call for review, but will be late. Feel free to provide any feedback blocking merge.

libraries/AP_DDS/AP_DDS_Client.cpp Outdated Show resolved Hide resolved
@tizianofiorenzani tizianofiorenzani force-pushed the wips/wip-dds-joy branch 2 times, most recently from f6334dd to 3494cac Compare September 24, 2024 21:52
Signed-off-by: Ryan Friedman <[email protected]>
Co-Authored-by: Tiziano Fiorenzani
@Ryanf55 Ryanf55 added this to the DDS 4.6 milestone Sep 30, 2024
@peterbarker peterbarker merged commit 1bdc635 into ArduPilot:master Oct 1, 2024
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants