mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
fixed some lint errors and removed arming
This commit is contained in:
@@ -68,45 +68,27 @@ class MavrosOffboardAttctlTest(unittest.TestCase):
|
|||||||
rospy.wait_for_service('iris/mavros/cmd/arming', 30)
|
rospy.wait_for_service('iris/mavros/cmd/arming', 30)
|
||||||
rospy.Subscriber('iris/vehicle_control_mode', vehicle_control_mode, self.vehicle_control_mode_callback)
|
rospy.Subscriber('iris/vehicle_control_mode', vehicle_control_mode, self.vehicle_control_mode_callback)
|
||||||
rospy.Subscriber("iris/mavros/position/local", PoseStamped, self.position_callback)
|
rospy.Subscriber("iris/mavros/position/local", PoseStamped, self.position_callback)
|
||||||
self.pubAtt = rospy.Publisher('iris/mavros/setpoint/attitude', PoseStamped, queue_size=10)
|
self.pub_att = rospy.Publisher('iris/mavros/setpoint/attitude', PoseStamped, queue_size=10)
|
||||||
self.pubThr = rospy.Publisher('iris/mavros/setpoint/att_throttle', Float64, queue_size=10)
|
self.pub_thr = rospy.Publisher('iris/mavros/setpoint/att_throttle', Float64, queue_size=10)
|
||||||
self.cmdArm = rospy.ServiceProxy("iris/mavros/cmd/arming", CommandBool)
|
|
||||||
self.rate = rospy.Rate(10) # 10hz
|
self.rate = rospy.Rate(10) # 10hz
|
||||||
self.rateSec = rospy.Rate(1)
|
self.has_pos = False
|
||||||
self.hasPos = False
|
self.control_mode = vehicle_control_mode()
|
||||||
self.controlMode = vehicle_control_mode()
|
self.local_position = PoseStamped()
|
||||||
|
|
||||||
#
|
#
|
||||||
# General callback functions used in tests
|
# General callback functions used in tests
|
||||||
#
|
#
|
||||||
def position_callback(self, data):
|
def position_callback(self, data):
|
||||||
self.hasPos = True
|
self.has_pos = True
|
||||||
self.localPosition = data
|
self.local_position = data
|
||||||
|
|
||||||
def vehicle_control_mode_callback(self, data):
|
def vehicle_control_mode_callback(self, data):
|
||||||
self.controlMode = data
|
self.control_mode = data
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Helper methods
|
|
||||||
#
|
|
||||||
def arm(self):
|
|
||||||
return self.cmdArm(value=True)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Test offboard position control
|
# Test offboard position control
|
||||||
#
|
#
|
||||||
def test_attctl(self):
|
def test_attctl(self):
|
||||||
# FIXME: this must go ASAP when arming is implemented
|
|
||||||
manIn = ManualInput()
|
|
||||||
manIn.arm()
|
|
||||||
manIn.offboard_attctl()
|
|
||||||
|
|
||||||
self.assertTrue(self.arm(), "Could not arm")
|
|
||||||
self.rateSec.sleep()
|
|
||||||
self.rateSec.sleep()
|
|
||||||
self.assertTrue(self.controlMode.flag_armed, "flag_armed is not set after 2 seconds")
|
|
||||||
|
|
||||||
# set some attitude and thrust
|
# set some attitude and thrust
|
||||||
att = PoseStamped()
|
att = PoseStamped()
|
||||||
att.header = Header()
|
att.header = Header()
|
||||||
@@ -121,19 +103,22 @@ class MavrosOffboardAttctlTest(unittest.TestCase):
|
|||||||
# does it cross expected boundaries in X seconds?
|
# does it cross expected boundaries in X seconds?
|
||||||
count = 0
|
count = 0
|
||||||
timeout = 120
|
timeout = 120
|
||||||
while(count < timeout):
|
while count < timeout:
|
||||||
# update timestamp for each published SP
|
# update timestamp for each published SP
|
||||||
att.header.stamp = rospy.Time.now()
|
att.header.stamp = rospy.Time.now()
|
||||||
self.pubAtt.publish(att)
|
self.pub_att.publish(att)
|
||||||
self.pubThr.publish(throttle)
|
self.pub_thr.publish(throttle)
|
||||||
|
|
||||||
if (self.localPosition.pose.position.x > 5
|
if (self.local_position.pose.position.x > 5
|
||||||
and self.localPosition.pose.position.z > 5
|
and self.local_position.pose.position.z > 5
|
||||||
and self.localPosition.pose.position.y < -5):
|
and self.local_position.pose.position.y < -5):
|
||||||
break
|
break
|
||||||
count = count + 1
|
count = count + 1
|
||||||
self.rate.sleep()
|
self.rate.sleep()
|
||||||
|
|
||||||
|
self.assertTrue(self.control_mode.flag_armed, "flag_armed is not set")
|
||||||
|
self.assertTrue(self.control_mode.flag_control_attitude_enabled, "flag_control_attitude_enabled is not set")
|
||||||
|
self.assertTrue(self.control_mode.flag_control_offboard_enabled, "flag_control_offboard_enabled is not set")
|
||||||
self.assertTrue(count < timeout, "took too long to cross boundaries")
|
self.assertTrue(count < timeout, "took too long to cross boundaries")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user