Skip to content
Snippets Groups Projects
Commit 416e7fa5 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Remove simulation member and replace simu by device in AbstractRobot class.

parent 184bea08
No related branches found
No related tags found
1 merge request!1[major][cpp] starting point to integrate pinocchio
...@@ -58,10 +58,6 @@ class AbstractHumanoidRobot (object): ...@@ -58,10 +58,6 @@ class AbstractHumanoidRobot (object):
name = None name = None
"""Entity name (internal use)""" """Entity name (internal use)"""
#FIXME: it should be some kind of global flag instead.
simulation = False
"""Are we in simulation or not?"""
halfSitting = None halfSitting = None
""" """
The half-sitting position is the robot initial pose. The half-sitting position is the robot initial pose.
...@@ -155,12 +151,12 @@ class AbstractHumanoidRobot (object): ...@@ -155,12 +151,12 @@ class AbstractHumanoidRobot (object):
if not self.dynamic: if not self.dynamic:
raise "robots models have to be initialized first" raise "robots models have to be initialized first"
if self.simulation: if not self.device:
self.simu = RobotSimu(self.name + '.simu') self.device = RobotSimu(self.name + '.device')
# Freeflyer reference frame should be the same as global # Freeflyer reference frame should be the same as global
# frame so that operational point positions correspond to # frame so that operational point positions correspond to
# position in freeflyer frame. # position in freeflyer frame.
self.simu.set(self.halfSitting) self.device.set(self.halfSitting)
self.dynamic.position.value = self.halfSitting self.dynamic.position.value = self.halfSitting
self.dynamic.velocity.value = self.dimension*(0.,) self.dynamic.velocity.value = self.dimension*(0.,)
...@@ -203,7 +199,7 @@ class AbstractHumanoidRobot (object): ...@@ -203,7 +199,7 @@ class AbstractHumanoidRobot (object):
setattr(self, memberName, self.features[op]) setattr(self, memberName, self.features[op])
def __init__(self, name, simulation): def __init__(self, name):
self.name = name self.name = name
if simulation: if simulation:
self.simulation = True self.simulation = True
...@@ -227,11 +223,10 @@ class HumanoidRobot(AbstractHumanoidRobot): ...@@ -227,11 +223,10 @@ class HumanoidRobot(AbstractHumanoidRobot):
halfSitting = [] #FIXME halfSitting = [] #FIXME
name = None name = None
simulation = None
filename = None filename = None
def __init__(self, name, simulation, filename): def __init__(self, name, filename):
AbstractHumanoidRobot.__init__(self, name, simulation) AbstractHumanoidRobot.__init__(self, name)
self.filename = filename self.filename = filename
self.dynamic = \ self.dynamic = \
self.loadModelFromKxml (self.name + '.dynamics', self.filename) self.loadModelFromKxml (self.name + '.dynamics', self.filename)
......
...@@ -90,8 +90,8 @@ solver.sot.push(robot.name + '.task.com') ...@@ -90,8 +90,8 @@ solver.sot.push(robot.name + '.task.com')
dynamicWalking = DynamicWalking(robot) dynamicWalking = DynamicWalking(robot)
for i in xrange(100): for i in xrange(100):
robot.simu.increment(timeStep) robot.device.increment(timeStep)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
...@@ -44,11 +44,11 @@ solver.sot.push(robot.name + '.task.com') ...@@ -44,11 +44,11 @@ solver.sot.push(robot.name + '.task.com')
# Main. # Main.
# Main loop # Main loop
for i in xrange(500): for i in xrange(500):
robot.simu.increment(timeStep) robot.device.increment(timeStep)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
finalPosition = ( finalPosition = (
...@@ -64,5 +64,5 @@ finalPosition = ( ...@@ -64,5 +64,5 @@ finalPosition = (
0.23896800000000001, 0.21485599999999999, -0.18973400000000001, 0.23896800000000001, 0.21485599999999999, -0.18973400000000001,
-0.49457699999999999, 0.040646799999999997, 0.16970299999999999, 0.100067) -0.49457699999999999, 0.040646799999999997, 0.16970299999999999, 0.100067)
checkFinalConfiguration(robot.simu.state.value, finalPosition) checkFinalConfiguration(robot.device.state.value, finalPosition)
print "Exiting." print "Exiting."
...@@ -180,13 +180,13 @@ totalSteps = int((stepTime / timeStep) * steps) ...@@ -180,13 +180,13 @@ totalSteps = int((stepTime / timeStep) * steps)
t = 0 t = 0
for i in xrange(totalSteps + 1): for i in xrange(totalSteps + 1):
t += timeStep t += timeStep
robot.simu.increment(timeStep) robot.device.increment(timeStep)
quasiStaticWalking.update(t) quasiStaticWalking.update(t)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
# Security: switch back to double support. # Security: switch back to double support.
quasiStaticWalking.moveCoM('origin') quasiStaticWalking.moveCoM('origin')
...@@ -194,11 +194,11 @@ duration = quasiStaticWalking.time[quasiStaticWalking.stateCoM_singleToDouble] ...@@ -194,11 +194,11 @@ duration = quasiStaticWalking.time[quasiStaticWalking.stateCoM_singleToDouble]
for i in xrange(int(duration / timeStep)): for i in xrange(int(duration / timeStep)):
t += timeStep t += timeStep
robot.simu.increment(timeStep) robot.device.increment(timeStep)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
finalPosition = ( finalPosition = (
-0.0082169200000000008, -0.0126068, -0.00022860999999999999, -0.0082169200000000008, -0.0126068, -0.00022860999999999999,
...@@ -213,5 +213,5 @@ finalPosition = ( ...@@ -213,5 +213,5 @@ finalPosition = (
0.26377400000000001, 0.171155, -0.00065098499999999998, 0.26377400000000001, 0.171155, -0.00065098499999999998,
-0.52324700000000002, -1.23291e-05, 6.0469500000000001e-05, 0.100009) -0.52324700000000002, -1.23291e-05, 6.0469500000000001e-05, 0.100009)
checkFinalConfiguration(robot.simu.state.value, finalPosition) checkFinalConfiguration(robot.device.state.value, finalPosition)
print "Exiting." print "Exiting."
...@@ -35,11 +35,11 @@ solver.sot.push(robot.name + '.task.com') ...@@ -35,11 +35,11 @@ solver.sot.push(robot.name + '.task.com')
# Main. # Main.
# Main loop # Main loop
for i in xrange(500): for i in xrange(500):
robot.simu.increment(timeStep) robot.device.increment(timeStep)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
finalPosition = ( finalPosition = (
-0.0357296, -0.0024092699999999998, 0.033870600000000001, -0.0357296, -0.0024092699999999998, 0.033870600000000001,
...@@ -55,5 +55,5 @@ finalPosition = ( ...@@ -55,5 +55,5 @@ finalPosition = (
-0.109959, -0.60156299999999996, -0.082422700000000002, -0.109959, -0.60156299999999996, -0.082422700000000002,
1.0207200000000001, 0.10037500000000001) 1.0207200000000001, 0.10037500000000001)
checkFinalConfiguration(robot.simu.state.value, finalPosition) checkFinalConfiguration(robot.device.state.value, finalPosition)
print "Exiting." print "Exiting."
...@@ -34,11 +34,11 @@ solver.sot.push(robot.name + '.task.com') ...@@ -34,11 +34,11 @@ solver.sot.push(robot.name + '.task.com')
# Main. # Main.
# Main loop # Main loop
for i in xrange(500): for i in xrange(500):
robot.simu.increment(timeStep) robot.device.increment(timeStep)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
finalPosition = ( finalPosition = (
-0.015183500000000001, -0.00037148200000000002, -0.00065935600000000005, -0.015183500000000001, -0.00037148200000000002, -0.00065935600000000005,
...@@ -53,5 +53,5 @@ finalPosition = ( ...@@ -53,5 +53,5 @@ finalPosition = (
0.170987, 0.100064, -0.117492, 0.24870200000000001, 0.016264399999999998, 0.170987, 0.100064, -0.117492, 0.24870200000000001, 0.016264399999999998,
-0.56795700000000005, 0.0040012399999999997, 0.18956200000000001, 0.100089) -0.56795700000000005, 0.0040012399999999997, 0.18956200000000001, 0.100089)
checkFinalConfiguration(robot.simu.state.value, finalPosition) checkFinalConfiguration(robot.device.state.value, finalPosition)
print "Exiting." print "Exiting."
...@@ -33,11 +33,11 @@ solver.sot.push(robot.name + '.task.com') ...@@ -33,11 +33,11 @@ solver.sot.push(robot.name + '.task.com')
# Main. # Main.
# Main loop # Main loop
for i in xrange(500): for i in xrange(500):
robot.simu.increment(timeStep) robot.device.increment(timeStep)
if clt: if clt:
clt.updateElementConfig( clt.updateElementConfig(
'hrp', robot.smallToFull(robot.simu.state.value)) 'hrp', robot.smallToFull(robot.device.state.value))
finalPosition = ( finalPosition = (
...@@ -53,5 +53,5 @@ finalPosition = ( ...@@ -53,5 +53,5 @@ finalPosition = (
0.23896800000000001, 0.21485599999999999, -0.18973400000000001, 0.23896800000000001, 0.21485599999999999, -0.18973400000000001,
-0.49457699999999999, 0.040646799999999997, 0.16970299999999999, 0.100067) -0.49457699999999999, 0.040646799999999997, 0.16970299999999999, 0.100067)
checkFinalConfiguration(robot.simu.state.value, finalPosition) checkFinalConfiguration(robot.device.state.value, finalPosition)
print "Exiting." print "Exiting."
...@@ -154,9 +154,9 @@ class Solver: ...@@ -154,9 +154,9 @@ class Solver:
self.sot.signal('damping').value = 1e-6 self.sot.signal('damping').value = 1e-6
self.sot.setNumberDofs(self.robot.dimension) self.sot.setNumberDofs(self.robot.dimension)
if robot.simu: if robot.device:
plug(self.sot.signal('control'), robot.simu.signal('control')) plug(self.sot.signal('control'), robot.device.signal('control'))
plug(self.robot.simu.state, plug(self.robot.device.state,
self.robot.dynamic.position) self.robot.dynamic.position)
......
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