mirror of
https://github.com/CopterExpress/clever-show.git
synced 2026-06-07 20:44:31 +00:00
Client: Add current task information to telemetry
This commit is contained in:
@@ -690,12 +690,13 @@ class Telemetry:
|
|||||||
"animation_id": None,
|
"animation_id": None,
|
||||||
"battery": None,
|
"battery": None,
|
||||||
"armed": False,
|
"armed": False,
|
||||||
"system_status": None,
|
"fcu_status": None,
|
||||||
"calibration_status": None,
|
"cal_status": None,
|
||||||
"mode": None,
|
"mode": None,
|
||||||
"selfcheck": None,
|
"selfcheck": None,
|
||||||
"current_position": None,
|
"current_position": None,
|
||||||
"start_position": None,
|
"start_position": None,
|
||||||
|
"task": None,
|
||||||
"time": None,
|
"time": None,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -779,6 +780,7 @@ class Telemetry:
|
|||||||
|
|
||||||
def update_telemetry_fast(self):
|
def update_telemetry_fast(self):
|
||||||
self.start_position = self.get_start_position()
|
self.start_position = self.get_start_position()
|
||||||
|
self.task = task_manager.get_current_task()
|
||||||
try:
|
try:
|
||||||
self.ros_telemetry = FlightLib.get_telemetry_locked(client.active_client.config.copter_frame_id)
|
self.ros_telemetry = FlightLib.get_telemetry_locked(client.active_client.config.copter_frame_id)
|
||||||
if self.ros_telemetry.connected:
|
if self.ros_telemetry.connected:
|
||||||
@@ -802,8 +804,8 @@ class Telemetry:
|
|||||||
self.animation_id = animation.get_id()
|
self.animation_id = animation.get_id()
|
||||||
self.git_version = self.get_git_version()
|
self.git_version = self.get_git_version()
|
||||||
try:
|
try:
|
||||||
self.calibration_status = get_calibration_status()
|
self.cal_status = get_calibration_status()
|
||||||
self.system_status = get_sys_status()
|
self.fcu_status = get_sys_status()
|
||||||
self.battery = self.get_battery(self.ros_telemetry)
|
self.battery = self.get_battery(self.ros_telemetry)
|
||||||
except rospy.ServiceException:
|
except rospy.ServiceException:
|
||||||
rospy.logdebug("Some service is unavailable")
|
rospy.logdebug("Some service is unavailable")
|
||||||
@@ -825,8 +827,8 @@ class Telemetry:
|
|||||||
|
|
||||||
def reset_telemetry_values(self):
|
def reset_telemetry_values(self):
|
||||||
self.battery = float('nan'), float('nan')
|
self.battery = float('nan'), float('nan')
|
||||||
self.calibration_status = 'NO_FCU'
|
self.cal_status = 'NO_FCU'
|
||||||
self.system_status = 'NO_FCU'
|
self.fcu_status = 'NO_FCU'
|
||||||
self.mode = 'NO_FCU'
|
self.mode = 'NO_FCU'
|
||||||
self.selfcheck = ['NO_FCU']
|
self.selfcheck = ['NO_FCU']
|
||||||
self.current_position = 'NO_POS'
|
self.current_position = 'NO_POS'
|
||||||
@@ -900,15 +902,14 @@ class Telemetry:
|
|||||||
if client.active_client.config.telemetry_transmit and client.active_client.connected:
|
if client.active_client.config.telemetry_transmit and client.active_client.connected:
|
||||||
self.transmit_message()
|
self.transmit_message()
|
||||||
|
|
||||||
if client.active_client.config.telemetry_log_resources:
|
|
||||||
self.log_cpu_and_memory()
|
|
||||||
|
|
||||||
rate.sleep()
|
rate.sleep()
|
||||||
|
|
||||||
def _slow_update_loop(self):
|
def _slow_update_loop(self):
|
||||||
rate = rospy.Rate(1)
|
rate = rospy.Rate(1)
|
||||||
while not rospy.is_shutdown():
|
while not rospy.is_shutdown():
|
||||||
self.update_telemetry_slow()
|
self.update_telemetry_slow()
|
||||||
|
if client.active_client.config.telemetry_log_resources:
|
||||||
|
self.log_cpu_and_memory()
|
||||||
rate.sleep()
|
rate.sleep()
|
||||||
|
|
||||||
def start_loop(self):
|
def start_loop(self):
|
||||||
|
|||||||
@@ -89,6 +89,21 @@ class TaskManager(object):
|
|||||||
|
|
||||||
def get_last_task_name(self):
|
def get_last_task_name(self):
|
||||||
return self._last_task
|
return self._last_task
|
||||||
|
|
||||||
|
def get_current_task(self):
|
||||||
|
try:
|
||||||
|
start_time, priority, count, task = self.task_queue[0]
|
||||||
|
except IndexError as e:
|
||||||
|
logger.debug("Task queue checking exception: {}".format(e))
|
||||||
|
return "No task"
|
||||||
|
else:
|
||||||
|
if self._running_event.is_set():
|
||||||
|
time_to_start = start_time - time.time()
|
||||||
|
if time_to_start > 0:
|
||||||
|
return "{} in {:.1f} s".format(task.func.__name__,time_to_start)
|
||||||
|
return task.func.__name__
|
||||||
|
else:
|
||||||
|
return "paused"
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
#print("Task manager is started")
|
#print("Task manager is started")
|
||||||
@@ -138,7 +153,7 @@ class TaskManager(object):
|
|||||||
with self._task_queue_lock:
|
with self._task_queue_lock:
|
||||||
try:
|
try:
|
||||||
start_time, priority, count, task = self.task_queue[0]
|
start_time, priority, count, task = self.task_queue[0]
|
||||||
except Exception as e:
|
except IndexError as e:
|
||||||
logger.debug("Task queue checking exception: {}".format(e))
|
logger.debug("Task queue checking exception: {}".format(e))
|
||||||
self._timeshift = 0.0
|
self._timeshift = 0.0
|
||||||
self._wait_interrupt_event.clear()
|
self._wait_interrupt_event.clear()
|
||||||
@@ -180,7 +195,7 @@ class TaskManager(object):
|
|||||||
if time.time() > start_time:
|
if time.time() > start_time:
|
||||||
try:
|
try:
|
||||||
start_time_n, priority_n, count_n, task_n = self.task_queue[0]
|
start_time_n, priority_n, count_n, task_n = self.task_queue[0]
|
||||||
except Exception as e:
|
except IndexError as e:
|
||||||
logger.warning("Timeout checking exception: {}".format(e))
|
logger.warning("Timeout checking exception: {}".format(e))
|
||||||
self._timeshift = 0.0
|
self._timeshift = 0.0
|
||||||
self._wait_interrupt_event.clear()
|
self._wait_interrupt_event.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user