drone: Update client handling emergency land message and show start animation point error only not in active state

This commit is contained in:
Arthur Golubtsov
2020-06-03 15:46:34 +03:00
parent d9d82992fe
commit 85f8239b72
2 changed files with 8 additions and 4 deletions

View File

@@ -607,7 +607,11 @@ def _command_land(*args, **kwargs):
@messaging.message_callback("emergency_land")
def _emergency_land(*args, **kwargs):
logger.info(flight.emergency_land().message)
try:
result = flight.emergency_land()
logger.info(result.message)
except rospy.ServiceException:
logger.error("Can't execute emergency land: service is unavailable!")
@messaging.message_callback("disarm")
@@ -798,7 +802,7 @@ class Telemetry:
start_action = copter.animation.get_start_action(
copter.config.animation_start_action, self.ros_telemetry.z,
copter.config.animation_takeoff_level, copter.config.animation_ground_level,
copter.config.animation_ratio, offset)
copter.config.animation_ratio, offset, self.fcu_status)
return [x,y,z,yaw,start_action,start_delay]
@classmethod

View File

@@ -322,7 +322,7 @@ class Animation(object):
return ground_level <= self.get_scaled_output_min_z(ratio, offset)
def get_start_action(self, start_action, current_height, takeoff_level,
ground_level, ratio=(1,1,1), offset=(0,0,0)):
ground_level, ratio=(1,1,1), offset=(0,0,0), state="STANDBY"):
# Check output frames
if not self.output_frames:
return 'error: empty output frames'
@@ -335,7 +335,7 @@ class Animation(object):
ground_level = float(ground_level)
except ValueError:
return 'error in [ANIMATION] ground_level parameter'
if ground_level > self.get_scaled_output_min_z(ratio, offset):
if state != "ACTIVE" and ground_level > self.get_scaled_output_min_z(ratio, offset):
return 'error: some animation points are lower than ground level for {:.2f}m (max)'.format(
ground_level - self.get_scaled_output_min_z(ratio, offset)
)