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

How to use mavsdk-python to takeoff without GPS #704

Open
Hmilzy opened this issue May 31, 2024 · 4 comments
Open

How to use mavsdk-python to takeoff without GPS #704

Hmilzy opened this issue May 31, 2024 · 4 comments
Labels

Comments

@Hmilzy
Copy link

Hmilzy commented May 31, 2024

Hello !
I will first introduce the framework. I have a control PC and a drone connected to the Raspberry Pi via a serial port.
Now I want to send a "takeoff" command from my PC and transmit it to the Raspberry Pi via UDP. After receiving the command, the Raspberry Pi will execute the program drone.action.takeoff() in mavsdk-python to control the takeoff.
I deployed mavsdk-server and mavlink-router on the Raspberry Pi.
mavlink-routerd -e 127.0.0.1:30000 /dev/ttyAMA0:921600 ./mavsdk_server .... -p 50040 udp://0.0.0.0:30000

I conducted an experiment indoor,I was able to successfully connect to the drone and commands were sent from the control computer to the Raspberry Pi. But when drone.action.takeoff() is executed, an error like command denied will be reported.

So I want to know whether the prerequisite for takeoff is to receive GPS signal, because I can successfully arm indoors, but I can't takeoff.

And If I want to control the flight indoors, how should I write mavsdk-python?

@julianoes julianoes added the bug label May 31, 2024
@julianoes
Copy link
Collaborator

That's a question that comes up often. I think it boils down to whether PX4 (assuming you're using PX4) can do autonomous flight without GPS.

Usually you need something like flow or VIO or a MOCAP system to do that. Otherwise you have to fly manually because you'd drift away pretty quickly.

@julianoes julianoes added question and removed bug labels May 31, 2024
@Hmilzy
Copy link
Author

Hmilzy commented May 31, 2024

Thank you for your answer.
Is it possible to use offboard mode?

`
await drone.action.arm()

print("Setting initial setpoints...")
await drone.offboard.set_velocity_ned(
    VelocityNedYaw(0.0, 0.0, 0.0, 0.0))  

print("Starting offboard control...")
try:
    await drone.offboard.start()
except OffboardError as error:
    print(f"Starting offboard mode failed with error code: {error._result.result}")
    print("-- Disarming")
    await drone.action.disarm()
    return

print("Taking off manually...")
await drone.offboard.set_velocity_ned(
    VelocityNedYaw(0.0, 0.0, -1.0, 0.0))  # Ascend with -1.0 m/s velocity

await asyncio.sleep(5)

print("Hovering...")
await drone.offboard.set_velocity_ned(
    VelocityNedYaw(0.0, 0.0, 0.0, 0.0))  # Hover in place

await asyncio.sleep(10)

print("Landing manually...")
await drone.offboard.set_velocity_ned(
    VelocityNedYaw(0.0, 0.0, 1.0, 0.0))  # Descend with 1.0 m/s velocity

await asyncio.sleep(5)

print("Stopping offboard control...")
try:
    await drone.offboard.stop()
except OffboardError as error:
    print(f"Stopping offboard mode failed with error code: {error._result.result}")

print("Disarming...")
await drone.action.disarm()

`

@julianoes
Copy link
Collaborator

No, offboard requires a position (or at least velocity) estimate, unless you use attitude offboard.

@arpitpara
Copy link
Contributor

It's possible through off-board mode. As @julianoes mentioned without GPS drones should have either VIO or MO-CAP.
We've built a indoor drone using VIO with PX4. We use Velocity-Ned and Position-NED(Prefered) function for autonomous control through MAVSDK-Python. You can also try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants