Skip to content

Commit 9a748ba

Browse files
committed
fix the direction of the palletizaion ++
1 parent 4846fb0 commit 9a748ba

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

ToDo.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
- ~~set/get digital outputs~~
1818
- ~~servo control (power on, break release)~~
1919
- force control
20-
- palletization
20+
- ~~palletization~~
2121
- other?
2222
- [ ] Examples
2323
- ~~pick and place~~
24-
- palletization
24+
- ~~palletization~~
2525
- path following (generated from G-code) with force control
2626
- more examples?

examples/ReadMe.md

+15
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,18 @@ The `pick_and_place.py` script can be customized to fit specific picking and pla
1616

1717
## Palletization Example
1818

19+
The code you provided appears to be a function named Palletization() that performs a series of actions related to palletization. Let's break down the logic step by step:
20+
21+
1. Create a pallet: The code defines three corners of a pallet using coordinate values. Then, it calls a function ur_control.create_pallet() to create a pallet with 10 rows and 10 columns, using the specified corner coordinates.
22+
23+
2. Set the tool center point (TCP): The code calls ur_control.set_tcp() function to set the tool center point to [0, 0, 0.2, 0, 0, 0]. The TCP is the reference point on the robot's end effector where the tool or gripper is attached.
24+
25+
3. Set the payload: The code calls ur_control.set_payload() function to set the payload of the robot. In this case, the payload is set to 0 kg, with the center of gravity at [0, 0, 0] and the inertia matrix [0, 0, 0, 0, 0, 0].
26+
27+
4. Go to pallet position: The code enters a loop that iterates 99 times. In each iteration, it performs the following actions:
28+
29+
Calls `ur_control.go_to_pallet_position_with_offset()` function to move the robot to the pallet position with an offset of `[0, 0, 0.2, 0, 0, 0]`. This is the approach phase.
30+
Calls `ur_control.go_to_pallet_position()` function to move the robot to the pallet position without any offset. This is the main position.
31+
Calls `ur_control.go_to_pallet_position_with_offset()` function again to move the robot away from the pallet position with the same offset. This is the leave phase.
32+
Pauses the execution for 1 second using the sleep() function.
33+
This code seems to be controlling a robot to perform palletization tasks, such as picking up items from a pallet and placing them elsewhere. The specific implementation details of the functions `ur_control.create_pallet()`, `ur_control.set_tcp()`,` ur_control.set_payload()`, and `ur_control.go_to_pallet_position_with_offset()` are not provided in the code snippet, so it's difficult to provide further insights without more context.

examples/palletization/palletization.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ def Palletization():
3434
# set payload if there is any
3535
ur_control.set_payload(0, [0, 0, 0], [0,0,0,0,0,0])
3636

37-
# move to pallet position 1
38-
ur_control.go_to_pallet_position(pallet1, 1)
39-
40-
# move to pallet position 2
41-
ur_control.go_to_pallet_position(pallet1, 2)
42-
43-
# move to pallet position 2
44-
ur_control.go_to_pallet_position(pallet1, 100)
37+
# go to pallet position
38+
for i in range(99):
39+
ur_control.go_to_pallet_position_with_offset(pallet1, i + 1, [0, 0, 0.2, 0 ,0, 0]) # approach
40+
ur_control.go_to_pallet_position(pallet1, i + 1)
41+
ur_control.go_to_pallet_position_with_offset(pallet1, i + 1, [0, 0, 0.2, 0 ,0, 0]) # leave
42+
sleep(1)
4543

4644

4745
if __name__ == '__main__':
4846
program()
4947

48+
49+

src/pyURControl/ur_control.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,12 @@ def create_pallet(rows: int, cols: int, corner1: list, corner2: list, corner3: l
223223
pallet = []
224224
for i in range(rows):
225225
for j in range(cols):
226-
x = corner1[0] + i * (corner2[0] - corner1[0]) / (rows - 1) + j * (corner3[0] - corner1[0]) / (cols - 1)
227-
y = corner1[1] + i * (corner2[1] - corner1[1]) / (rows - 1) + j * (corner3[1] - corner1[1]) / (cols - 1)
228-
z = corner1[2] + i * (corner2[2] - corner1[2]) / (rows - 1) + j * (corner3[2] - corner1[2]) / (cols - 1)
229-
rx = corner1[3] + i * (corner2[3] - corner1[3]) / (rows - 1) + j * (corner3[3] - corner1[3]) / (cols - 1)
230-
ry = corner1[4] + i * (corner2[4] - corner1[4]) / (rows - 1) + j * (corner3[4] - corner1[4]) / (cols - 1)
231-
rz = corner1[5] + i * (corner2[5] - corner1[5]) / (rows - 1) + j * (corner3[5] - corner1[5]) / (cols - 1)
226+
x = corner1[0] + i * (corner3[0] - corner1[0]) / (rows - 1) + j * (corner2[0] - corner1[0]) / (cols - 1)
227+
y = corner1[1] + i * (corner3[1] - corner1[1]) / (rows - 1) + j * (corner2[1] - corner1[1]) / (cols - 1)
228+
z = corner1[2] + i * (corner3[2] - corner1[2]) / (rows - 1) + j * (corner2[2] - corner1[2]) / (cols - 1)
229+
rx = corner1[3] + i * (corner3[3] - corner1[3]) / (rows - 1) + j * (corner2[3] - corner1[3]) / (cols - 1)
230+
ry = corner1[4] + i * (corner3[4] - corner1[4]) / (rows - 1) + j * (corner2[4] - corner1[4]) / (cols - 1)
231+
rz = corner1[5] + i * (corner3[5] - corner1[5]) / (rows - 1) + j * (corner2[5] - corner1[5]) / (cols - 1)
232232
pallet.append([x, y, z, rx, ry, rz])
233233
return pallet
234234

0 commit comments

Comments
 (0)