Compare commits
10 Commits
9a7b3797e2
...
7ffdec977c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ffdec977c | ||
|
|
bd757ce965 | ||
|
|
4d1d814e37 | ||
|
|
47eda969c9 | ||
|
|
3e670c4a92 | ||
|
|
aa4b21fa91 | ||
|
|
224c79842f | ||
|
|
4c31dc9cf3 | ||
|
|
4b8d7eb7b2 | ||
|
|
28d4ced8c1 |
40
new_main.py
40
new_main.py
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
from __future__ import print_function
|
||||||
import argparse
|
import argparse
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
@ -26,7 +27,7 @@ import target_angles as ta
|
|||||||
#^Importing essential libraries for ROS and motion planning and running for the main script^
|
#^Importing essential libraries for ROS and motion planning and running for the main script^
|
||||||
|
|
||||||
simulation = True #Flag for spawning objects in the gazebo if the script is running in a simulation
|
simulation = True #Flag for spawning objects in the gazebo if the script is running in a simulation
|
||||||
debug = True #Flag for asking confirmation before robot performs key maneuvers
|
debug = False #Flag for asking confirmation before robot performs key maneuvers
|
||||||
|
|
||||||
class PickAndPlace(object): #class that handles moving the robot, gripper and IK
|
class PickAndPlace(object): #class that handles moving the robot, gripper and IK
|
||||||
def __init__(self, limb, hover_distance = 0.10, verbose=True, speed=0.2, accuracy=baxter_interface.settings.JOINT_ANGLE_TOLERANCE):
|
def __init__(self, limb, hover_distance = 0.10, verbose=True, speed=0.2, accuracy=baxter_interface.settings.JOINT_ANGLE_TOLERANCE):
|
||||||
@ -47,6 +48,10 @@ class PickAndPlace(object): #class that handles moving the robot, gripper and IK
|
|||||||
print("Enabling robot... ")
|
print("Enabling robot... ")
|
||||||
self._rs.enable()
|
self._rs.enable()
|
||||||
|
|
||||||
|
def calibrate_gripper(self):
|
||||||
|
'''Calibrated gripper'''
|
||||||
|
self._gripper.calibrate()
|
||||||
|
|
||||||
def _guarded_move_to_joint_position(self, joint_angles):
|
def _guarded_move_to_joint_position(self, joint_angles):
|
||||||
'''Private class to move robot limbs'''
|
'''Private class to move robot limbs'''
|
||||||
if joint_angles:
|
if joint_angles:
|
||||||
@ -215,6 +220,7 @@ def V_Routine(limb):
|
|||||||
if debug: x = raw_input('Pick? ')
|
if debug: x = raw_input('Pick? ')
|
||||||
limb.goto(ta.V_pickup)
|
limb.goto(ta.V_pickup)
|
||||||
if debug: x = raw_input('Close gripper? ')
|
if debug: x = raw_input('Close gripper? ')
|
||||||
|
print('Closing gripper...')
|
||||||
limb.gripper_close()
|
limb.gripper_close()
|
||||||
gripperBrickChecker(limb)
|
gripperBrickChecker(limb)
|
||||||
limb.goto(ta.V_approach)
|
limb.goto(ta.V_approach)
|
||||||
@ -226,24 +232,34 @@ def H_Routine(limb):
|
|||||||
if debug: x = raw_input('Pick? ')
|
if debug: x = raw_input('Pick? ')
|
||||||
limb.goto(ta.H_pickup)
|
limb.goto(ta.H_pickup)
|
||||||
if debug: x = raw_input('Close gripper? ')
|
if debug: x = raw_input('Close gripper? ')
|
||||||
|
print('Closing gripper...')
|
||||||
limb.gripper_close()
|
limb.gripper_close()
|
||||||
gripperBrickChecker(limb)
|
gripperBrickChecker(limb)
|
||||||
limb.goto(ta.H_approach)
|
limb.goto(ta.H_approach)
|
||||||
|
|
||||||
def process(limb, step):
|
def process(limb, step):
|
||||||
if step['vertical'] == True:
|
print('Picking up brick ', step['step'], '...')
|
||||||
V_Routine(limb)
|
|
||||||
else:
|
|
||||||
H_Routine(limb)
|
|
||||||
|
|
||||||
|
if step['vertical'] == True: V_Routine(limb)
|
||||||
|
else: H_Routine(limb)
|
||||||
|
|
||||||
|
print('Moving brick ', step['step'], ' to hover position...')
|
||||||
limb.goto(step['hover'])
|
limb.goto(step['hover'])
|
||||||
|
|
||||||
if debug:x = raw_input('Place?: ')
|
if debug:x = raw_input('Place?: ')
|
||||||
|
print('Placing brick ', step['step'], '...')
|
||||||
limb.goto(step['place'])
|
limb.goto(step['place'])
|
||||||
|
|
||||||
if debug:x = raw_input('Open gripper?: ')
|
if debug:x = raw_input('Open gripper?: ')
|
||||||
|
print('Opening gripper...')
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
limb.gripper_open()
|
limb.gripper_open()
|
||||||
if not step['lastBrick']:
|
if not step['lastBrick']:
|
||||||
|
print('Moving arm to hover ', step['step'], ' position...')
|
||||||
limb.goto(step['hover'])
|
limb.goto(step['hover'])
|
||||||
else:
|
else:
|
||||||
|
print('Moving arm to home position...')
|
||||||
limb.goto(step['last1'])
|
limb.goto(step['last1'])
|
||||||
limb.goto(step['last2'])
|
limb.goto(step['last2'])
|
||||||
limb.goto(step['last3'])
|
limb.goto(step['last3'])
|
||||||
@ -252,23 +268,35 @@ def process(limb, step):
|
|||||||
|
|
||||||
|
|
||||||
rospy.init_node("MOTHER_CLUCKER") #Initializes rospy node
|
rospy.init_node("MOTHER_CLUCKER") #Initializes rospy node
|
||||||
|
print('Robot initialized')
|
||||||
|
print('Simulation: ', simulation)
|
||||||
|
print('Debug: ', debug)
|
||||||
|
|
||||||
if simulation:
|
if simulation:
|
||||||
#Clean up any (known) preexisting objects in Gazebo and spawns the tables
|
#Clean up any (known) preexisting objects in Gazebo and spawns the tables
|
||||||
cleanup()
|
cleanup()
|
||||||
spawn_tables()
|
spawn_tables()
|
||||||
|
|
||||||
|
print('Initializing arms...')
|
||||||
tuck_arms.init_arms() #Makes sure the arms are in known starting place
|
tuck_arms.init_arms() #Makes sure the arms are in known starting place
|
||||||
tuck_arms.init_arms()
|
|
||||||
left_pnp = PickAndPlace('left') #Limb initializer
|
left_pnp = PickAndPlace('left') #Limb initializer
|
||||||
|
|
||||||
|
print('Calibrating gripper...')
|
||||||
|
left_pnp.calibrate_gripper()
|
||||||
|
|
||||||
|
print('Opening gripper...')
|
||||||
left_pnp.gripper_open() #Ensures gripper is open before grabbing brick
|
left_pnp.gripper_open() #Ensures gripper is open before grabbing brick
|
||||||
|
|
||||||
tower_instructions = ta.instructions
|
tower_instructions = ta.instructions
|
||||||
|
|
||||||
|
print('Loaded tower instructions, bricks: ', len(tower_instructions))
|
||||||
|
|
||||||
for step in tower_instructions:
|
for step in tower_instructions:
|
||||||
|
print('Processing step: ', step['step'])
|
||||||
process(left_pnp, step)
|
process(left_pnp, step)
|
||||||
|
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
print("#################################################################################################################")
|
print("#################################################################################################################")
|
||||||
|
|||||||
@ -27,64 +27,67 @@ instructions = [
|
|||||||
{
|
{
|
||||||
'step':1,
|
'step':1,
|
||||||
'hover':B_1_A,
|
'hover':B_1_A,
|
||||||
'pick':B_1_P,
|
'place':B_1_P,
|
||||||
'vertical':True,
|
'vertical':True,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':2,
|
'step':2,
|
||||||
'hover':B_2_A,
|
'hover':B_2_A,
|
||||||
'pick':B_2_P,
|
'place':B_2_P,
|
||||||
'vertical':True,
|
'vertical':True,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':3,
|
'step':3,
|
||||||
'hover':B_3_A,
|
'hover':B_3_A,
|
||||||
'pick':B_3_P,
|
'place':B_3_P,
|
||||||
'vertical':True,
|
'vertical':True,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':4,
|
'step':4,
|
||||||
'hover':B_4_A,
|
'hover':B_4_A,
|
||||||
'pick':B_4_P,
|
'place':B_4_P,
|
||||||
'vertical':False,
|
'vertical':False,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':5,
|
'step':5,
|
||||||
'hover':B_5_A,
|
'hover':B_5_A,
|
||||||
'pick':B_5_P,
|
'place':B_5_P,
|
||||||
'vertical':False,
|
'vertical':False,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':6,
|
'step':6,
|
||||||
'hover':B_6_A,
|
'hover':B_6_A,
|
||||||
'pick':B_6_P,
|
'place':B_6_P,
|
||||||
'vertical':True,
|
'vertical':True,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':7,
|
'step':7,
|
||||||
'hover':B_7_A,
|
'hover':B_7_A,
|
||||||
'pick':B_7_P,
|
'place':B_7_P,
|
||||||
'vertical':True,
|
'vertical':True,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':8,
|
'step':8,
|
||||||
'hover':B_8_A,
|
'hover':B_8_A,
|
||||||
'pick':B_8_P,
|
'place':B_8_P,
|
||||||
'vertical':False,
|
'vertical':False,
|
||||||
'lastBrick':False
|
'lastBrick':False
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'step':9,
|
'step':9,
|
||||||
'hover':B_9_A,
|
'hover':B_9_A,
|
||||||
'pick':B_9_P,
|
'place':B_9_P,
|
||||||
'vertical':True,
|
'vertical':True,
|
||||||
'lastBrick':True
|
'lastBrick':True,
|
||||||
|
'last1':B_9_za,
|
||||||
|
'last2':B_9_zb,
|
||||||
|
'last3':H_pickup
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Loading…
Reference in New Issue
Block a user