pybricks._common.IMU: Change settings setter.

This commit is contained in:
Laurens Valk
2023-04-21 10:42:30 +02:00
committed by laurensvalk
parent bb37b94f5e
commit b311c54261
8 changed files with 38 additions and 23 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
- Documented ``Motor.model``. This can be used to view the estimated motor
state and change its settings.
- Added `rotation`, `orientation`, `ready`, `stationary`
and `set_stationary_thresholds` methods to `IMU` class.
and `settings` methods to `IMU` class.
### Changed
- Change implementation status of `IMU.heading` and `IMU.reset_heading`. They
+2 -2
View File
@@ -29,8 +29,6 @@ Essential Hub
.. automethod:: pybricks.hubs::EssentialHub.imu.stationary
.. automethod:: pybricks.hubs::EssentialHub.imu.set_stationary_thresholds
.. automethod:: pybricks.hubs::EssentialHub.imu.up
.. automethod:: pybricks.hubs::EssentialHub.imu.tilt
@@ -47,6 +45,8 @@ Essential Hub
.. automethod:: pybricks.hubs::EssentialHub.imu.orientation
.. automethod:: pybricks.hubs::EssentialHub.imu.settings
.. rubric:: Using the battery
.. automethod:: pybricks.hubs::EssentialHub.battery.voltage
+2 -2
View File
@@ -63,8 +63,6 @@ Prime Hub / Inventor Hub
.. automethod:: pybricks.hubs::PrimeHub.imu.stationary
.. automethod:: pybricks.hubs::PrimeHub.imu.set_stationary_thresholds
.. automethod:: pybricks.hubs::PrimeHub.imu.up
.. automethod:: pybricks.hubs::PrimeHub.imu.tilt
@@ -81,6 +79,8 @@ Prime Hub / Inventor Hub
.. automethod:: pybricks.hubs::PrimeHub.imu.orientation
.. automethod:: pybricks.hubs::PrimeHub.imu.settings
.. rubric:: Using the speaker
.. automethod:: pybricks.hubs::PrimeHub.speaker.volume
+2 -2
View File
@@ -25,8 +25,6 @@ Technic Hub
.. automethod:: pybricks.hubs::TechnicHub.imu.stationary
.. automethod:: pybricks.hubs::TechnicHub.imu.set_stationary_thresholds
.. automethod:: pybricks.hubs::TechnicHub.imu.up
.. automethod:: pybricks.hubs::TechnicHub.imu.tilt
@@ -43,6 +41,8 @@ Technic Hub
.. automethod:: pybricks.hubs::TechnicHub.imu.orientation
.. automethod:: pybricks.hubs::TechnicHub.imu.settings
.. rubric:: Using the battery
.. automethod:: pybricks.hubs::TechnicHub.battery.voltage
+1 -1
View File
@@ -83,7 +83,7 @@ def test_hub_dot_imu_dot():
"ready",
"reset_heading",
"rotation",
"set_stationary_thresholds",
"settings",
"stationary",
"tilt",
"up",
+1 -1
View File
@@ -101,7 +101,7 @@ def test_hub_dot_imu_dot():
"ready",
"reset_heading",
"rotation",
"set_stationary_thresholds",
"settings",
"stationary",
"tilt",
"up",
+1 -1
View File
@@ -71,7 +71,7 @@ def test_hub_dot_imu_dot():
"ready",
"reset_heading",
"rotation",
"set_stationary_thresholds",
"settings",
"stationary",
"tilt",
"up",
+28 -13
View File
@@ -1012,27 +1012,42 @@ class IMU(Accelerometer):
moving.
"""
def set_stationary_thresholds(
self, angular_velocity: float, acceleration: float
@overload
def settings(
self,
angular_velocity_threshold: float = None,
acceleration_threshold: float = None,
) -> None:
"""set_stationary_thresholds(angular_velocity, acceleration)
...
When the angular velocity and acceleration measurements are below the
given threshold values for at least one second, the sensor is
considered stationary. This is when the sensor recalibrates itself.
@overload
def settings(self) -> Tuple[float, float]:
...
If you are in a noisy room with high ambient vibrations (such as a
robot competition hall), it is recommended to increase these values
slightly to give your robot the chance to calibrate properly.
def settings(self, *args):
"""
settings(angular_velocity_threshold, acceleration_threshold)
settings() -> Tuple[float, float]
To verify that your settings are working, test that
Configures the IMU settings. If no arguments are given,
this returns the current values.
The ``angular_velocity_threshold`` and ``acceleration_threshold``
define when the hub is considered stationary. If all
measurements stay below these thresholds for one second, the IMU
will recalibrate itself.
In a noisy room with high ambient vibrations (such as a
competition hall), it is recommended to increase the thresholds
slightly to give your robot the chance to calibrate.
To verify that your settings are working as expected, test that
the ``stationary()`` method gives ``False`` if your robot is moving,
and ``True`` if it is sitting still for at least a second.
Arguments:
angular_velocity (Number, deg/s): The threshold for angular
velocity. The default value is 1.5 deg/s.
acceleration (Number, mm/s²): The threshold for angular
angular_velocity_threshold (Number, deg/s): The threshold for
angular velocity. The default value is 1.5 deg/s.
acceleration_threshold (Number, mm/s²): The threshold for angular
velocity. The default value is 250 mm/s².
"""