Closed omerkaanvural closed 5 months ago
Looks like mavsdk_server
is not running. Do you have mavsdk_server
installed on your system (it should have come with pip install
somewhere)? If yes, can you try to start it manually to confirm that it works?
we solved the server problem but now there is another problem while setting the takeoff altitude. Any idea ?@JonasVautherin
@julianoes: Could that be related to recent changes in the parameters handling in MAVSDK?
I didnt get what you mean and also the MultiThreadRandezvous error still occurs some time to time without changing anything
@erdoski what is the mavsdk_server version that you're using? Do you build it yourself or use the one that comes with the pip install?
pi@raspberrypi-MP:~/backup_jai $ python buster_dronekit_test.py --connect /dev/ttyAMA1 --baud 921600 /dev/ttyAMA1 921600
Connecting to vehicle on: /dev/ttyAMA1 A Mode: ALT_HOLD indoors prearm_check: 0 B Mode: ALT_HOLD ARM Vehicle is ready for arm
Wait for drone to transit to arm vehicle is now armed. Propellers are spinning Wait for drone to transit to disarm Wait for drone to transit to disarm Wait for drone to transit to disarm close End of python test script
Time take: 29.08 pi@raspberrypi-MP:~/backup_jai $ ~/.local/lib/python3.7/site-packages/mavsdk/bin/mavsdk_server serial:///dev/ttyAMA1:921600 [03:57:59|Info ] MAVSDK version: v1.2.0 (mavsdk_impl.cpp:28)
^C [blank, like hangs, nothing]
MAVProxy Connect /dev/ttyAMA1,921600 source_system=255 Log Directory: Telemetry log: mav.tlog Waiting for heartbeat from /dev/ttyAMA1 MAV> Detected vehicle 1:1 on link 0 online system 1 ALT_HOLD> Mode ALT_HOLD AP: ArduCopter V4.1.5 (1002fd6e) AP: ChibiOS: 45395b6a AP: CubeBlack 002F0039 30385111 30343937 AP: RCOut: PWM:1-12 AP: IMU0: fast sampling enabled 8.0kHz/1.0kHz AP: IMU2: fast sampling enabled 8.0kHz/1.0kHz AP: Frame: HEXA/X Received 981 parameters (ftp) Saved 981 parameters to mav.parm fence present fence enabled ALT_HOLD>
just to check is mavsdk ready in python 3.7? I cannot get it to work. I notice same result was with python3.9
I am sure my hardware serial port is correct as I can use it with MAVProxy and dronekit.
[blank, like hangs, nothing]
Can you try to run it with gdb and then after a while (when it hangs), do Ctrl+C and then type backtrace
to see where it hangs, and then post that here, thanks!
finally, I am able to get mavsdk server 1.4.9 to work with Arducopter. both the below works. command line, the server takes about 20-30 secs to return the connection. Python, the connection is faster. I am not sure which server version onwards work. last week, decided to try again. upgrade the mavsdk from 1.4.0
pip3 install --user --upgrade mavsdk Attempting uninstall: mavsdk Found existing installation: mavsdk 1.4.0 Uninstalling mavsdk-1.4.0: Successfully uninstalled mavsdk-1.4.0 Successfully installed grpcio-1.59.0 mavsdk-1.4.9
~/.local/lib/python3.9/site-packages/mavsdk/bin/mavsdk_server serial:///dev/ttyAMA1:921600 and python3 bullseye_mavsdk_test_2.py
async def run():
# Init the drone
#UART 4
print(f"System server b4")
drone = System()
print(f"System server done")
await drone.connect(system_address="serial:///dev/ttyAMA1:921600")
print("Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print(f"Drone discovered!")
break
info = await drone.info.get_version()
print(info)
if __name__ == "__main__":
# Run the asyncio loop
asyncio.run(run())
[34m[11:42:20|Info ] [0mMAVSDK version: v1.4.17 (mavsdk_impl.cpp:20) [34m[11:42:20|Info ] [0mWaiting to discover system on serial:///dev/ttyAMA1:921600... (connection_initiator.h:20) [32m[11:42:20|Debug] [0mNew: System ID: 1 Comp ID: 1 (mavsdk_impl.cpp:496) [32m[11:42:20|Debug] [0mComponent Autopilot (1) added. (system_impl.cpp:377) [33m[11:42:20|Warn ] [0mVehicle type changed (new type: 2, old type: 0) (system_impl.cpp:225) [32m[11:42:20|Debug] [0mDiscovered 1 component(s) (system_impl.cpp:578) [34m[11:42:20|Info ] [0mSystem discovered (connection_initiator.h:63) [34m[11:42:20|Info ] [0mServer started (grpc_server.cpp:53) [34m[11:42:20|Info ] [0mServer set to listen on 0.0.0.0:50051 (grpc_server.cpp:54) [32m[11:42:25|Debug] [0mMAVLink: critical: PreArm: Throttle below failsafe (system_impl.cpp:250) [32m[11:42:25|Debug] [0mMAVLink: critical: PreArm: Hardware safety switch (system_impl.cpp:250) [32m[11:42:25|Debug] [0mMAVLink: critical: PreArm: Battery 1 below minimum arming voltage (system_impl.cpp:250)
and
System server b4 System server done Waiting for drone to connect... Drone discovered! Version: [flight_sw_major: 4, flight_sw_minor: 3, flight_sw_patch: 0, flight_sw_vendor_major: 52, flight_sw_vendor_minor: 51, flight_sw_vendor_patch: 57, os_sw_major: 0, os_sw_minor: 0, os_sw_patch: 0, flight_sw_git_hash: 313762383 , os_sw_git_hash: 643065643565363 ]
But, this example code does not work.
# Start the tasks
asyncio.ensure_future(print_battery(drone))
while True:
await asyncio.sleep(1)
You might have to set the rate of the battery message: http://mavsdk-python-docs.s3-website.eu-central-1.amazonaws.com/plugins/telemetry.html#mavsdk.telemetry.Telemetry.set_rate_battery
set the rate of the battery message
Thank you, this code on Pi4B works with Arducopter 4.3.0.
async def run():
# Init the drone
#UART 4
print("System server b4")
drone = System()
print("System server done")
await drone.connect(system_address="serial:///dev/ttyAMA1:921600")
drone.telemetry.status_text() #Subscribe to ‘status text’ updates.
await asyncio.sleep(1)
status_text_task = asyncio.ensure_future(print_status_text(drone))
print("Pi4B Waiting for drone to connect...")
async for state in drone.core.connection_state():
if state.is_connected:
print("-- Connected to drone!")
break
info = await drone.info.get_version()
print(info)
# Start the tasks
await drone.telemetry.set_rate_battery(1) #1hz
await asyncio.sleep(1)
telem_battery = asyncio.ensure_future(print_battery(drone))
print("-- Arming")
#await drone.action.arm()
print("-- Taking off")
#await drone.action.takeoff()
print("-- Landing")
#await drone.action.land()
await asyncio.sleep(3)
status_text_task.cancel()
await asyncio.sleep(3)
telem_battery.cancel()
async def print_status_text(drone):
try:
async for status_text in drone.telemetry.status_text():
print(f"Status: {status_text.type}: {status_text.text}")
except asyncio.CancelledError:
print("print_status_text CancelledError")
return
async def print_battery(drone):
try:
async for battery in drone.telemetry.battery():
print(f"Battery: {battery.remaining_percent}")
print(f"Battery_v: {battery.voltage_v}")
except asyncio.CancelledError:
print("print_battery CancelledError")
return
if __name__ == "__main__":
asyncio.run(run())
Hi, can anybody help me this out? I'm trying to make a flight with pixhawk orange cube and raspberry pi 4 via mavsdk. I can connect pi and pixhawk with usb cable and connect serial ttyACM0, I can arm the drone but this error comes up immediately. Any idea?