Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cbiering committed Dec 20, 2024
1 parent bbff5db commit 66a526b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 8 additions & 4 deletions examples/01_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio

from nova import Nova


Expand All @@ -10,16 +9,21 @@ async def main():
controller = controllers[0]
motion_group = controller[0]

tcp_names = await motion_group.tcp_names()
print(tcp_names)

tcp = tcp_names[0]

# Current motion group state
state = await motion_group.get_state("Flange")
state = await motion_group.get_state(tcp)
print(state)

# Current joints positions
joints = await motion_group.joints("Flange")
joints = await motion_group.joints()
print(joints)

# Current TCP pose
tcp_pose = await motion_group.tcp_pose("Flange")
tcp_pose = await motion_group.tcp_pose(tcp)
print(tcp_pose)


Expand Down
7 changes: 5 additions & 2 deletions nova/core/motion_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ async def get_state(self, tcp: str | None) -> wb.models.MotionGroupStateResponse
)
return response

async def joints(self, tcp: str) -> wb.models.Joints:
async def joints(self, tcp: str | None = None) -> wb.models.Joints:
state = await self.get_state(tcp=tcp)
return state.state.joint_position

Expand All @@ -184,7 +184,10 @@ async def tcp_pose(self, tcp: str) -> Pose:
return Pose(state.state.tcp_pose)

async def tcps(self) -> list[wb.models.RobotTcp]:
return (await self._api_gateway.motion_group_infos_api.list_tcps()).tcps
response = await self._api_gateway.motion_group_infos_api.list_tcps(
cell=self._cell, motion_group=self.motion_group_id
)
return response.tcps

async def tcp_names(self) -> list[str]:
return [tcp.id for tcp in await self.tcps()]
3 changes: 1 addition & 2 deletions nova/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ def __init__(
if host is None:
host = config("NOVA_API", default=INTERNAL_CLUSTER_NOVA_API)

print()

if username is None:
username = config("NOVA_USERNAME", default=None)

Expand All @@ -93,6 +91,7 @@ def __init__(
)

self._api_client = wb.ApiClient(api_client_config)
self._host = host

# Use the intercept function to wrap each API client
self.controller_api = intercept(wb.ControllerApi(api_client=self._api_client))
Expand Down

0 comments on commit 66a526b

Please sign in to comment.