-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from kreft/April_fixes
Fix for agent spawners not completing spine function initialization
- Loading branch information
Showing
6 changed files
with
73 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package agent; | ||
|
||
import dataIO.Log; | ||
import expression.Expression; | ||
import idynomics.Global; | ||
import idynomics.Idynomics; | ||
import referenceLibrary.AspectRef; | ||
import surface.link.LinearSpring; | ||
import surface.link.Spring; | ||
import surface.link.TorsionSpring; | ||
import utility.Helper; | ||
|
||
public class AgentHelperMethods { | ||
public static void springInitialization(Agent a) | ||
{ | ||
Body b = (Body) a.get(AspectRef.agentBody); | ||
for( Spring s : b.getSpringsToEvaluate()) | ||
{ | ||
if( s != null ) | ||
{ | ||
if( !s.ready()) | ||
{ | ||
s.setStiffness( Helper.setIfNone( a.getDouble(AspectRef.spineStiffness), | ||
1e6)); | ||
//TODO warn user if not set | ||
if( s instanceof LinearSpring) | ||
{ | ||
Expression spineFun; | ||
if ( !Helper.isNullOrEmpty( a.getValue( | ||
AspectRef.agentSpineFunction ))) | ||
spineFun = new Expression((String) | ||
a.getValue(AspectRef.agentSpineFunction )); | ||
else | ||
spineFun = Global.fallback_spinefunction; | ||
s.setSpringFunction( spineFun ); | ||
} | ||
else if( s instanceof TorsionSpring) | ||
{ | ||
Expression torsFun = null; | ||
if ( !Helper.isNullOrEmpty( | ||
a.getValue(AspectRef.torsionFunction))) | ||
torsFun = (Expression) | ||
a.getValue(AspectRef.torsionFunction); | ||
else | ||
{ | ||
/* TODO set default maybe? */ | ||
Idynomics.simulator.interupt( | ||
"missing torsion spring function in relax"); | ||
} | ||
s.setSpringFunction( torsFun ); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters