Skip to content

Commit

Permalink
Update airo-tulip to 0.0.5 (align drives)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-decoster committed Aug 22, 2024
1 parent a131a71 commit bb00fa1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
27 changes: 22 additions & 5 deletions airo-robots/airo_robots/drives/hardware/kelo_robile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
from functools import partial

from airo_tulip.platform_driver import PlatformDriverType
from airo_tulip.server.kelo_robile import KELORobile as KELORobileClient
Expand All @@ -24,12 +25,28 @@ def __init__(self, robot_ip: str, robot_port: int):
robot_port: Port to connect on."""
self._kelo_robile = KELORobileClient(robot_ip, robot_port)

def set_platform_velocity_target(self, x: float, y: float, a: float, timeout: float,
align_drives_first: bool = False) -> AwaitableAction:
if align_drives_first:
self._kelo_robile.set_platform_velocity_target(x, y, a, timeout=1.0, instantaneous=False,
only_align_drives=True)
def align_drives(self, x: float, y: float, a: float, timeout: float = 1.0) -> AwaitableAction:
"""Align all drives for driving in a direction given by the linear and angular velocities.
Beware that sending any other velocity commands before the awaitable is done may cause unexpected behaviour,
as this affects the "aligned" condition.
Args:
x: The x velocity (linear, m/s).
y: The y velocity (linear, m/s)
a: The angular velocity (rad/s).
timeout: The awaitable will finish after this time at the latest.
Returns:
An AwaitableAction which will check if the drives are aligned, or if the timeout has expired."""
self._kelo_robile.align_drives(x, y, a, timeout=timeout)

def aligned_awaitable(start_time: float) -> bool:
return self._kelo_robile.are_drives_aligned() or time.time() > start_time + timeout

return AwaitableAction(partial(aligned_awaitable, time.time()))

def set_platform_velocity_target(self, x: float, y: float, a: float, timeout: float) -> AwaitableAction:
self._kelo_robile.set_platform_velocity_target(x, y, a, timeout=timeout, instantaneous=True)

def timeout_awaitable() -> bool:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
"""code for manual testing of mobile robot base class implementations.
"""
from airo_robots.drives.mobile_robot import MobileRobot
from airo_robots.drives.hardware.kelo_robile import KELORobile


def manually_test_robot_implementation(robot: MobileRobot) -> None:
if isinstance(robot, KELORobile):
input("robot will rotate drives")
robot.align_drives(0.1, 0.0, 0.0, 1.0).wait()

input("robot will now move forward 10cm")
robot.set_platform_velocity_target(0.1, 0.0, 0.0, 1.0).wait()

Expand Down
2 changes: 1 addition & 1 deletion airo-robots/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"click",
"airo-typing",
"airo-spatial-algebra",
"airo-tulip==0.0.4",
"airo-tulip==0.0.5",
],
packages=setuptools.find_packages(),
package_data={"airo_robots": ["py.typed"]},
Expand Down

0 comments on commit bb00fa1

Please sign in to comment.