Skip to content
Snippets Groups Projects
Commit 20ae730b authored by Steve Tonneau's avatar Steve Tonneau
Browse files

generate also unstable configurations

parent c2cdb581
No related branches found
No related tags found
No related merge requests found
...@@ -318,18 +318,20 @@ def _boundSO3(q, num_limbs): ...@@ -318,18 +318,20 @@ def _boundSO3(q, num_limbs):
return q return q
def _genbalance(limbs): def _genbalance(limbs, unstable):
for i in range(10000): for i in range(10000):
q = fullBody.client.basic.robot.shootRandomConfig() q = fullBody.client.basic.robot.shootRandomConfig()
q = _boundSO3(q, len(limbs)) q = _boundSO3(q, len(limbs))
if fullBody.isConfigValid(q)[0] and fullBody.isConfigBalanced(q, limbs, 5) and __loosely_z_aligned(limbs[0], q) and __loosely_z_aligned(limbs[1], q): if fullBody.isConfigValid(q)[0] and __loosely_z_aligned(limbs[0], q) and __loosely_z_aligned(limbs[1], q):
if (unstable and not fullBody.isConfigBalanced(q, limbs, 5)) or (not unstable and fullBody.isConfigBalanced(q, limbs, 5)):
#~ if fullBody.isConfigValid(q)[0] and __loosely_z_aligned(limbs[0], q) and __loosely_z_aligned(limbs[1], q): #~ if fullBody.isConfigValid(q)[0] and __loosely_z_aligned(limbs[0], q) and __loosely_z_aligned(limbs[1], q):
return q return q
print "can't generate equilibrium config" print "can't generate equilibrium config"
all_qs = [] all_qs = []
all_states = [] all_states = []
def gen(limbs, num_samples = 1000, coplanar = True, num_candidates_per_config = 0, num_contact_candidates = 10, q_entries = None, projectToObstacles = False): all_data = []
def gen(limbs, num_samples = 1000, coplanar = True, num_candidates_per_config = 0, num_contact_candidates = 10, q_entries = None, projectToObstacles = False, unstable = False):
q_0 = fullBody.getCurrentConfig(); q_0 = fullBody.getCurrentConfig();
#~ fullBody.getSampleConfig() #~ fullBody.getSampleConfig()
qs = []; qs_gepetto = []; states = [] qs = []; qs_gepetto = []; states = []
...@@ -343,7 +345,7 @@ def gen(limbs, num_samples = 1000, coplanar = True, num_candidates_per_config = ...@@ -343,7 +345,7 @@ def gen(limbs, num_samples = 1000, coplanar = True, num_candidates_per_config =
if(coplanar): if(coplanar):
q = fullBody.generateGroundContact(limbs) q = fullBody.generateGroundContact(limbs)
else: else:
q = _genbalance(limbs) q = _genbalance(limbs, unstable)
else: else:
q = q_entries[i] q = q_entries[i]
q_gep = q[:] q_gep = q[:]
...@@ -366,7 +368,10 @@ def gen(limbs, num_samples = 1000, coplanar = True, num_candidates_per_config = ...@@ -366,7 +368,10 @@ def gen(limbs, num_samples = 1000, coplanar = True, num_candidates_per_config =
fname += "configs" fname += "configs"
if(coplanar): if(coplanar):
fname += "_coplanar" fname += "_coplanar"
if(unstable):
fname += "_unstable"
data["samples"] = states data["samples"] = states
all_data.append(data)
from pickle import dump from pickle import dump
#~ f1=open("configs_feet_on_ground_static_eq", 'w+') #~ f1=open("configs_feet_on_ground_static_eq", 'w+')
f1=open(fname, 'w+') f1=open(fname, 'w+')
...@@ -386,14 +391,15 @@ q_init = [ ...@@ -386,14 +391,15 @@ q_init = [
0.0, 0.0, -0.453785606, 0.872664626, -0.41887902, 0.0, # RLEG 31-36 0.0, 0.0, -0.453785606, 0.872664626, -0.41887902, 0.0, # RLEG 31-36
]; r (q_init) ]; r (q_init)
limbs = [[lLegId,rLegId],[lLegId,rLegId, rarmId], [lLegId,rLegId, larmId], [lLegId,rLegId, rarmId, larmId] ] #~ limbs = [[lLegId,rLegId],[lLegId,rLegId, rarmId], [lLegId,rLegId, larmId], [lLegId,rLegId, rarmId, larmId] ]
#~ limbs = [[lLegId,rLegId, rarmId]] #~ limbs = [[lLegId,rLegId] ]
limbs = [[lLegId,rLegId, rarmId]]
#~ limbs = [[larmId, rarmId]] #~ limbs = [[larmId, rarmId]]
gen(limbs[0], 10) #~ gen(limbs[0], 1000)
for ls in limbs: for ls in limbs:
gen(ls, 10, False) gen(ls, 1000, False, unstable=True)
gen(limbs[0], 10) gen(limbs[0], 1000, unstable=True)
i = 0 i = 0
a = None a = None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment