Commit 48886bf5 authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Reduce initializations in prologue

  Application dependent initialization have been moved to a new package called
  sot-application.
parent 1464d907
......@@ -59,7 +59,6 @@ SET(PYTHON_MODULE_BUILD_DIR
SET(PYTHON_MODULE dynamic_graph/sot/hrp2)
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "__init__.py" )
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "hrp2.py" )
PYTHON_INSTALL_ON_SITE("${PYTHON_MODULE}" "prologue.py" )
SET(FILES __init__.py robot.py)
# Install dynamic_graph.sot.hrp2_14
......
# -*- coding: utf-8 -*-
# Copyright 2011, Florent Lamiraux, Thomas Moulard, Olivier Stasse, JRL, CNRS/AIST
#
# This file is part of dynamic-graph.
# dynamic-graph is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# dynamic-graph is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
print("Prologue HRP-2")
from dynamic_graph import plug
from dynamic_graph.entity import PyEntityFactoryClass
from dynamic_graph.sot.dynamics.solver import Solver
def prologue_hrp2(robot,device):
# Initialize the zmp signal to the current com.
_com = robot.dynamic.com.value
robot.device.zmp.value = (_com[0], _com[1], 0.)
# Create a solver.
solver = Solver(robot)
# Make sure com and feet desired positions match the current
# positions.
s = ['left-ankle', 'right-ankle']
for i in s:
robot.dynamic.signal(i).recompute(robot.dynamic.signal(i).time + 1)
robot.features[i].reference.value = \
robot.dynamic.signal(i).value
robot.features[i]._feature.selec.value = '111111'
robot.tasks[i].controlGain.value = 1.
robot.comRef.value = robot.dynamic.com.value
robot.tasks ['com'].controlGain.value = 1.
# Push com and feet tasks.
#
# The robot is currently in half-sitting, so this script freezes com
# and feet position so that the robot will remain stable while the
# user program is starting.
solver.push(robot.comTask)
for i in s:
solver.push(robot.tasks[i])
print("Prologue ran successfully.")
# Make sure only robot and solver are visible from the outside.
return solver
####################################
# --- IMPORTANT --- #
# #
# THIS FILE MUST NEVER BE CHANGED. #
# TO RUN YOUR EXPERIMENT, PLEASE #
# WRITE A SEPARATE PYTHON MODULE #
# AND LAUNCH IT USING dg-remote! #
####################################
......@@ -15,8 +15,7 @@
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
print("Prologue HRP2-10")
from dynamic_graph.sot.hrp2_10.robot import *
from dynamic_graph.sot.hrp2.prologue import *
from dynamic_graph.sot.hrp2_10.robot import Robot
# Create the device.
# This entity behaves exactly like robotsimu except:
......@@ -24,14 +23,14 @@ from dynamic_graph.sot.hrp2.prologue import *
# 2. it forwards the robot control to the sot-abstract
# controller.
Device = PyEntityFactoryClass('Device')
# Create instance for HRP2JRL
device=Device('HRP2JRL')
# Create the robot using the device.
robot = Robot(name = 'robot', device = device)
robot = Robot(name = 'robot', device = Device('HRP2JRL'))
solver = prologue_hrp2(robot,device)
__all__ = ["robot","solver"]
_com = robot.dynamic.com.value
robot.device.zmp.value = (_com[0], _com[1], 0.)
__all__ = ["robot"]
####################################
# --- IMPORTANT --- #
......
......@@ -15,8 +15,8 @@
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
print("Prologue HRP2-14")
from dynamic_graph.sot.hrp2_14.robot import *
from dynamic_graph.sot.hrp2.prologue import *
from dynamic_graph.entity import PyEntityFactoryClass
from dynamic_graph.sot.hrp2_14.robot import Robot
# Create the device.
# This entity behaves exactly like robotsimu except:
......@@ -24,14 +24,15 @@ from dynamic_graph.sot.hrp2.prologue import *
# 2. it forwards the robot control to the sot-abstract
# controller.
Device = PyEntityFactoryClass('Device')
# Create instance for HRP2JRL
device=Device('HRP2LAAS')
# Create the robot using the device.
robot = Robot(name = 'robot', device = device)
robot = Robot(name = 'robot', device = Device('HRP2LAAS'))
solver = prologue_hrp2(robot,device)
__all__ = ["robot","solver"]
robot.dynamic.com.recompute (0)
_com = robot.dynamic.com.value
robot.device.zmp.value = (_com[0], _com[1], 0.)
__all__ = ["robot"]
####################################
# --- IMPORTANT --- #
......
......@@ -35,7 +35,7 @@ void SoTHRP2_14_Controller::startupPython()
std::ofstream aof(LOG_PYTHON_14.c_str());
runPython
(aof,
"from dynamic_graph.sot.hrp2_14.prologue import robot, solver",
"from dynamic_graph.sot.hrp2_14.prologue import robot",
*interpreter_);
aof.close();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment