Could I disarm the drone without this two lines?
Because the drone cannot stop motor immediately and the boat will move away.
self.set_mode("AUTO.LAND", 5)
self.wait_for_landed_state(mavutil.mavlink.MAV_LANDED_STATE_ON_GROUND,10, 0)
FAILURE: False is not true : landed state not detected | desired: MAV_LANDED_STATE_ON_GROUND, current: MAV_LANDED_STATE_LANDING
there are similar topics:
How to force disarm (or switch off) when landing on a moving platform
How to disarm or stops motor when the drone touch the ground during offboard mode
Kill switch for companion computer
I follow the instruction and changed the parameter CBRK_FLIGHTTERM
from 121212 to 0.
however, the landed state just changed repeatedly from MAV_LANDED_STATE_LANDING to MAV_LANDED_STATE_IN_AIR
send the mavlink msg works
rospy.loginfo("Force disarm")
connection = mavutil.mavlink_connection('udp:localhost:14540')
# command = 400
# param1 = 0 # 1 to ARM, 0 to DISARM
# param2 = 21196 # Custom parameter (set to whatever value you need)
msg = connection.mav.command_long_encode(
target_system=1, # Target system ID
target_component=1, # Target component ID
command=400,
confirmation=0,
param1=0,
param2=21196,
param3=0,
param4=0,
param5=0,
param6=0,
param7=0
)
connection.mav.send(msg)
Landing on the solid place is ok. The messages like the below
armed state changed from True to False
connected changed from True to False
mode changed from AUTO.LAND to
system_status changed from MAV_STATE_ACTIVE to MAV_STATE_UNINIT
However, landing on a boat cannot work. The messages like the below:
WARN [mc_pos_control] invalid setpoints
WARN [mc_pos_control] Failsafe: blind land
WARN [failsafe] Failsafe activated
ref: Can’t start sitl sim “warn [mc_pos_control] invalid setpoints”
The drone’s rotor keeps spinning. probably due to the different altitudes.
The GPS becomes noisy
I am not whether it is a good way.
My temporary solution is using
rosrun mavros mavsafety kill
according to this post. (mavsafety kill feature for emergency stop)
def run_mavsafety_kill(self):
try:
# Run the 'rosrun' command with 'mavros' package and 'mavsafety kill' arguments
subprocess.run(['rosrun', 'mavros', 'mavsafety', 'kill'], check=True)
except subprocess.CalledProcessError as e:
rospy.loginfo("Error running command:", e)
rospy.loginfo("Force disarm")
connection = mavutil.mavlink_connection('udp:localhost:14540')
# command = 400
# param1 = 0 # 1 to ARM, 0 to DISARM
# param2 = 21196 # Custom parameter (set to whatever value you need)
msg = connection.mav.command_long_encode(
target_system=1, # Target system ID
target_component=1, # Target component ID
command=400,
confirmation=0,
param1=0,
param2=21196,
param3=0,
param4=0,
param5=0,
param6=0,
param7=0
)
connection.mav.send(msg)
rospy.loginfo("run_mavsafety_kill")
self.run_mavsafety_kill()
The GPS is still drifting.
armed state changed from True to False
connected changed from True to False
mode changed from OFFBOARD to
system_status changed from MAV_STATE_ACTIVE to MAV_STATE_UNINIT
I also tried , but it still does not work , reference: MAVROS errors with T200 thrusters
from mavros_msgs.msg import Thrust
self.thrust_pub = rospy.Publisher( '/mavros/setpoint_attitude/thrust', Thrust, queue_size=10) # queue_size=1
def stop_all_rotors(self):
rate = rospy.Rate(100) # Publishing rate
zero_throttle = Thrust()
zero_throttle.header.stamp = rospy.Time.now()
zero_throttle.thrust = 0.0 # Assuming a quadcopter with 4 rotors
while not rospy.is_shutdown():
self.thrust_pub.publish(zero_throttle)
rate.sleep()
I also tried rosservice but it still does not work
rosservice call /mavros/cmd/arming "value: false"