Skip to content

Commit 7ef1721

Browse files
committed
Added api for 350 and fixed some bugs
1 parent e487abf commit 7ef1721

File tree

3 files changed

+322
-5
lines changed

3 files changed

+322
-5
lines changed

docs/README.md

Lines changed: 124 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ We support Python2, Python3.5 or later.
4444
- [Running status and Settings](#running-status-and-settings)
4545
- [get_speed](#get_speed)
4646
- [set_speed](#set_speed)
47+
- [set_joint_min](#set_joint_min)
48+
- [set_joint_max](#set_joint_max)
4749
- [get_joint_min_angle](#get_joint_min_angle)
4850
- [get_joint_max_angle](#get_joint_max_angle)
4951
- [Servo control](#servo-control)
@@ -65,13 +67,22 @@ We support Python2, Python3.5 or later.
6567
- [set_gripper_value](#set_gripper_value)
6668
- [set_gripper_ini](#set_gripper_ini)
6769
- [is_gripper_moving](#is_gripper_moving)
68-
- [Basic](#basic)
6970
- [get_basic_input](#get_basic_input)
7071
- [set_basic_output](#set_basic_output)
7172
- [set_ssid_pwd](#set_ssid_pwd)
7273
- [get_ssid_pwd](#get_ssid_pwd)
7374
- [set_server_port](#set_server_port)
7475
- [get_tof_distance](#get_tof_distance)
76+
- [get_tool_reference](#get_tool_reference)
77+
- [set_tool_reference](#set_tool_reference)
78+
- [set_world_reference](#set_world_reference)
79+
- [get_world_reference](#get_world_reference)
80+
- [set_reference_frame](#set_reference_frame)
81+
- [get_reference_frame](#get_reference_frame)
82+
- [set_movement_type](#set_movement_type)
83+
- [get_movement_type](#get_movement_type)
84+
- [set_end_type](#set_end_type)
85+
- [get_movement_type](#get_movement_type-1)
7586
- [Raspberry pi -- GPIO](#raspberry-pi----gpio)
7687
- [gpio_init](#gpio_init)
7788
- [gpio_output](#gpio_output)
@@ -453,6 +464,24 @@ from pymycobot import MyCobot
453464

454465
- **Parameters**: speed: (`int`) 0 ~ 100
455466

467+
### set_joint_min
468+
469+
- **Prototype**: `set_joint_min(id, angle)`
470+
- **Description**: Sets the minimum angle for the specified joint.
471+
472+
- **Parameters**:
473+
- `id`: (`int`) joint id 1-6.
474+
- `angle`: 0 - 180.
475+
476+
### set_joint_max
477+
478+
- **Prototype**: `set_joint_max(id, angle)`
479+
- **Description**: Sets the maximum angle of the specified joint.
480+
481+
- **Parameters**:
482+
- `id`: (`int`) joint id 1-6.
483+
- `angle`: 0 - 180.
484+
456485
### get_joint_min_angle
457486

458487
- **Prototype**: `get_joint_min_angle()`
@@ -651,8 +680,6 @@ from pymycobot import MyCobot
651680
- `1` : is moving
652681
- `-1`: error data
653682

654-
## Basic
655-
656683
### get_basic_input
657684

658685
- **Prototype**: `get_basic_input(pin_no)`
@@ -703,7 +730,7 @@ from pymycobot import MyCobot
703730

704731
- **Parameters**
705732

706-
- `port` (`int`) The new connection port of the server.
733+
- `port`: (`int`) The new connection port of the server.
707734

708735
### get_tof_distance
709736

@@ -713,6 +740,99 @@ from pymycobot import MyCobot
713740

714741
- **Return**: `int` The unit is mm.
715742

743+
### get_tool_reference
744+
745+
- **Prototype**: `get_tool_reference()`
746+
747+
- **Description**: Get tool coordinate system.
748+
749+
- **Return**: `list` [x, y, z, rx, ry, rz].
750+
751+
### set_tool_reference
752+
753+
- **Prototype**: `set_tool_reference(coords)`
754+
755+
- **Description**: Set tool coordinate system.
756+
757+
- **Parameters**:
758+
- `coords`: (`list`) [x, y, z, rx, ry, rz].
759+
760+
### set_world_reference
761+
762+
- **Prototype**: `set_world_reference(coords)`
763+
764+
- **Description**: Set world coordinate system.
765+
766+
- **Parameters**:
767+
- `coords`: (`list`) [x, y, z, rx, ry, rz].
768+
769+
### get_world_reference
770+
771+
- **Prototype**: `get_world_reference()`
772+
773+
- **Description**: Get world coordinate system.
774+
775+
- **Return**: `list` [x, y, z, rx, ry, rz].
776+
777+
### set_reference_frame
778+
779+
- **Prototype**: `set_reference_frame(rftype)`
780+
781+
- **Description**: Set base coordinate system.
782+
783+
- **Parameters**:
784+
- `rftype`: 0 - base 1 - tool.
785+
786+
### get_reference_frame
787+
788+
- **Prototype**: `get_reference_frame()`
789+
790+
- **Description**: Get base coordinate system.
791+
792+
- **Return**: 0 - base 1 - tool.
793+
794+
### set_movement_type
795+
796+
- **Prototype**: `set_movement_type(move_type)`
797+
798+
- **Description**: Set movement type.
799+
800+
- **Parameters**:
801+
- `move_type`: 1 - movel, 0 - moveJ.
802+
803+
### get_movement_type
804+
805+
- **Prototype**: `get_movement_type()`
806+
807+
- **Description**: Get movement type.
808+
809+
- **Return**: 1 - movel, 0 - moveJ.
810+
811+
### set_end_type
812+
813+
- **Prototype**: `set_end_type(end)`
814+
815+
- **Description**: Set end coordinate system.
816+
817+
- **Parameters**:
818+
- `end`: 0 - flange, 1 - tool.
819+
820+
### get_movement_type
821+
822+
- **Prototype**: `get_movement_type()`
823+
824+
- **Description**: Get movement type.
825+
826+
- **Return**: 0 - flange, 1 - tool.
827+
828+
<!-- ### get_plan_speed
829+
830+
- **Prototype**: `get_movement_type()`
831+
832+
- **Description**: Get movement type.
833+
834+
- **Return**: 0 - flange, 1 - tool. -->
835+
716836
## Raspberry pi -- GPIO
717837

718838
### gpio_init

pymycobot/common.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class ProtocolCode(object):
5353
GET_ACCELERATION = 0x44
5454
GET_JOINT_MIN_ANGLE = 0x4A
5555
GET_JOINT_MAX_ANGLE = 0x4B
56+
SET_JOINT_MIN = 0x4C
57+
SET_JOINT_MAX = 0x4D
5658

5759
# SERVO CONTROL
5860
IS_SERVO_ENABLE = 0x50
@@ -93,7 +95,31 @@ class ProtocolCode(object):
9395

9496
# Get the measured distance
9597
GET_TOF_DISTANCE = 0xC0
96-
98+
99+
# Coordinate transformation
100+
SET_TOOL_REFERENCE = 0x81
101+
GET_TOOL_REFERENCE = 0x82
102+
SET_WORLD_REFERENCE = 0x83
103+
GET_WORLD_REFERENCE = 0x84
104+
SET_REFERENCE_FRAME = 0x85
105+
GET_REFERENCE_FRAME = 0x86
106+
SET_MOVEMENT_TYPE = 0x87
107+
GET_MOVEMENT_TYPE = 0x88
108+
SET_END_TYPE = 0x89
109+
GET_END_TYPE = 0x8A
110+
111+
# planning speed
112+
GET_PLAN_SPEED = 0xD0
113+
GET_PLAN_ACCELERATION = 0xD1
114+
SET_PLAN_SPEED = 0xD2
115+
SET_PLAN_ACCELERATION = 0xD3
116+
117+
# Motor status read
118+
GET_SERVO_SPEED = 0xE1
119+
GET_SERVO_CURRENTS = 0xE2
120+
GET_SERVO_VOLTAGES = 0xE3
121+
GET_SERVO_STATUS = 0xE4
122+
GET_SERVO_TEMPS = 0xE5
97123

98124
class DataProcessor(object):
99125
# Functional approach
@@ -183,10 +209,19 @@ def _process_received(self, data, genre):
183209
one = valid_data[header_i: header_i + 2]
184210
res.append(self._decode_int16(one))
185211
elif data_len == 2:
212+
if genre in [ProtocolCode.GET_PLAN_SPEED, ProtocolCode.GET_PLAN_ACCELERATION]:
213+
return [self._decode_int8(valid_data[0:1]), self._decode_int8(valid_data[1:])]
186214
if genre in [ProtocolCode.IS_SERVO_ENABLE]:
187215
return [self._decode_int8(valid_data[1:2])]
188216
res.append(self._decode_int16(valid_data))
217+
elif data_len == 3:
218+
res.append(self._decode_int16(valid_data[1:]))
189219
else:
220+
if genre in [ProtocolCode.GET_SERVO_VOLTAGES, ProtocolCode.GET_SERVO_STATUS, ProtocolCode.GET_SERVO_TEMPS]:
221+
for i in range(data_len):
222+
data1 = self._decode_int8(valid_data[i:i+1])
223+
res.append(256+data1 if data1 <0 else data1)
224+
return res
190225
res.append(self._decode_int8(valid_data))
191226
return res
192227

0 commit comments

Comments
 (0)