Skip to content

Commit

Permalink
save code
Browse files Browse the repository at this point in the history
  • Loading branch information
anla-xu committed Oct 17, 2023
1 parent 8ced525 commit d0d08cd
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 27 deletions.
6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ We support Python2, Python3.5 or later.
- [get\_plan\_acceleration](#get_plan_acceleration)
- [set\_plan\_speed](#set_plan_speed)
- [set\_plan\_acceleration](#set_plan_acceleration)
- [set\_gservo\_round](#move_round)
- [move\_round](#move_round)
- [get\_basic\_version](#get_basic_version)
- [set\_communicate\_mode](#set_transponder_mode)
- [set\_transponder\_mode](#set_transponder_mode)
- [get\_servo\_speeds](#get_servo_speeds)
- [get\_servo\_currents](#get_servo_currents)
- [get\_servo\_voltages](#get_servo_voltages)
Expand All @@ -112,7 +112,7 @@ We support Python2, Python3.5 or later.
- [set\_solution\_angles](#set_solution_angles)
- [joint\_brake](#joint_brake)
- [get\_transponder\_mode](#get_transponder_mode)
- [set\_transponder\_mode](#set_transponder_mode)
- [set\_transponder\_mode](#set_transponder_mode-1)
- [Raspberry pi -- GPIO](#raspberry-pi----gpio)
- [gpio\_init](#gpio_init)
- [gpio\_output](#gpio_output)
Expand Down
1 change: 0 additions & 1 deletion docs/myAGV.md

This file was deleted.

127 changes: 127 additions & 0 deletions docs/myAGV_en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# myAgv

<details>
<summary>Catalogue:</summary>

- [myAgv](#myagv)
- [set\_led(mode, R, G, B)](#set_ledmode-r-g-b)
- [get\_firmware\_version](#get_firmware_version)
- [get\_motors\_current](#get_motors_current)
- [get\_battery\_info](#get_battery_info)
- [move\_control(direction\_1, direction\_2, direction\_3)](#move_controldirection_1-direction_2-direction_3)
- [go\_ahead(go\_speed)](#go_aheadgo_speed)
- [retreat(back\_speed)](#retreatback_speed)
- [pan\_left(pan\_left\_speed)](#pan_leftpan_left_speed)
- [pan\_right(pan\_right\_speed)](#pan_rightpan_right_speed)
- [clockwise\_rotation(rotate\_right\_speed)](#clockwise_rotationrotate_right_speed)
- [counterclockwise\_rotation(rotate\_left\_speed)](#counterclockwise_rotationrotate_left_speed)
- [stop()](#stop)
- [restore()](#restore)

</details>

## set_led(mode, R, G, B)

Set up LED lights

- **Parameters**

- **mode** – 1 - Set LED light color. 2 - Set the LED light to blink.

- **R** – (int) 0 ~ 255

- **G** – (int) 0 ~ 255

- **B** – (int) 0 ~ 255

## get_firmware_version

Get firmware version number

## get_motors_current

Get the total current of the motor

## get_battery_info

Read battery information

- **Return**
list : [battery_data, battery_1_voltage, battery_2_voltage].
`battery_data`:A string of length 6, represented from left to right: bit5, bit4, bit3, bit2, bit1, bit0.
bit5 : Battery 2 is inserted into the interface 1 means inserted, 0 is not inserted.
bit4 : Battery 1 is inserted into the interface, 1 means inserted, 0 is not inserted.
bit3 : The adapter is plugged into the interface 1 means plugged in, 0 not plugged in.
bit2 : The charging pile is inserted into the interface, 1 means plugged in, 0 is not plugged in.
bit1 : Battery 2 charging light 0 means off, 1 means on.
bit0 : Battery 1 charging light, 0 means off, 1 means on.
`battery_1_voltage` : Battery 1 voltage in volts.
`battery_2_voltage` : Battery 2 voltage in volts.

## move_control(direction_1, direction_2, direction_3)

Control the car to rotate forward, backward, left, right and forward/counterclockwise.

- **Parameters**

- **direction_1** – (int) Control forward or backward: 0 ~ 127 is backward, 129 ~ 255 is forward, 128 is stop.

- **direction_2** – (int) control left and right movement: 0 ~ 127 is right, 129 ~ 255 is left, 128 is stop.

- **direction_3** – (int) control rotation: 0 ~ 127 is clockwise, 129 ~ 255 is counterclockwise, 128 is stop.

## go_ahead(go_speed)

Control the car to move forward

- **Parameters**

- **go_speed** – (int) 1 ~ 127 is forward.The smaller the value, the smaller the speed

## retreat(back_speed)

Control the car back

- **Parameters**

- **back_speed** – (int) 1 ~ 127 is backward.The smaller the value, the smaller the speed

## pan_left(pan_left_speed)

Control the car to pan to the left

- **Parameters**

- **pan_left_speed** – (int) 1 ~ 127.The smaller the value, the smaller the speed

## pan_right(pan_right_speed)

Control the car to pan to the right

- **Parameters**

- **pan_right_speed** – (int) 1 ~ 127.The smaller the value, the smaller the speed

## clockwise_rotation(rotate_right_speed)

Control the car to rotate clockwise

- **Parameters**

- **rotate_right_speed** – (int) 1 ~ 127.The smaller the value, the smaller the speed

## counterclockwise_rotation(rotate_left_speed)

Control the car to rotate counterclockwise

- **Parameters**

- **rotate_left_speed** – (int) 1 ~ 127.The smaller the value, the smaller the speed

## stop()

stop motion.

## restore()

Motor stall recovery
127 changes: 127 additions & 0 deletions docs/myAGV_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# myAgv

<details>
<summary>API目录:</summary>

- [myAgv](#myagv)
- [set\_led(mode, R, G, B)](#set_ledmode-r-g-b)
- [get\_firmware\_version](#get_firmware_version)
- [get\_motors\_current](#get_motors_current)
- [get\_battery\_info](#get_battery_info)
- [move\_control(direction\_1, direction\_2, direction\_3)](#move_controldirection_1-direction_2-direction_3)
- [go\_ahead(go\_speed)](#go_aheadgo_speed)
- [retreat(back\_speed)](#retreatback_speed)
- [pan\_left(pan\_left\_speed)](#pan_leftpan_left_speed)
- [pan\_right(pan\_right\_speed)](#pan_rightpan_right_speed)
- [clockwise\_rotation(rotate\_right\_speed)](#clockwise_rotationrotate_right_speed)
- [counterclockwise\_rotation(rotate\_left\_speed)](#counterclockwise_rotationrotate_left_speed)
- [stop()](#stop)
- [restore()](#restore)

</details>

## set_led(mode, R, G, B)

设置led灯颜色

- **参数**

- **mode** – 1 - 常亮. 2 - 闪烁.

- **R** – (int) 0 ~ 255

- **G** – (int) 0 ~ 255

- **B** – (int) 0 ~ 255

## get_firmware_version

获取固件版本号

## get_motors_current

获取电机电流信息

## get_battery_info

获取电池信息

- **Return**
list : [battery_data, battery_1_voltage, battery_2_voltage].
`battery_data`: 长度为6的字符串, 从左到右依次对应: bit5, bit4, bit3, bit2, bit1, bit0.
bit5 : 电池2插入接口,1表示插入,0未插入.
bit4 : 电池1插入接口,1表示插入,0未插入.
bit3 : 适配器插入接口,1表示插入,0未插入.
bit2 : 充电桩插入接口,1表示插入,0未插入.
bit1 : 电池2充电灯,0表示没亮,1表示亮.
bit0 : 电池1充电灯,0表示没亮,1表示亮.
`battery_1_voltage` : 电池1电压.
`battery_2_voltage` : 电池2电压.

## move_control(direction_1, direction_2, direction_3)

运动控制接口,控制小车前进、后退、平移、旋转.

- **参数**

- **direction_1** – (int) 控制前进或者后退: 0 ~ 127 表示后退, 129 ~ 255 表示前进, 128 表示停止.

- **direction_2** – (int) 控制左右平移: 0 ~ 127 表示向右平移, 129 ~ 255 表示向左平移, 128 表示停止.

- **direction_3** – (int) 控制旋转: 0 ~ 127 表示顺时针旋转, 129 ~ 255 表示逆时针旋转, 128 表示停止.

## go_ahead(go_speed)

控制前进

- **参数**

- **go_speed** – (int) 1 ~ 127 数值越小,速度越慢

## retreat(back_speed)

控制后退

- **参数**

- **back_speed** – (int) 1 ~ 127 数值越小,速度越慢

## pan_left(pan_left_speed)

控制左平移

- **参数**

- **pan_left_speed** – (int) 1 ~ 127 数值越小,速度越慢

## pan_right(pan_right_speed)

控制右平移

- **参数**

- **pan_right_speed** – (int) 1 ~ 127 数值越小,速度越慢

## clockwise_rotation(rotate_right_speed)

控制顺时针旋转

- **参数**

- **rotate_right_speed** – (int) 1 ~ 127 数值越小,速度越慢

## counterclockwise_rotation(rotate_left_speed)

控制逆时针旋转

- **参数**

- **rotate_left_speed** – (int) 1 ~ 127 数值越小,速度越慢

## stop()

停止运动

## restore()

堵转恢复
4 changes: 2 additions & 2 deletions pymycobot/mecharm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from pymycobot import MyCobot

class MechArm(MyCobot):
def __init__(self, port, baudrate="115200", timeout=0.1, debug=False):
super(MechArm, self).__init__(port, baudrate, timeout, debug)
def __init__(self, port, baudrate="115200", timeout=0.1, debug=False, thread_lock=False):
super(MechArm, self).__init__(port, baudrate, timeout, debug, thread_lock)
2 changes: 1 addition & 1 deletion pymycobot/myagv.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,6 @@ def get_muc_info(self):
return res

def restore(self):
""""""
"""Motor stall recovery"""
self._mesg(ProtocolCode.RESTORE.value, 1)

2 changes: 2 additions & 0 deletions pymycobot/mybuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ def sync_send_angles(self, id, degrees, speed, timeout=15):
"""
t = time.time()
self.send_angles(id, degrees, speed)
time.sleep(0.5)
while time.time() - t < timeout:
f = self.is_in_position(id, degrees, 0)
if f == 1:
Expand All @@ -425,6 +426,7 @@ def sync_send_coords(self, id, coords, speed, mode=0, timeout=15):
"""
t = time.time()
self.send_coords(id, coords, speed, mode)
time.sleep(0.5)
while time.time() - t < timeout:
if self.is_in_position(id, coords, 1) == 1:
break
Expand Down
40 changes: 20 additions & 20 deletions tests/rasp_mypall_test_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,48 +330,48 @@ def _aging_test(self):
self.stop_test = False
while True and time.time() - start < 60*30 and self.stop_test == False:
self.mycobot.set_color(255, 0, 0)
self.mycobot.wait(5).send_angles([0, 0, 0, 0, 0], 95)
self.mycobot.wait(5).send_angles([0, 0, 0, 0], 95)
self.mycobot.wait(3).send_angles([-160, 0, 0, 0], 95)
self.mycobot.wait(3).send_angles([160, 0, 0, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 95)
self.mycobot.wait(3).send_angles([0, 80, 0, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, -90, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, -60, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, 20, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, 40, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 95)
self.mycobot.wait(3).send_angles([0, 0, 0, 180], 95)
self.mycobot.wait(3).send_angles([0, 0, 0, -180], 95)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 95)

# middle
self.mycobot.set_color(0, 255, 0)
self.mycobot.wait(5).send_angles([0, 0, 0, 0, 0], 55)
self.mycobot.wait(3).send_angles([-160, 0, 0, 0], 55)
self.mycobot.wait(3).send_angles([160, 0, 0, 0], 55)
self.mycobot.wait(5).send_angles([0, 0, 0, 0], 55)
self.mycobot.wait(5).send_angles([-160, 0, 0, 0], 55)
self.mycobot.wait(5).send_angles([160, 0, 0, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 55)
self.mycobot.wait(3).send_angles([0, 80, 0, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, -90, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, -60, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, 0, 180], 55)
self.mycobot.wait(3).send_angles([0, 0, 0, -180], 55)
self.mycobot.wait(3).send_angles([0, 0, 20, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, 40, 0], 55)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 55)
self.mycobot.wait(6).send_angles([0, 0, 0, 180], 55)
self.mycobot.wait(6).send_angles([0, 0, 0, -180], 55)
self.mycobot.wait(6).send_angles([0, 0, 0, 0], 55)

# slow
self.mycobot.set_color(0, 0, 255)
self.mycobot.wait(5).send_angles([0, 0, 0, 0, 0], 15)
self.mycobot.wait(3).send_angles([-160, 0, 0, 0], 15)
self.mycobot.wait(3).send_angles([160, 0, 0, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 15)
self.mycobot.wait(5).send_angles([0, 0, 0, 0], 15)
self.mycobot.wait(8).send_angles([-160, 0, 0, 0], 15)
self.mycobot.wait(8).send_angles([160, 0, 0, 0], 15)
self.mycobot.wait(5).send_angles([0, 0, 0, 0], 15)
self.mycobot.wait(3).send_angles([0, 80, 0, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, -90, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, -60, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, 0, 180], 15)
self.mycobot.wait(3).send_angles([0, 0, 0, -180], 15)
self.mycobot.wait(3).send_angles([0, 0, 20, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, 40, 0], 15)
self.mycobot.wait(3).send_angles([0, 0, 0, 0], 15)
self.mycobot.wait(8).send_angles([0, 0, 0, 180], 15)
self.mycobot.wait(8).send_angles([0, 0, 0, -180], 15)
self.mycobot.wait(5).send_angles([0, 0, 0, 0], 15)
self.mycobot.send_angles([0, 0, 0, 0], 35)
self.write_log_to_Text("老化测试结束。")
# aging_test_content_py = textwrap.dedent(
Expand Down

0 comments on commit d0d08cd

Please sign in to comment.