mavlink / MAVSDK

API and library for MAVLink compatible systems written in C++17
https://mavsdk.mavlink.io
BSD 3-Clause "New" or "Revised" License
593 stars 491 forks source link

MAVSDK equivalent of POSITION_GLOBAL_TARGET_INT? #2015

Open TheKeveloper opened 1 year ago

TheKeveloper commented 1 year ago

This is a noob question and I'm probably just missing something in the MAVSDK docs, but is there a way to tell the current target of the drone using MAVSDK? Basically what we would get from the POSITION_GLOBAL_TARGET_INT message?

Thanks!

JonasVautherin commented 1 year ago

Something like action.goto_location()?

TheKeveloper commented 1 year ago

@JonasVautherin Sorry, maybe I wasn't super clear. I know we can use that to tell the drone where to go, but there's no way for us to inspect the state of the drone and find out where it's current target is if that makes sense?

We could do something like maintain some state for where the drone is going each time we send a go to location command, but it seems like Mavlink already provides a message type that tells us the current target of the drone.

JonasVautherin commented 1 year ago

Hmm maybe @julianoes can answer that. My limited understanding is that goto_location puts PX4 in "hold mode", with the setpoint set there. I don't think that there is a notion of "target reached" (or even a notion of "target" at all).

Not sure how Ardupilot does it though. What autopilot are you using?

TheKeveloper commented 1 year ago

I'm using the px4 gazebo simulator: https://github.com/JonasVautherin/px4-gazebo-headless. I seem to be receiving this message: https://mavlink.io/en/messages/common.html#POSITION_TARGET_GLOBAL_INT, when communicating directly over mavlink.

I'm thinking of switching over to MAVSDK but couldn't find how to support this using mavsdk

JonasVautherin commented 1 year ago

Maybe we could add this message to the telemetry plugin? Something like SubscribePositionTargetGlobal?

julianoes commented 1 year ago

The equivalent is Offboard::set_global_position.

Also see:

https://github.com/mavlink/MAVSDK/blob/ad478f19ab99fce4a9b16f33353306f45764acf1/src/mavsdk/plugins/offboard/offboard_impl.cpp#L448-L470

julianoes commented 1 year ago

Ok, and if you want to actually see tthe telemetry if someone else is commanding this, then that's not supported.

You could use MavlinkPassthrough and subscribe to https://mavlink.io/en/messages/common.html#POSITION_TARGET_GLOBAL_INT.

TheKeveloper commented 1 year ago

@julianoes thanks for the response! Yeah, that makes sense. I'm using the mavsdk java client for my workflow currently so can't access the mavlink passthrough. Not sure if this is something that may be worth adding to the proto?

JonasVautherin commented 1 year ago

I think it would be worth adding to the telemetry plugin. It does make sense to me that a ground station may want to show where the drone is headed in that situation :innocent:

julianoes commented 1 year ago

Fair enough, feel free to make a pull request.

julianoes commented 1 year ago

And make sure to make PR to the MAVSDK-Proto repo first.