I have flight a VTOL tailsitter plane with offboard control. At first time, my script worked, but in the second and third time, the same script cannot work. After excute offboard mode, I wrote to change into “AUTO.LOITER” and “AUTO.LAND” mode, but it failed and finally into a descend mode.
Could please tell me how to fix it? Thank you very much!
Here are my three times flight logs.
First flight (right test)
second flight test (fault)
Third flight test (fault)
This is my code:
def send_att(self):
rate = rospy.Rate(50) # Hz
self.att.body_rate = Vector3()
self.att.header = Header()
self.att.header.frame_id = "base_footprint"
self.att.orientation = Quaternion(*quaternion_from_euler(-0, 0, 0))
self.att.thrust = 1
self.att.type_mask = 7 # ignore body rate
while not rospy.is_shutdown():
self.att.header.stamp = rospy.Time.now()
self.att_setpoint_pub.publish(self.att)
if not self.att_running.isSet():
self.att_setpoint_pub.unregister()
break
try: # prevent garbage in console output when thread is killed
rate.sleep()
except rospy.ROSInterruptException:
pass
def run_mission(self):
rospy.loginfo("attitude control mode start!")
timeout = 90 # (int) seconds
loop_freq = 100 # Hz
rate = rospy.Rate(loop_freq)
while not rospy.is_shutdown():
if self.local_position.pose.position.z > 10:
rospy.loginfo("altitude of plane: %d", self.local_position.pose.position.z)
self.set_mode("AUTO.LOITER", 5)
for i in xrange(15*loop_freq):
rate.sleep()
break
rate.sleep()
self.set_mode("AUTO.LAND", 50)
self.wait_for_landed_state(mavutil.mavlink.MAV_LANDED_STATE_ON_GROUND, 45, 0)
self.set_arm(False, 5)