1+ from __future__ import annotations
2+
13import ast
24import math
35import time
4- from typing import Any , Dict , List , Union
6+ from typing import Any
57
8+ from armctl .templates import Commands , Properties
9+ from armctl .templates import SocketController as SCT
610from armctl .utils import CommandCheck as cc
711from armctl .utils import units as uu
8- from armctl .templates import Commands
9- from armctl .templates import Properties
10- from armctl .templates import SocketController as SCT
1112
1213### Notes ###
1314# Command Format: dictionaries/json strings.
@@ -30,9 +31,7 @@ class Jaka(SCT, Commands, Properties):
3031 MAX_JOINT_VELOCITY = uu .deg2rad (180 ) # rad/s
3132 MAX_JOINT_ACCELERATION = uu .deg2rad (720 ) # rad/s^2
3233
33- def __init__ (
34- self , ip : str , port : Union [int , tuple [int , int ]] = (10_001 , 10_000 )
35- ):
34+ def __init__ (self , ip : str , port : int | tuple [int , int ] = (10_001 , 10_000 )):
3635 super ().__init__ (ip , port )
3736
3837 def _response_handler (self , response : str ) -> Any :
@@ -41,7 +40,7 @@ def _response_handler(self, response: str) -> Any:
4140 except (ValueError , SyntaxError ) as e :
4241 raise RuntimeError (f"Failed to parse response: { response } " ) from e
4342
44- def _send_and_check (self , cmd_dict : Dict [str , Any ]) -> Dict [str , Any ]:
43+ def _send_and_check (self , cmd_dict : dict [str , Any ]) -> dict [str , Any ]:
4544 resp = self ._response_handler (self .send_command (str (cmd_dict )))
4645 if not (
4746 isinstance (resp , dict )
@@ -76,7 +75,7 @@ def sleep(self, seconds: float) -> None:
7675 time .sleep (seconds )
7776
7877 def move_joints (
79- self , pos : List [float ], speed : float = 0.25 , acceleration : float = 0.1
78+ self , pos : list [float ], speed : float = 0.25 , acceleration : float = 0.1
8079 ) -> None :
8180 """
8281 Move the robot to the specified joint positions.
@@ -101,7 +100,7 @@ def move_joints(
101100 self ._send_and_check (cmd )
102101
103102 def move_cartesian (
104- self , pose : List [float ], speed : float = 0.25 , acceleration : float = 0.0
103+ self , pose : list [float ], speed : float = 0.25 , acceleration : float = 0.0
105104 ) -> None :
106105 """
107106 Move the robot to the specified cartesian position.
@@ -124,7 +123,7 @@ def move_cartesian(
124123 }
125124 self ._send_and_check (cmd )
126125
127- def get_joint_positions (self ) -> List [float ]:
126+ def get_joint_positions (self ) -> list [float ]:
128127 """
129128 Get the current joint positions of the robot.
130129 Returns
@@ -137,7 +136,7 @@ def get_joint_positions(self) -> List[float]:
137136 response = self ._send_and_check (cmd )
138137 return [math .radians (angle ) for angle in response ["joint_pos" ]]
139138
140- def get_cartesian_position (self ) -> List [float ]:
139+ def get_cartesian_position (self ) -> list [float ]:
141140 """
142141 Retrieves the current Cartesian position of the robot's tool center point (TCP).
143142 Returns
@@ -154,7 +153,7 @@ def stop_motion(self) -> None:
154153 cc .stop_motion ()
155154 self ._send_and_check ({"cmdName" : "stop_program" })
156155
157- def get_robot_state (self ) -> Dict [str , Any ]:
156+ def get_robot_state (self ) -> dict [str , Any ]:
158157 """
159158 Get the current state of the robot.
160159
0 commit comments