-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Servo feedback for physical robots (#389)
- Loading branch information
Showing
19 changed files
with
482 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
..._robot_physical/revolve2/modular_robot_physical/remote/_active_hinge_sensor_state_impl.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from revolve2.modular_robot.sensor_state import ActiveHingeSensorState | ||
|
||
|
||
class ActiveHingeSensorStateImpl(ActiveHingeSensorState): | ||
"""ActiveHingeSensorState implementation for physical robots.""" | ||
|
||
_position: float | ||
|
||
def __init__(self, position: float) -> None: | ||
""" | ||
Initialize this object. | ||
:param position: The position of the active hinge. | ||
""" | ||
self._position = position | ||
|
||
@property | ||
def position(self) -> float: | ||
""" | ||
Get the measured position of the active hinge. | ||
:returns: The measured position. | ||
""" | ||
return self._position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...ot_physical/revolve2/modular_robot_physical/remote/_modular_robot_sensor_state_impl_v2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from revolve2.modular_robot.body.base import ActiveHingeSensor | ||
from revolve2.modular_robot.sensor_state import ( | ||
ActiveHingeSensorState, | ||
ModularRobotSensorState, | ||
) | ||
|
||
from .._uuid_key import UUIDKey | ||
from ._active_hinge_sensor_state_impl import ActiveHingeSensorStateImpl | ||
|
||
|
||
class ModularRobotSensorStateImplV2(ModularRobotSensorState): | ||
"""Implementation of ModularRobotSensorState for v2 robots.""" | ||
|
||
_hinge_sensor_mapping: dict[UUIDKey[ActiveHingeSensor], int] | ||
_positions: dict[int, float] | ||
|
||
def __init__( | ||
self, | ||
hinge_sensor_mapping: dict[UUIDKey[ActiveHingeSensor], int], | ||
positions: dict[int, float], | ||
) -> None: | ||
""" | ||
Initialize this object. | ||
:param hinge_sensor_mapping: Mapping from active hinge sensors to pin ids. | ||
:param positions: Position of hinges accessed by pin id. | ||
""" | ||
self._hinge_sensor_mapping = hinge_sensor_mapping | ||
self._positions = positions | ||
|
||
def get_active_hinge_sensor_state( | ||
self, sensor: ActiveHingeSensor | ||
) -> ActiveHingeSensorState: | ||
""" | ||
Get sensor states for Hinges. | ||
:param sensor: The sensor to query. | ||
:returns: The Sensor State. | ||
""" | ||
return ActiveHingeSensorStateImpl( | ||
self._positions[self._hinge_sensor_mapping[UUIDKey(sensor)]] | ||
) |
Oops, something went wrong.