Python =========== Download and Installation ------------------------- The Python driver is available as a **PyPI package** for easy installation. .. raw:: html

Supported platforms:

Installation using pip:

.. code-block:: bash pip install bota-driver .. raw:: html
Usage Examples --------------- .. _py_usage_examples: We provide a complete set of examples to **get yourself started** with the Python driver. .. raw:: html

What you'll find in the examples:

→ Python Driver Examples Repository ←
API description ------------------ Custom data types ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. raw:: html
DriverState Enum
Represents the internal lifecycle states of the BotaDriver. .. py:class:: DriverState - ``UNCONFIGURED`` – Primary state - ``INACTIVE`` – Primary state - ``ACTIVE`` – Primary state - ``FINALIZED`` – Primary state - ``CONFIGURING`` – Transition state - ``ACTIVATING`` – Transition state - ``DEACTIVATING`` – Transition state - ``CLEANING_UP`` – Transition state - ``SHUTTING_DOWN`` – Transition state - ``ERROR_PROCESSING`` – Transition state .. raw:: html
DataStatus Class
Represents the status flags for a single data frame. .. py:class:: DataStatus .. py:attribute:: val :type: int Combined 16-bit value of the status flags. .. py:attribute:: throttled :type: bool Indicates that the data was rate-limited. .. py:attribute:: overrange :type: bool Indicates that the data exceeded sensor limits. .. py:attribute:: invalid :type: bool Indicates that the data is invalid or corrupt. .. py:attribute:: raw :type: bool Indicates that the data is unprocessed raw sensor output. .. raw:: html
BotaFrame Class
Represents a full frame, including status, wrench, imu data, temperature and timestamp. .. py:class:: BotaFrame(status: DataStatus, force: list[float], torque: list[float], timestamp: int, temperature: float, acceleration: list[float], angular_rate: list[float]) .. py:method:: __init__(status: DataStatus, force: list[float], torque: list[float], timestamp: int, temperature: float, acceleration: list[float], angular_rate: list[float]) Constructs a frame .. py:attribute:: status :type: DataStatus Bitfield status information about the frame. .. py:attribute:: force :type: list[float] Force vector ``[Fx, Fy, Fz]`` in Newtons. .. py:attribute:: torque :type: list[float] Torque vector ``[Tx, Ty, Tz]`` in Newton-meters. .. py:attribute:: timestamp :type: int Timestamp of the frame in microseconds since boot. .. py:attribute:: temperature :type: float Internal temperature in degrees Celsius. .. py:attribute:: acceleration :type: list[float] Linear acceleration ``[Ax, Ay, Az]`` in m/s². .. py:attribute:: angular_rate :type: list[float] Angular velocity ``[Wx, Wy, Wz]`` in rad/s. BotaDriver class public interface ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. py:class:: BotaDriver .. raw:: html
Constructor and destructor
.. py:method:: __init__(config_path) Constructor initializing the driver using a path to a JSON configuration file. :param config_path: Path to the JSON configuration file. :type config_path: str .. py:method:: __del__() Default destructor. .. raw:: html
Life cycle management methods
.. py:method:: configure() Transitions the driver from ``UNCONFIGURED`` to ``INACTIVE``, passing through the ``CONFIGURING`` transition. :returns: ``false`` if called from the wrong state or transition failed; otherwise, ``true``. :rtype: bool .. py:method:: activate() Transitions the driver from ``INACTIVE`` to ``ACTIVE``, passing through the ``ACTIVATING`` transition. :returns: ``false`` if called from the wrong state or transition failed; otherwise, ``true``. :rtype: bool .. py:method:: deactivate() Transitions the driver from ``ACTIVE`` to ``INACTIVE``, passing through the ``DEACTIVATING`` transition. :returns: ``false`` if called from the wrong state or transition failed; otherwise, ``true``. :rtype: bool .. py:method:: cleanup() Transitions the driver from ``INACTIVE`` to ``UNCONFIGURED``, passing through the ``CLEANING_UP`` transition. :returns: ``false`` if called from the wrong state or transition failed; otherwise, ``true``. :rtype: bool .. py:method:: shutdown() Shuts down the driver and releases any associated resources. :returns: ``false`` if something failed; otherwise, ``true``. :rtype: bool .. raw:: html
User functions
.. py:method:: tare() Computes and applies wrench offsets to zero the output. Can only be called in the ``INACTIVE`` state. :returns: ``false`` if called from the wrong state or something failed; otherwise, ``true``. :rtype: bool .. py:method:: read_frame() Returns the most recent available frame. Must be called in the ``ACTIVE`` state; otherwise, an error is raised. :returns: A `BotaFrame` object containing the latest sensor data. :rtype: BotaFrame .. py:method:: read_frame_blocking() Blocks until a new frame is available, then returns it. Must be called in the ``ACTIVE`` state; otherwise, an error is raised. :returns: A `BotaFrame` object containing the newly received sensor data. :rtype: BotaFrame .. raw:: html
Getters
.. py:method:: get_driver_state() Returns the current internal driver state. :returns: The current state of the driver. :rtype: DriverState .. py:method:: get_expected_timestep() Returns the expected update interval for sensor data. :returns: The expected timestep between consecutive sensor data frames. :rtype: datetime.timedelta .. py:method:: get_driver_version_string() Returns a string representation of the driver version in the format ``X.Y.Z``. :returns: A string representing the driver version. :rtype: str