I have Dronekit working properly with SITL sim, however for my project I want to be able to command the attitude of the copter. Obviously I can do this via RC over ride in ALT_HOLD mode, however I don't like that approach.
I have been trying to use the Mavlink message SET_ATTITUDE_TARGET (#82), however when I send the messages to the sim, nothing happens. I have been able to set the velocity and the position, and those work fine.
Here is my function:
def att_msg_mode():
print "=========== Building Message"
veh1.mode = VehicleMode("ALT_HOLD")
msg = veh1.message_factory.set_attitude_target_encode(
0,
0, #target system
0, #target component
0b11100010, #type mask
[.9438,0,0,.17364], #q
0, #body roll rate
0, #body pitch rate
0, #body yaw rate
0) #thrust
time.sleep(1)
veh1.send_mavlink(msg)
veh1.flush()
print "=========== Message Sent"
Can someone help me out?
It is not possible to set the attitude directly because the command is not supported by Copter in either guided mode or AUTO mode/missions). The list of supported commands in guided mode is here and AUTO commands here.
What you can do is set the yaw. Another (hacky) approach that may work is setting the ROI as this will point the camera (and often the whole vehicle) at a target.
This sounds like a reasonable requirement - perhaps create a request with explanation of why this is useful for you?
SET_ATTITUDE_TARGET is now available to be used in guided_mode. You can even test it using mavproxy attitude command.
SET_ATTITUDE_TARGET
is now implemented, and will be released with ArduCopter 3.4
来源:https://stackoverflow.com/questions/31391721/how-to-set-copters-attitude-via-dronekit-set-attitude-target-not-working