MAVSDK-Python: action.do_orbit no attribut found error message.

Hi, I am trying to achieve an auto mission with do_orbit function to move the drone in circle facing towards alawys front option. I tried using mavsdk python and it gives the following error.

`Error msg: Waiting for drone to connect… Drone discovered! Waiting for drone to have a global position estimate… – Global position estimate OK – Arming — Taking Off Traceback (most recent call last): File “/home/lalith/MAVSDK-Python/testScripts/windmillinspect.py”, line 43, in <module> asyncio.run(run()) File “/usr/lib/python3.8/asyncio/runners.py”, line 44, in run return loop.run_until_complete(main) Screenshot from 2023-05-17 16-12-34

File “/usr/lib/python3.8/asyncio/base_events.py”, line 616, in run_until_complete return future.result() File “/home/lalith/MAVSDK-Python/testScripts/windmillinspect.py”, line 30, in run await drone.action.do_orbit(radius_m = 5, File “/home/lalith/MAVSDK-Python/drones/lib/python3.8/site-packages/mavsdk/action.py”, line 587, in do_orbit request.yaw_behavior = yaw_behavior.translate_to_rpc() AttributeError: ‘int’ object has no attribute ‘translate_to_rpc’`

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 20 (16 by maintainers)

Most upvoted comments

@arpitpara it would be great if you could add an example to https://github.com/mavlink/MAVSDK-Python/tree/main/examples once you have something that nicely works against SITL.

image

so…analyzing this ulg file with plotjuggler: The drone was for ~10 seconds in ORBIT mode. The navigation mode is written in the vehicle_status uORB topic in the field nav_state. As you can see, it’s 21 for around 10 seconds and checking https://github.com/PX4/PX4-Autopilot/blob/main/msg/VehicleStatus.msg you will find NAVIGATION_STATE_ORBIT = 21.

The issue seems that the takeoff didn’t have enough time to do it’s job: the drone reached only 0.5m altitude. Then you gave him the orbit command to orbit somewhere at 2.5m AMSL, even though your flight started at ~488m AMSL.

So my tip: Use float("nan") for param7/altitude to use the current vehicle altitude (see https://mavlink.io/en/messages/common.html#MAV_CMD_DO_ORBIT) and give all the sleeps a little bit more time, especially the takeoff. Or consider a way of checking whether the drone finished takeoff before sending the orbit command. Eventually, the land detector detected the drone touching the earth and caused the drone to disarm.

Edit: the altitude graph:

image

If you do git log in the PX4 folder, you can find out which version your PX4 is based on.

Can you be more precise what exactly is not working? Usually it’s good to post the entire error messages (and not entire code files) here to help find the issue. At least your initial issue should be solved:

>>> OrbitYawBehavior.HOLD_FRONT_TO_CIRCLE_CENTER.translate_to_rpc()
0

Screenshot from 2023-05-18 12-32-07

Sorry for pasting the whole code. But there was no error shown. That’s why

I think you are supposed to use the enum instead of raw integers, e.g.

from mavsdk.action import OrbitYawBehavior
OrbitYawBehavior.HOLD_FRONT_TANGENT_TO_CIRCLE