|
| 1 | +import compas_rrc as rrc |
| 2 | +from compas.geometry import Frame |
| 3 | +from compas.geometry import Point |
| 4 | +from compas.geometry import Vector |
| 5 | + |
| 6 | +if __name__ == '__main__': |
| 7 | + |
| 8 | + # Create Ros Client |
| 9 | + ros = rrc.RosClient() |
| 10 | + ros.run() |
| 11 | + |
| 12 | + # Create ABB Client |
| 13 | + abb = rrc.AbbClient(ros, '/rob1') |
| 14 | + print('Connected.') |
| 15 | + |
| 16 | + # Reset signals |
| 17 | + abb.send(rrc.SetDigital('doNewBrick',0)) |
| 18 | + abb.send(rrc.SetDigital('doVacuumOn',0)) |
| 19 | + |
| 20 | + # Set tool |
| 21 | + abb.send(rrc.SetTool('t_RRC_Vacuum_Gripper')) |
| 22 | + |
| 23 | + # Set work object |
| 24 | + abb.send(rrc.SetWorkObject('ob_RRC_Brick_Pallet')) |
| 25 | + |
| 26 | + # Create a new brick |
| 27 | + done = abb.send_and_wait(rrc.PulseDigital('doNewBrick',0.2)) |
| 28 | + |
| 29 | + # Define pick positions |
| 30 | + pre_pick_position = Frame(Point(68.5, 48.5, 50), Vector(0, -1, 0), Vector(-1, 0, 0)) |
| 31 | + pick_position = Frame(Point(68.5, 48.5, 36), Vector(0, -1, 0), Vector(-1, 0, 0)) |
| 32 | + |
| 33 | + # Define speeds |
| 34 | + speed = 100 |
| 35 | + |
| 36 | + # Move over pick postion |
| 37 | + abb.send(rrc.MoveToFrame(pre_pick_position, speed, rrc.Zone.Z10)) |
| 38 | + |
| 39 | + # Move to pick postion |
| 40 | + abb.send(rrc.MoveToFrame(pick_position, speed, rrc.Zone.FINE)) |
| 41 | + |
| 42 | + # Vacuum on |
| 43 | + abb.send(rrc.SetDigital('doVacuumOn',1)) |
| 44 | + |
| 45 | + # Move over pick postion |
| 46 | + abb.send(rrc.MoveToFrame(pre_pick_position, speed, rrc.Zone.Z10)) |
| 47 | + |
| 48 | + # Set work object |
| 49 | + abb.send(rrc.SetWorkObject('ob_RRC_Build_Space')) |
| 50 | + |
| 51 | + # Define pick positions |
| 52 | + pre_place_position = Frame(Point(50, 50, 50), Vector(0, -1, 0), Vector(-1, 0, 0)) |
| 53 | + place_position = Frame(Point(50, 50, 12), Vector(0, -1, 0), Vector(-1, 0, 0)) |
| 54 | + |
| 55 | + # Move over place postion |
| 56 | + abb.send(rrc.MoveToFrame(pre_place_position, speed, rrc.Zone.Z10)) |
| 57 | + |
| 58 | + # Move to pick postion |
| 59 | + abb.send(rrc.MoveToFrame(place_position, speed, rrc.Zone.FINE)) |
| 60 | + |
| 61 | + # Vacuum on |
| 62 | + abb.send(rrc.SetDigital('doVacuumOn',0)) |
| 63 | + |
| 64 | + # Move over place postion |
| 65 | + abb.send(rrc.MoveToFrame(pre_place_position, speed, rrc.Zone.Z10)) |
| 66 | + |
| 67 | + # End of Code |
| 68 | + print('Finished') |
| 69 | + |
| 70 | + # Close client |
| 71 | + ros.close() |
| 72 | + ros.terminate() |
0 commit comments