Loiter turns always falling down

Hi.
Now I’m trying to controll my drone with my Jetson board by using Pymavlink.
I wrote pymavlink script and need to validate it works well.
So I did these.

  1. Run Sim_vehicle
    " sim_vehicle.py -v ArduCopter --out=tcpin:0.0.0.0:5765"
  2. Connect sim with GCS, TCP:localhost:5765
  3. Connect sim with Pymavlink connection, TCP:localhost:5762
  4. Give Loiter_turn params
    " master.mav.command_long_send(
    master.target_system,
    master.target_component,
    mavutil.mavlink.MAV_CMD_NAV_LOITER_TURNS,
    0, # confirmation
    1, # number of turns
    0,
    10, # radius
    0, # reserved
    new_lat, # latitude
    new_lon, # longitude
    0 # altitude
    ) "
  5. Let it circle
    master.mav.set_mode_send(
    master.target_system,
    mavutil.mavlink.MAV_MODE_FLAG_CUSTOM_MODE_ENABLED,
    7)

These sequence make drone can circular but It falls down soon.

It looks like the vehicle never arms. Start it in GUIDED mode, then switch to CIRCLE.

It looks like you are going to circle mode (not an auto mission with loiter turns). In circle mode the throttle from your RC controls altitude (like in alt-hold and loiter mode). Since you have no RC connected in the sim (i assume) its commanding a descent during the circle.

Thank you, but I started it in Guided by manually, then switched to Circle.
You can see message “Hit the ground” on GCS

Thank you, You mean If I don’t have any RC controller, I have to switch to Auto mode right?
So, Is that right to give Loiter turn params for Auto mode as mission?
then, It automatically do when I switch to Auto mode?
“MAV_CMD_NAV_LOITER_TURNS”

Yeah switch to auto with that in the mission - or somehow simulate middle throttle on a rc controller.

Thank you, but there is some issue.
When I tried to switch mode to Auto, error came out like “mode AUTO init failed”. There is no other log about why It can’t be Auto mode.

There is a setting to allow Auto mode when throttle is still at zero - usually you have to raise the throttle for Auto mode to take effect (like do a take off)

Maybe I understand. But I don’t want to control by RC controller. Only with my Jetson board with python scripts. I mean “autonomous”.
When I don’t connect RC controller, vehicle doesn’t have any throttle values. right?
So If I allow to auto mode when there is no throttle(but still flying in Guided mode), It automatically keep its altitude?

Modify the AUTO_OPTIONS parameter with the behavior you want.

Thanks a lot for all you guys’ advices.
I did many things, then I can enter auto mode as modifying AUTO_OPTIONS param.
But there is no other way to give mission item about LOITER_TURNS so I decided to make turn same as LOITER_TURNS in GUIDED mode.
There is my code and vehicle’s moving, of course I need to adjust some params about yaw and speed…
Thank you for your interests :smile: