Base
ADCBase
¶
Bases: SensorBase
, ABC
Abstract base class for ADC (Analog-to-Digital Converter) sensors.
ADC sensors are used to convert analog signals into digital data.
Source code in opensourceleg/sensors/base.py
EncoderBase
¶
Bases: SensorBase
, ABC
Abstract base class for encoder sensors.
Encoders are used to measure position and velocity.
Source code in opensourceleg/sensors/base.py
position: float
abstractmethod
property
¶
Get the current encoder position.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The current position value. |
velocity: float
abstractmethod
property
¶
Get the current encoder velocity.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The current velocity value. |
__init__(tag, offline=False, **kwargs)
¶
__repr__()
¶
Return a string representation of the encoder sensor.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
"EncoderBase" |
IMUBase
¶
Bases: SensorBase
, ABC
Abstract base class for Inertial Measurement Unit (IMU) sensors.
IMUs typically provide acceleration and gyroscopic data.
Source code in opensourceleg/sensors/base.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
acc_x: float
abstractmethod
property
¶
Get the estimated linear acceleration along the x-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Acceleration in m/s^2 along the x-axis. |
acc_y: float
abstractmethod
property
¶
Get the estimated linear acceleration along the y-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Acceleration in m/s^2 along the y-axis. |
acc_z: float
abstractmethod
property
¶
Get the estimated linear acceleration along the z-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Acceleration in m/s^2 along the z-axis. |
gyro_x: float
abstractmethod
property
¶
Get the gyroscopic measurement along the x-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Angular velocity in rad/s along the x-axis. |
gyro_y: float
abstractmethod
property
¶
Get the gyroscopic measurement along the y-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Angular velocity in rad/s along the y-axis. |
gyro_z: float
abstractmethod
property
¶
Get the gyroscopic measurement along the z-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Angular velocity in rad/s along the z-axis. |
LoadcellBase
¶
Bases: SensorBase
, ABC
Abstract base class for load cell sensors.
Load cells are used to measure forces and moments.
Source code in opensourceleg/sensors/base.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
fx: float
abstractmethod
property
¶
Get the force along the x-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The force measured along the x-axis. |
fy: float
abstractmethod
property
¶
Get the force along the y-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The force measured along the y-axis. |
fz: float
abstractmethod
property
¶
Get the force along the z-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The force measured along the z-axis. |
is_calibrated: bool
abstractmethod
property
¶
Check if the load cell sensor is calibrated.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if calibrated, False otherwise. |
mx: float
abstractmethod
property
¶
Get the moment about the x-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The moment measured about the x-axis. |
my: float
abstractmethod
property
¶
Get the moment about the y-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The moment measured about the y-axis. |
mz: float
abstractmethod
property
¶
Get the moment about the z-axis.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The moment measured about the z-axis. |
__init__(tag, offline=False, **kwargs)
¶
__repr__()
¶
Return a string representation of the load cell sensor.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
"LoadcellBase" |
calibrate()
abstractmethod
¶
Calibrate the load cell sensor.
Implementations should perform the calibration procedure to ensure accurate readings.
reset()
abstractmethod
¶
Reset the load cell sensor.
Implementations should reset the sensor state and any calibration data.
SensorBase
¶
Bases: ABC
Abstract base class for sensors.
Defines the common interface for sensors including starting, stopping, updating, and streaming status.
Source code in opensourceleg/sensors/base.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
data: Any
abstractmethod
property
¶
Get the sensor data.
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The current data from the sensor. |
is_offline: bool
property
¶
Get the offline status of the sensor.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the sensor is offline, False otherwise. |
is_streaming: bool
abstractmethod
property
¶
Check if the sensor is currently streaming.
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the sensor is streaming, False otherwise. |
tag: str
property
¶
__enter__()
¶
Enter the runtime context for the sensor.
This method calls start() and returns the sensor instance.
Returns:
Name | Type | Description |
---|---|---|
SensorBase |
SensorBase
|
The sensor instance. |
Source code in opensourceleg/sensors/base.py
__exit__(exc_type, exc_value, traceback)
¶
Exit the runtime context for the sensor.
This method calls stop() to shut down the sensor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc_type |
Any
|
Exception type if raised. |
required |
exc_value |
Any
|
Exception value if raised. |
required |
traceback |
Any
|
Traceback if an exception occurred. |
required |
Source code in opensourceleg/sensors/base.py
__repr__()
¶
Return a string representation of the sensor.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string identifying the sensor class. |
start()
abstractmethod
¶
Start the sensor streaming.
Implementations should handle initializing the sensor and beginning data acquisition.
stop()
abstractmethod
¶
Stop the sensor streaming.
Implementations should handle gracefully shutting down the sensor.
update()
abstractmethod
¶
Update the sensor state or data.
Implementations should refresh or poll the sensor data as needed.
SensorNotStreamingException
¶
Bases: Exception
Exception raised when an operation is attempted on a sensor that is not streaming.
This exception indicates that the sensor is not actively streaming data.
Source code in opensourceleg/sensors/base.py
__init__(sensor_name='Sensor')
¶
Initialize the SensorNotStreamingException.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sensor_name |
str
|
The name or identifier of the sensor. Defaults to "Sensor". |
'Sensor'
|
Source code in opensourceleg/sensors/base.py
check_sensor_stream(func)
¶
Decorator to ensure that a sensor is streaming before executing the decorated method.
If the sensor is not streaming, a SensorNotStreamingException is raised.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable
|
The sensor method to be wrapped. |
required |
Returns:
Name | Type | Description |
---|---|---|
Callable |
Callable
|
The wrapped method that checks streaming status before execution. |