|
| 1 | +import time |
| 2 | +from pymycobot.mycobot import MyCobot |
| 3 | +from pymycobot.genre import Angle, Coord |
| 4 | + |
| 5 | +reset = [153.19, 137.81, -153.54, 156.79, 87.27, 13.62] |
| 6 | +zero = [0, 0, 0, 0, 0, 0] |
| 7 | +sp = 100 |
| 8 | + |
| 9 | + |
| 10 | +def test(mc): |
| 11 | + print('Start check jog api\n') |
| 12 | + |
| 13 | + mc.send_angles(zero, sp) |
| 14 | + time.sleep(5) |
| 15 | + |
| 16 | + print('jog_angle() -> control joint1') |
| 17 | + mc.jog_angle(Angle.J1.value, 1, 10) |
| 18 | + time.sleep(3) |
| 19 | + print('pause 10 s') |
| 20 | + mc.pause() |
| 21 | + time.sleep(3) |
| 22 | + print('speed get', mc.get_speed()) |
| 23 | + mc.set_speed(20) |
| 24 | + print('speed set', mc.get_speed()) |
| 25 | + time.sleep(7) |
| 26 | + print('resume') |
| 27 | + mc.resume() |
| 28 | + time.sleep(10) |
| 29 | + |
| 30 | + coords = [160, 140, 160, 0, 0, 0] |
| 31 | + mc.send_coords(coords, 100, 0) |
| 32 | + time.sleep(4) |
| 33 | + |
| 34 | + mc.jog_coord(Coord.Z.value, 1, 10) |
| 35 | + time.sleep(3) |
| 36 | + print('stop') |
| 37 | + |
| 38 | + print('=== check end ===\n') |
| 39 | + |
| 40 | + |
| 41 | +if __name__ == '__main__': |
| 42 | + print(''' |
| 43 | +-------------------------------------------- |
| 44 | +| This file will test jog method: | |
| 45 | +| jog_angle() | |
| 46 | +| jog_coord() | |
| 47 | +| pause() | |
| 48 | +| resume() | |
| 49 | +| stop() | |
| 50 | +| get_speed() | |
| 51 | +| set_speed() | |
| 52 | +-------------------------------------------- |
| 53 | + ''') |
| 54 | + time.sleep(3) |
| 55 | + with open('./port.txt') as f: |
| 56 | + port = f.read().strip().replace('\n', '') |
| 57 | + print(port) |
| 58 | + mc = MyCobot(port) |
| 59 | + |
| 60 | + test(mc) |
0 commit comments