sensor_data.py
Go to the documentation of this file.
1 from .utils.widgets import MicrostrainWidget, MicrostrainPlugin
2 from .utils.subscribers import ImuMonitor, MagMonitor
3 
4 _WIDGET_NAME = 'SensorData'
5 
7 
8  def __init__(self, node):
9  # Initialize the parent class
10  super(SensorDataWidget, self).__init__(node, _WIDGET_NAME)
11 
12  def _configure(self):
13  # Set up the subscriber status monitors
14  self._imu_monitor = ImuMonitor(self._node, self._node_name, "imu/data")
15  self._mag_monitor = MagMonitor(self._node, self._node_name, "mag")
16 
17  def run(self):
18  # Update data common to all sensors
19  self._update_imu()
20 
21  # Magnetometer Only widgets (GQ7, GX5-45, GX5-25)
22  magnetometer_widgets = [
23  self.sensor_magnetometer_widget,
24  ]
25 
26  # Hide or show the widgets
27  self.hide_show_widgets(magnetometer_widgets, self._device_report_monitor.has_magnetometer)
28 
29  # Update device specific data
30  if self._device_report_monitor.has_magnetometer:
31  self._update_mag()
32 
33  def _update_imu(self):
34  # Accel
35  self.sensor_accel_x_label.setText(self._imu_monitor.accel_x_string)
36  self.sensor_accel_y_label.setText(self._imu_monitor.accel_y_string)
37  self.sensor_accel_z_label.setText(self._imu_monitor.accel_z_string)
38 
39  # Gyro
40  self.sensor_gyro_x_label.setText(self._imu_monitor.vel_x_string)
41  self.sensor_gyro_y_label.setText(self._imu_monitor.vel_y_string)
42  self.sensor_gyro_z_label.setText(self._imu_monitor.vel_z_string)
43 
44  def _update_mag(self):
45  self.sensor_magnetometer_x_label.setText(self._mag_monitor.x_string)
46  self.sensor_magnetometer_y_label.setText(self._mag_monitor.y_string)
47  self.sensor_magnetometer_z_label.setText(self._mag_monitor.z_string)
48 
49 
51 
52  def __init__(self, context):
53  # Initialize the parent class
54  super(SensorDataPlugin, self).__init__(context, _WIDGET_NAME, SensorDataWidget)


microstrain_inertial_rqt
Author(s): Parker Hannifin Corp
autogenerated on Wed Mar 22 2023 02:35:20