reachy2_sdk.orbita.orbita_axis

Reachy OrbitaAxis module.

Handles all specific methods to OrbitaAxis.

 1"""Reachy OrbitaAxis module.
 2
 3Handles all specific methods to OrbitaAxis.
 4"""
 5
 6from typing import Dict
 7
 8from google.protobuf.wrappers_pb2 import FloatValue
 9
10from .utils import to_position
11
12
13class OrbitaAxis:
14    """The OrbitaAxis class represents any Orbita3d or Orbita2d axis.
15
16    The OrbitaAxis class is used to store the up-to-date state of the axis, especially:
17    - its present speed (RO)
18    - its present load (RO)
19    """
20
21    def __init__(self, initial_state: Dict[str, FloatValue]) -> None:
22        """Initialize the axis with its initial state.
23
24        Args:
25            initial_state: A dictionary containing the initial state values for the axis. The keys should include
26                "present_speed" and "present_load", with corresponding FloatValue objects as values.
27        """
28        self._update_with(initial_state)
29
30    @property
31    def present_speed(self) -> float:
32        """Get the present speed of the axis in radians per second."""
33        return to_position(self._present_speed)
34
35    @property
36    def present_load(self) -> float:
37        """Get the present load of the axis in Newtons."""
38        return float(self._present_load)
39
40    def _update_with(self, new_state: Dict[str, FloatValue]) -> None:
41        """Update the present speed and load of the axis with new state values.
42
43        Args:
44            new_state: A dictionary containing the new state values for the axis. The keys should include
45                "present_speed" and "present_load", with corresponding FloatValue objects as values.
46        """
47        self._present_speed = new_state["present_speed"].value
48        self._present_load = new_state["present_load"].value
class OrbitaAxis:
14class OrbitaAxis:
15    """The OrbitaAxis class represents any Orbita3d or Orbita2d axis.
16
17    The OrbitaAxis class is used to store the up-to-date state of the axis, especially:
18    - its present speed (RO)
19    - its present load (RO)
20    """
21
22    def __init__(self, initial_state: Dict[str, FloatValue]) -> None:
23        """Initialize the axis with its initial state.
24
25        Args:
26            initial_state: A dictionary containing the initial state values for the axis. The keys should include
27                "present_speed" and "present_load", with corresponding FloatValue objects as values.
28        """
29        self._update_with(initial_state)
30
31    @property
32    def present_speed(self) -> float:
33        """Get the present speed of the axis in radians per second."""
34        return to_position(self._present_speed)
35
36    @property
37    def present_load(self) -> float:
38        """Get the present load of the axis in Newtons."""
39        return float(self._present_load)
40
41    def _update_with(self, new_state: Dict[str, FloatValue]) -> None:
42        """Update the present speed and load of the axis with new state values.
43
44        Args:
45            new_state: A dictionary containing the new state values for the axis. The keys should include
46                "present_speed" and "present_load", with corresponding FloatValue objects as values.
47        """
48        self._present_speed = new_state["present_speed"].value
49        self._present_load = new_state["present_load"].value

The OrbitaAxis class represents any Orbita3d or Orbita2d axis.

The OrbitaAxis class is used to store the up-to-date state of the axis, especially:

  • its present speed (RO)
  • its present load (RO)
OrbitaAxis(initial_state: Dict[str, google.protobuf.wrappers_pb2.FloatValue])
22    def __init__(self, initial_state: Dict[str, FloatValue]) -> None:
23        """Initialize the axis with its initial state.
24
25        Args:
26            initial_state: A dictionary containing the initial state values for the axis. The keys should include
27                "present_speed" and "present_load", with corresponding FloatValue objects as values.
28        """
29        self._update_with(initial_state)

Initialize the axis with its initial state.

Arguments:
  • initial_state: A dictionary containing the initial state values for the axis. The keys should include "present_speed" and "present_load", with corresponding FloatValue objects as values.
present_speed: float
31    @property
32    def present_speed(self) -> float:
33        """Get the present speed of the axis in radians per second."""
34        return to_position(self._present_speed)

Get the present speed of the axis in radians per second.

present_load: float
36    @property
37    def present_load(self) -> float:
38        """Get the present load of the axis in Newtons."""
39        return float(self._present_load)

Get the present load of the axis in Newtons.