services.py
Go to the documentation of this file.
1 from threading import Thread
2 
3 from microstrain_inertial_msgs.srv import DeviceReport
4 
5 from .common import ServiceMonitor
6 from .constants import _MICROSTRAIN_ROS_VERISON
7 from .constants import _DEFAULT_VAL
8 
10 
11  def __init__(self, node, node_name):
12  super(DeviceReportMonitor, self).__init__(node, node_name, "device_report", DeviceReport, message_timeout=25, poll_interval=5)
13 
14  # Keep track of some booleans so that we can keep track between disconnects
15  self._is_gq7 = False
16  self._is_gx5 = False
17  self._has_magnetometer = False
18  self._has_gnss = False
19  self._has_dual_antenna = False
20 
21  @property
22  def connected(self):
23  return self._current_message is not _DEFAULT_VAL and not self._message_timed_out
24 
25  @property
26  def model_name(self):
27  return self._get_val(self._current_message.model_name)
28 
29  @property
30  def model_number(self):
31  return self._get_val(self._current_message.model_number)
32 
33  @property
34  def serial_number(self):
35  return self._get_val(self._current_message.serial_number)
36 
37  @property
38  def options(self):
39  return self._get_val(self._current_message.options)
40 
41  @property
42  def firmware_version(self):
43  return self._get_val(self._current_message.firmware_version)
44 
45  @property
46  def is_gq7(self):
47  # If we are not connected, no reason to check any further
48  if self.connected:
49  # Check the model name to determine if this is a GQ7
50  model_name = self.model_name
51  if model_name is not _DEFAULT_VAL:
52  self._is_gq7 = "GQ7" in model_name
53 
54  # Return the stored value
55  return self._is_gq7
56 
57  @property
58  def is_gx5(self):
59  # If we are not connected, no reason to check any further
60  if self.connected:
61  # Check the model name to determine if this is a GX5
62  model_name = self.model_name
63  if model_name is not _DEFAULT_VAL:
64  self._is_gx5 = "GX5" in model_name
65 
66  # Return the stored value
67  return self._is_gx5
68 
69  @property
70  def has_magnetometer(self):
71  # If we are not connected, no reason to check any further
72  if self.connected:
73  # Check the model name to determine if this device has GNSS
74  model_name = self.model_name
75  if model_name is not _DEFAULT_VAL:
76  self._has_magnetometer = self.is_gq7 or "GX5-45" in model_name or "GX5-25" in model_name
77 
78  # Return the stored value
79  return self._has_magnetometer
80 
81  @property
82  def has_gnss(self):
83  # If we are not connected, no reason to check any further
84  if self.connected:
85  # Check the model name to determine if this device has GNSS
86  model_name = self.model_name
87  if model_name is not _DEFAULT_VAL:
88  self._has_gnss = self.is_gq7 or "GX5-45" in model_name
89 
90  # Return the stored value
91  return self._has_gnss
92 
93  @property
94  def has_dual_antenna(self):
95  # Right now, the GQ7 is the only device that supports dual antenna
96  return self.is_gq7
97 
98  @property
99  def model_name_string(self):
100  return self._get_string(self.model_name)
101 
102  @property
104  return self._get_string(self.model_number)
105 
106  @property
108  return self._get_string(self.serial_number)
109 
110  @property
111  def options_string(self):
112  return self._get_string(self.options)
113 
114  @property
116  return self._get_string(self.firmware_version)
117 
118  @property
119  def connected_string(self):
120  return self._get_small_boolean_icon_string(self.connected)
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.serial_number
def serial_number(self)
Definition: services.py:34
microstrain_inertial_rqt.utils.services.DeviceReportMonitor._has_gnss
_has_gnss
Definition: services.py:18
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.has_magnetometer
def has_magnetometer(self)
Definition: services.py:70
microstrain_inertial_rqt.utils.services.DeviceReportMonitor._has_magnetometer
_has_magnetometer
Definition: services.py:17
microstrain_inertial_rqt.utils.services.DeviceReportMonitor
Definition: services.py:9
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.firmware_version
def firmware_version(self)
Definition: services.py:42
microstrain_inertial_rqt.utils.common.ServiceMonitor
Definition: common.py:158
microstrain_inertial_rqt.utils.common.Monitor._current_message
_current_message
Definition: common.py:74
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.model_name_string
def model_name_string(self)
Definition: services.py:99
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.is_gq7
def is_gq7(self)
Definition: services.py:46
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.is_gx5
def is_gx5(self)
Definition: services.py:58
microstrain_inertial_rqt.utils.common.Monitor._get_string
def _get_string(self, val, default_val=_DEFAULT_VAL, default_str=_DEFAULT_STR)
Definition: common.py:121
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.has_gnss
def has_gnss(self)
Definition: services.py:82
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.model_number_string
def model_number_string(self)
Definition: services.py:103
microstrain_inertial_rqt.utils.common.Monitor._message_timed_out
def _message_timed_out(self)
Definition: common.py:111
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.model_name
def model_name(self)
Definition: services.py:26
microstrain_inertial_rqt.utils.services.DeviceReportMonitor._is_gq7
_is_gq7
Definition: services.py:15
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.options_string
def options_string(self)
Definition: services.py:111
microstrain_inertial_rqt.utils.services.DeviceReportMonitor._has_dual_antenna
_has_dual_antenna
Definition: services.py:19
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.firmware_version_string
def firmware_version_string(self)
Definition: services.py:115
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.__init__
def __init__(self, node, node_name)
Definition: services.py:11
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.serial_number_string
def serial_number_string(self)
Definition: services.py:107
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.model_number
def model_number(self)
Definition: services.py:30
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.connected
def connected(self)
Definition: services.py:22
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.options
def options(self)
Definition: services.py:38
microstrain_inertial_rqt.utils.common.Monitor._get_val
def _get_val(self, val, default=_DEFAULT_VAL)
Definition: common.py:115
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.connected_string
def connected_string(self)
Definition: services.py:119
microstrain_inertial_rqt.utils.services.DeviceReportMonitor._is_gx5
_is_gx5
Definition: services.py:16
microstrain_inertial_rqt.utils.common.Monitor._get_small_boolean_icon_string
def _get_small_boolean_icon_string(self, val, default_val=_DEFAULT_VAL)
Definition: common.py:139
microstrain_inertial_rqt.utils.services.DeviceReportMonitor.has_dual_antenna
def has_dual_antenna(self)
Definition: services.py:94


microstrain_inertial_rqt
Author(s): Parker Hannifin Corp
autogenerated on Fri Apr 18 2025 02:52:41