So basically, my goal is to be able to set or control the attitude of my quadcopter using MAVlink, I’ve downloaded pymavlink and dronekit and am sticking to python because it’s nice and easy for a beginner like me ( o.k at python, new to mavlink and general ardupilot programming).
So far I’ve tried the dronekit commands, these haven’t worked out too well, and the documentation even mentions this : “ArduPilot does not currently support controlling the vehicle by specifying acceleration/force components.” (http://python.dronekit.io/guide/copter/guided_mode.html) perhaps there is something I am missing, but this seems like another dead end.
I’ve also tried sending messages, by encoding and then sending through mavlink. The code looks something like this:
#msg= vehicle.message_factory.hil_controls_encode(0,0.174533,3,0,100,0,0,0,0,1,1)
msg= vehicle.message_factory.attitude_encode( 0,0.174533,0,0,1,1,1)
print str(msg)
for x in range(0,20):
vehicle.send_mavlink(msg)
print " Altitude: ", vehicle.location.global_relative_frame.alt
print "Attitude: %s" % vehicle.attitude
time.sleep(1)
I have tried various messages (All taken from :https://www.samba.org/tridge/UAV/pymavlink/apidocs/mavlink.MAVLink.html#hil_controls_encode
)
I have already tried hils_controls_encode,manual_control_encode, and set_roll_pitch_yaw_thrust_encode. They all do not work.
But it appears that this does not even work.Everything I try results in the drone staying still. When I change flightmodes from GUIDED to LOITER or STABILIZE, the drone just falls out of the air (in SITL). Does anyone happen to know how I can move my drone, without giving a gps coordinate in GUIDED mode?
Thanks!