1 / 66

Simulation Training Course

Simulation Training Course. Shervin Talebi Benjamin Swilling Nancy Cornelius Rob Playter. Objective. Teach how to use Digital Biomechanics simulation software Goals Understand Digital Biomechanics UI Set up simulation scenarios Set simulation parameters Run simulations Data analysis

Download Presentation

Simulation Training Course

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Simulation Training Course Shervin Talebi Benjamin Swilling Nancy Cornelius Rob Playter

  2. Objective Teach how to use Digital Biomechanics simulation software Goals • Understand Digital Biomechanics UI • Set up simulation scenarios • Set simulation parameters • Run simulations • Data analysis • Introduce simulation API (advanced) • Add custom control (advanced)

  3. Outline • How simulation works • Simulator overview • Quick tutorial • Modeling instruments • Understanding Equipment • Understanding Contact • Understanding Sensors • Simulated characters • Simulation specific variables and commands • Sample human simulation

  4. Fcontrol Fext Newton’s 2nd Law says Ftotal = ma therefore, a = Ftotal / m How Simulation Works (1/2) m Ftotal = Fcontrol + Fext

  5. . . Control Integrator .. Fexternal x x, x x, x Fcontrol Equations ofMotion How Simulation Works (2/2) Equations of Motion calculate acceleration from current state (pos. and vel. ) and forces Numerical Integrators calculate new positions and velocities from accelerations Control system determines new forces

  6. What is Digital Biomechanics (DB)? • Boston Dynamics’ Physics-based rigid-body dynamics simulator • Simulate humans/robots • Interactively configure environment • Contact properties • Character mass properties • Add equipment & sensors

  7. SIMULATE VISUALIZE SETUP PLOT DB Simulation Workflow Digital biomechanics has 4 modes

  8. DB File Formats • DB uses various types of files

  9. Quick Start Tutorial • Falling brick simulation (pg.22) Ideas to highlight • DB’s Four Windows • Camera Navigation • 3D window changes in playback mode • Positing via pose edit tool • Add/position props in the world • Setup contact relationships • Simulate and save results • Analyze data using BDIPlot

  10. Tutorial Review • Tutorial simulated falling brick • Explored various aspects of DB • Continue with an more in-depth description of DB • Equipment/Sensors • Contact • Understanding/Setting Variables

  11. Equipment • Equipment can be statically attached to character links • Affects contact and mass properties • Equipment can be: • Scaled • Positioned/Oriented • Grouped • Sensors are special type of equipment

  12. Sensors • Sensors can be used to measure and record simulation information • What can we measure? • Position • Velocity (linear and angular) • Acceleration (linear and angular) • Select reference frame (local/global)

  13. How Do I Add Equipment? • Create equipment kit • Add equipment entry to kit • Modify position, orientation, scaling offsets • Modify mass properties

  14. Object Radius Convex Hull Understanding Contact • Forces are calculated when objects are within an “Object Radius” of each other • Convex hulls are created for all shapes • Object Radius is added to all Shapes • Contact is reduced to single closest distance ( Edge/Edge or Point/Face ) • DB uses polyhedra/polyhedra contact

  15. Understanding Contact • Contact fails if objects interpenetrate

  16. Using Contact (1/2) • By default no contact relationships are defined • Character will fall through floor • A new contact relationship must be added for each pair of objects that exchange forces

  17. Using Contact (2/2) • Contact relationships can be defined between • Character links • Props • Equipment • Use 2 scenario objects • Contact properties • Vector graphics • Can use these objects multiple times

  18. Contact Tutorial • Repeat falling brick simulation, with point contacts (manual pg.37) Ideas to Highlight • Points are massless • Contact object for point only has a single vertex • Contact properties may need to be adjusted depending on number of points simultaneously in contact • Graphics can be configured at UI to show interaction forces in various ways

  19. Ground Contact Tuning • To insure stability and avoid ground reaction force vectors that oscillate wildly, some care must be taken when choosing the ground contact parameters. (see chapter 13 in DB User Manual for in depth review)

  20. Understanding Ground Contact

  21. Ground Contact Stability Unstable Region Stable Region

  22. Summary So far, we have talked about • Basics of simulation • Basics of DB • DB workflow • Modeling contact in DB • Adding equipment/sensors

  23. What Next? • Simulation charachters • Simulation variables • Commands and scripting • Perform more interesting simulations • SimUI • Sensors • BDIPlot

  24. Joint Body Simulated Characters • Simulated characters are trees of • Joints • Links • Joints can have multiple degrees of freedom (DOF) • dofname is not always equal to jointname • For pin joints (1 DOF) jointname = dofname • Base joint has 6 DOF

  25. hl_hip_rx hl_hip_ry hl_knee_ry hr_hip_rx fl_hip_rx z y hr_hip_ry x fl_hip_ry hr_knee_ry fr_hip_ry fr_hip_rx fl_knee_ry fr_knee_ry LittleDog character 13 Links - 18 DOF - 3 Pin joints / leg

  26. Simulation Variables • Simulations include many variables • State (position, velocity, acceleration) • Timing • Servos • Forces • Variable names follow Boston Dynamics standard

  27. State Variables Each model’s degree of freedom (dof) has state (position, velocity, acceleration)

  28. Timing Variables Simulations depend on a number of timing variables. Some are set at DB’s UI, others can be controlled for each character. All simulations are integrated and recorded at the same rate.

  29. Misc. Variables Various other variables control/report behavior of simulated characters.

  30. Servo Variables PD+FF servo is most general servo. tau.dofname = ff_dofname + k_dofname (q.dofname - q_d. dofname) + b_dofname (qd.dofname - qd_d. dofname) Output is clipped such that | tau.dofname |  tmax.dofname

  31. Joint Servos Four different servos are available for each simulations DOF. Servo select based on value of servosw.dofname.

  32. Joint Limits Joint motion can be limited to simulate physical joint constraints. Constraints implemented as servos.

  33. External Forces • External forces act on all links that belong to a contact relationship

  34. Simulation Commands (1/2) • Simulation parameters can be modified in simulation mode using special commands • Commands can be issued via • DB command line • Script files • Batch files • Commands are executed sequentially

  35. Simulation Commands (2/2) • Many commands (pg.82) • Commands support basic regexp syntax

  36. LittleDog walking simulation • Load scenario: LittleDog_Walk.dbs • Run simulation using script file: LittleDog_Walk.script • Save results • Playback data, and use BDIplot • Load data file in Matlab

  37. Commands Tutorial • Run simple simulation • Modify behavior by issuing commands at DB command line • Save Data • Create script file that issues same commands • Run simulation and load script file • Save Data • Compare Data in BDIPlot

  38. Batch Processing Example Start up batch mode and type: !cd examples/littledog/scripts open ../LittleDog_walk.dbs start target littledog open LittleDog_walk.script set k_f[lr]_knee_ry 20 run 10 save ../littledog_test.dbs stop close

  39. Batch Mode Looping • Batch mode currently has no embedded looping function. • However looping functionality can be achieved by at least two methods: • Interface Digital Biomechanics with another scripting language (MS Jscript) • Write another program to generate Digital Biomechanics scripts with loops explicitly included. (see appendix for Matlab example)

  40. Batch Mode Looping with MS Jscript var WshShell = WScript.CreateObject("WScript.Shell"); WshShell.Run(“cmd.exe"); WScript.Sleep(100); WshShell.AppActivate("cmd.exe"); WshShell.SendKeys("cd %%DIGITAL_BIOMECHANICS%\\db\\examples\\littledog~"); WshShell.SendKeys(“%%DIGITAL_BIOMECHANICS%%\\bin\\win32\\i586\\db.exe -no_ui~"); WshShell.SendKeys("open LittleDog_walk.dbs~"); var k; for (k = 10; k < 85;) { WshShell.SendKeys("start~"); WshShell.SendKeys("open scripts\\LittleDog_walk.script~"); WshShell.SendKeys("set k_f* " + k.toLocaleString() + "~"); WScript.Sleep(100); WshShell.SendKeys("run 5~"); WshShell.SendKeys("save testk" + k.toLocaleString() + ".dbs~"); WScript.Sleep(100); WshShell.SendKeys("stop~"); k = k + 5; } WshShell.SendKeys("exit~");

  41. Explicit Loops with DB Scripting open LittleDog_walk.dbs start open scripts\LittleDog_walk.script set k_f* 10 run 5 save testk10.dbs stop start open scripts\LittleDog_walk.script set k_f* 15 run 5 save testk15.dbs stop … start open scripts\LittleDog_walk.script set k_f* 80 run 5 save testk80.dbs stop exit

  42. Customizing Simulations • New controlled behaviors can be added to a character • Use simulation C++ API • Commonly used functions (forward kinematics) provided for ease of use and to avoid common math errors • Many functions optimized for efficiency

  43. Getting Started Check your setup (section 10.1 pg.131) • Start shell • Make sure compiler can be found • Try cl /help • cd %DIGITAL_BIOMECHANICS%/sim/LittleDog • nmake /f Makefile.nmake

  44. C++ Refresher (1/2) • C++ allows hierarchy of classes to be created (OOP) • You can write general parent classes and specialize child behavior • DB uses this feature to allow user customization of simulations A Parent B Child

  45. C++ Refresher (2/2) void B::test( void ) { // Do special behavior int i = 0; i++; // Do default behavior A::test(); } // Parent class class A { public: A() ~A() virtual void test( void );}; // Child class class B : public A { public: A() ~A() virtual void test( void );}; int main( int argc, char argv[] ) { A a; B b; a.test(); b.test(); return 0; }

  46. Simulation Hierarchy bdiSimulation bdiCLSimulation GENERIC dbSimulation bdiCLSimulation_name_base SIMULATION SPECIFIC bdiCLSimulation_name bdiCLSimulation_name_customize pg.133

  47. . . Control Integrator .. Fexternal x x, x x, x Fcontrol Equations ofMotion goal_now(goal_dt) control_now(control_dt) servo_now (servo_dt) Simulations: A Closer Look handle_command

  48. Adding a Variable (1/3) • Users can add variables to simulations so that they appear at simulation UI Adding variables to simulation allows, • Users to inspect/record values of variables • Users to set variable values via script files/command line • Users to restore FULL controller state from DBS file • BDI encourages use of ls_ prefix to help quickly identify which variables have been added to simulation • Variables MUST be added during class construction

  49. Adding a Command (2/3) • 3 overloaded functions in bdiSimulation class allow for easy addition of variables ( from bdiSimulation.h ) void add_variable( const char *, double * , double value=0.0 ); void add_variable( const char *, float * , float value=0.0 ); void add_variable( const char *, int * , int value=0 );

  50. Adding a Variable (3/3) ( from creature_littledog_customize.h ) class bdiCLSimulation_littledog_customize : public bdiCLSimulation_littledog { ... double ls_example_gain1; }; ( from creature_littledog_customize.cpp ) bdiCLSimulation_littledog_customize::bdiCLSimulation_littledog_customize() { add_variable( “example_gain1”, &ls_example_gain1, 100 ); return; }

More Related