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

Set Guided mode with MAVSDK-java #130

Closed
TeoVal138 opened this issue Jun 9, 2023 · 5 comments
Closed

Set Guided mode with MAVSDK-java #130

TeoVal138 opened this issue Jun 9, 2023 · 5 comments

Comments

@TeoVal138
Copy link

Hello everyone,
I'm developing an android mobile app with mavsdk-java to control my ardupilot drone, in this days I've been trying to set the guided mode in order to takeoff autonomously.
Can you please tell me what can I do?

Many thanks in advance

@JonasVautherin
Copy link
Collaborator

JonasVautherin commented Jun 9, 2023

I think that the equivalent to "guided" in PX4 is "offboard". Did you try the offboard plugin? Not sure if it works with Ardupilot though 🤔. Worth trying with a simulator! 😊

@TeoVal138
Copy link
Author

Hi Jonas,
Thank you for the support 😊
I was trying with a simulator to use offboard but the "system.getOffboard().start()" method doesn't respond and "system.getOffboard().isActive()" is always set to false so I think it's off limits unfortunately.
For a while I tried with the Shell plugin but I didn't find anything useful in the online forums, do you happen to know if I could actually use it to change the flight modes and if so what command should I use?

@JonasVautherin
Copy link
Collaborator

JonasVautherin commented Jun 9, 2023

Calling offboard.start() should just change the flight mode, see here:

_system_impl->set_flight_mode(FlightMode::Offboard)

which ends up translating that to an Ardupilot flight mode here:

make_command_ardupilot_mode(flight_mode, component_id);

which e.g. for a copter will translate to Guided here:

        case FlightMode::Offboard:
            return ardupilot::CopterMode::Guided;

So I think it should work.

The problem is that at least the last part is not available in MAVSDK v1.4.16 (latest release, see here), only on the main branch.

I see two three solutions for you (none of them ideal, unfortunately):

  1. You build MAVSDK from source (from the C++ core up to MAVSDK-Java)
  2. You wait until MAVSDK v2 is out, but that may take time. It is being tracked here.
  3. You fix v1.4.16 and open a PR, such that we can release v1.4.17 with the changes you need. You can get inspiration from the main branch (where I believe it should work), but honestly I don't know how easy that will be. Could be quite straightforward, I think.

@TeoVal138
Copy link
Author

Thank you Jonas I will try to follow your advice! 😊
So no other mavsdk-java plugin would allow me to switch modes right?
I'm not just talking about the guided mode set but also about the other modes set

@JonasVautherin
Copy link
Collaborator

The MAVSDK plugins set the mode as required. For instance the mission plugin will set the mission mode, the action plugin will set the RTL, takeoff, land mode, etc.

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

No branches or pull requests

2 participants