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

Cannot apply throttle / Offboard mode #951

Open
igordevjspy opened this issue Jun 19, 2024 · 0 comments
Open

Cannot apply throttle / Offboard mode #951

igordevjspy opened this issue Jun 19, 2024 · 0 comments

Comments

@igordevjspy
Copy link

igordevjspy commented Jun 19, 2024

Hello,

I'm trying to apply throttle using offboard mode.

I have tested those two methods:
set_attitude_target_send
rc_channels_override_send


def apply_throttle_with_attitude(throttle):
    q = QuaternionBase([1, 0, 0, 0])
    master.mav.set_attitude_target_send(
        0,
        master.target_system,
        master.target_component,
        0b00000000,
        q,
        0, 0, 0, 
        throttle / 100.0 
    )

def apply_throttle(throttle):
    throttle_pwm = int(1000 + (throttle / 100.0) * 1000) 
    master.mav.rc_channels_override_send(
        master.target_system,
        master.target_component,
        0,0,
        throttle_pwm,
        0, 0, 0, 0, 0
    )

But it's not working;

I don't think it's a hardware / config issue as it's working fine with mavsdk lib:

import asyncio
from mavsdk import System
from mavsdk.offboard import (OffboardError, Attitude)

async def run():
    # Initialize the drone
    drone = System()
    await drone.connect(system_address="serial:///dev/tty.usbserial-XXXXXX:57600")

    print("Waiting for drone to connect...")
    async for state in drone.core.connection_state():
        if state.is_connected:
            break

    async for health in drone.telemetry.health():
        if health.is_global_position_ok and health.is_home_position_ok:
            print("Drone has a global position estimate")
            break

    # Arm the drone
    await drone.action.arm()

    # Set an initial setpoint
    await drone.offboard.set_attitude(Attitude(0.0, 0.0, 0.0, 0.2)) 

    await asyncio.sleep(3)

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

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(run())

thanks for your help

@igordevjspy igordevjspy changed the title Cannot send throttle / Offboard mode Cannot apply throttle / Offboard mode Jun 19, 2024
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

1 participant