@@ -59,22 +59,8 @@ def __init__(self, ip, netport=9000):
5959 self .calibration_parameters = calibration_parameters
6060 self .SERVER_IP = ip
6161 self .SERVER_PORT = netport
62- self .rasp = False
63- self .sock = self .connect_socket ()
64-
65- def connect (self , serialport = "/dev/ttyAMA0" , baudrate = "1000000" , timeout = '0.1' ):
66- """Connect the robot arm through the serial port and baud rate (Use only when connecting the pi version)
67-
68- Args:
69- serialport: (str) default /dev/ttyAMA0
70- baudrate: default 1000000
71- timeout: default 0.1
72-
73- """
7462 self .rasp = True
75- self ._write (serialport , "socket" )
76- self ._write (baudrate , "socket" )
77- self ._write (timeout , "socket" )
63+ self .sock = self .connect_socket ()
7864
7965 def connect_socket (self ):
8066 sock = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
@@ -115,12 +101,18 @@ def _mesg(self, genre, *args, **kwargs):
115101 ProtocolCode .GET_SPEED ,
116102 ProtocolCode .GET_ENCODER ,
117103 ProtocolCode .GET_BASIC_INPUT ,
118- ProtocolCode .GET_TOF_DISTANCE
104+ ProtocolCode .GET_TOF_DISTANCE ,
105+ ProtocolCode .GET_END_TYPE ,
106+ ProtocolCode .GET_MOVEMENT_TYPE ,
107+ ProtocolCode .GET_REFERENCE_FRAME ,
108+ ProtocolCode .GET_FRESH_MODE ,
109+ ProtocolCode .GET_GRIPPER_MODE ,
110+ ProtocolCode .GET_ERROR_INFO
119111 ]:
120112 return self ._process_single (res )
121113 elif genre in [ProtocolCode .GET_ANGLES ]:
122114 return [self ._int2angle (angle ) for angle in res ]
123- elif genre in [ProtocolCode .GET_COORDS ]:
115+ elif genre in [ProtocolCode .GET_COORDS , ProtocolCode . GET_TOOL_REFERENCE , ProtocolCode . GET_WORLD_REFERENCE ]:
124116 if res :
125117 r = []
126118 for idx in range (3 ):
@@ -130,11 +122,10 @@ def _mesg(self, genre, *args, **kwargs):
130122 return r
131123 else :
132124 return res
133- elif genre in [
134- ProtocolCode .GET_JOINT_MIN_ANGLE ,
135- ProtocolCode .GET_JOINT_MAX_ANGLE ,
136- ]:
137- return self ._int2angle (res [0 ]) if res else 0
125+ elif genre in [ProtocolCode .GET_SERVO_VOLTAGES ]:
126+ return [self ._int2coord (angle ) for angle in res ]
127+ elif genre in [ProtocolCode .GET_JOINT_MAX_ANGLE , ProtocolCode .GET_JOINT_MIN_ANGLE ]:
128+ return self ._int2coord (res [0 ])
138129 else :
139130 return res
140131 return None
0 commit comments