Newer
Older
import time
import uuid
def makeDDP():
rcost_x = .1
rcost_u = .2
tcost_x = 3.
horizon = 100
model = crocoddyl.ActionModelUnicycle()
modelT = crocoddyl.ActionModelUnicycle()
modelT.costWeights = np.array([tcost_x, 0])
state = np.zeros(3)
problem = crocoddyl.ShootingProblem(state, [model] * horizon, modelT)
class TaskParameters:
'''Common information to all tasks, to be allocated by each minion and the boss. '''
ddp = makeDDP()
self.converged = converged
self.x0 = ddp.problem.x0.copy()
self.xs = np.array(ddp.xs)
self.us = np.array(ddp.xs)
self.v = ddp.cost
self.Vx = ddp.Vx[0].copy()
self.Vxx = ddp.Vxx[0].copy()
self.iter = ddp.iter
'''
Set a task with a list of initial state. Identifier is a uniq identifier of the task (for documentation only)
that is generated randomly if none is provided.
'''
self.identifier = identifier if identifier is not None else uuid.uuid1()
self.time = 0
self.x0s = x0s
self.results = []
def work(self):
start = time.perf_counter()
ddp = TaskParameters.ddp
for x0 in self.x0s:
ddp.problem.x0 = x0.copy()
res = ddp.solve()
self.time = time.perf_counter() - start
if __name__ == "__main__":