Commit 6d7525c7 authored by Steve Tonneau's avatar Steve Tonneau
Browse files

export helpers for all scenarios

parent 095ccb59
......@@ -18,6 +18,7 @@
from hpp.corbaserver.rbprm import Client as RbprmClient
from hpp.corbaserver import Client as BasicClient
import hpp.gepetto.blender.exportmotion as em
## Corba clients to the various servers
#
......@@ -111,6 +112,14 @@ class Builder (object):
def setFilter (self, romFilter):
return self.client.rbprm.rbprm.setFilter (romFilter)
## Export a computed path for blender
#
# \param problem the problem associated with the path computed for the robot
# \param stepsize increment along the path
# \param pathId if of the considered path
# \param filename name of the output file where to save the output
def exportPath (self, viewer, problem, pathId, stepsize, filename):
em.exportPath(viewer, self.client.basic.robot, problem, pathId, stepsize, filename)
## \name Degrees of freedom
# \{
......@@ -267,7 +276,7 @@ class Builder (object):
# \return whether configuration is valid
def isConfigValid (self, cfg):
return self.client.basic.robot.isConfigValid (cfg)
## Compute distances between bodies and obstacles
#
# \return list of distances,
......
......@@ -217,6 +217,18 @@ class FullBody (object):
# \param filename outputfile where to export the motion
def exportMotion(self, viewer, configurations, filename):
em.exportStates(viewer, self.client.basic.robot, configurations, filename)
## Export motion to a format readable by the blender
# importFromGepetto script
# \param viewer gepetto viewer instance
# \param configurations list of configurations to save
# \param filename outputfile where to export the motion
def exportAll(self, viewer, configurations, testname):
self.exportMotion(viewer, configurations, testname+"_motion.txt")
self.saveComputedStates(testname+"_states.txt")
f1 = open(testname+"_configs.txt","w+")
f1.write(str(configurations))
f1.close()
## \name Degrees of freedom
# \{
......
......@@ -387,7 +387,8 @@ namespace hpp {
}
state.nbContacts = state.contactNormals_.size() ;
state.configuration_ = config;
state.stable = stability::IsStable(fullBody,state) >= 0;
state.robustness = stability::IsStable(fullBody,state);
state.stable = state.robustness >= 0;
fullBody->device_->currentConfiguration(old);
}
......@@ -476,12 +477,12 @@ namespace hpp {
void RbprmBuilder::saveComputedStates(const char* outfilename) throw (hpp::Error)
{
std::stringstream ss;
ss << lastStatesComputed_.size() << "\n";
std::vector<rbprm::State>::const_iterator cit = lastStatesComputed_.begin();
ss << lastStatesComputed_.size()-1 << "\n";
std::vector<rbprm::State>::const_iterator cit = lastStatesComputed_.begin()+1;
int i = 0;
ss << i++ << " ";
cit->print(ss);
for(std::vector<rbprm::State>::const_iterator cit2 = lastStatesComputed_.begin()+1;
for(std::vector<rbprm::State>::const_iterator cit2 = lastStatesComputed_.begin()+2;
cit2 != lastStatesComputed_.end(); ++cit2, ++cit, ++i)
{
ss << i<< " ";
......
Supports Markdown
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