-
Notifications
You must be signed in to change notification settings - Fork 1
/
push_the_ball_cartesian.py
56 lines (43 loc) · 1.45 KB
/
push_the_ball_cartesian.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Example of moving the robot in cartesian space to push the ball. It is more robust than the pure joint control.
:Author: Lukas Rustler
"""
import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from pycub import pyCub
from utils import Pose
def push_the_ball():
"""
Function to move the ball with cartesian control. The robot is moved 15cm lower and 10cm closer and the moved left to
push the ball.
"""
# Get current pose
cur_pose = client.end_effector.get_position()
# Copy, the pose and go 15cm lower and 10cm closer to the robot
new_pose = Pose(cur_pose.pos, cur_pose.ori)
new_pose.pos[2] -= 0.15
new_pose.pos[0] -= 0.1
# move
client.move_cartesian(new_pose)
# get current pose
pose = client.end_effector.get_position()
# assign straight to it to move hand left
pose.pos[1] -= 0.2
# move; do not wait for completion; and move a bit faster
client.move_cartesian(pose, wait=False, velocity=2)
# wait manually
while not client.motion_done():
client.update_simulation()
"""
Wait could be also achieved with:
client.wait_motion_done()
"""
client.logger.info("Moved the ball!")
if __name__ == "__main__":
# load the robot with correct world/config
client = pyCub(config="with_ball.yaml")
push_the_ball()
# just wait until the gui is closed
while client.is_alive():
client.update_simulation()