Assignment #3: Simulation


Instructor: Irfan Essa
TSRB 230A.
Office Hours: After Class
  Location: CoCB 102
TA: Justin Jang
Office Hours: Monday 1-2p, Wednesday 4-5p in CoCB 104a (DML)
Day/Time: Tuesdays - Thursdays 4:35pm-5:55pm

CA2004
SITE menu
Home
Schedule
CoWeb
Participants
Books
Assignments
Readings
Resources
Information
 


Additional Information
CoWeb
DVFX@GT
GVU Center
Readings
Related Classes
Open Dynamics Eng.
Mocap Source
Alias | MAYA

Goals:

The goal of this assignment is to use the Open Dynamics Engine (ODE) to explore certain aspects of physical simulation. The ODE Documentation will be an indispensable resource throughout this assignment.

The assignment is broken up in 3 parts. Part 1, 2, & 3. Part 1 is DUE 11/2/04 (Before Class) and Parts 2 & 3 are due 11/9/04 (before class).

Part 1 | Part 2 | Part 3 | What to Turn In | Helpful Tips


Part 1: Gravity & Time-steps (30%)

Setting up ODE

Download the latest version of ODE (version 0.5 as of 2004-05-29) from sourceforge. (The links are found on the ODE download page. To use ODE, one only needs to get a binary release. The source code is also available. The ODE download page has a good explanation of the different binary releases available. The suggested release for this assignment is ode-bin-0.5-msvc-dll-SINGLE-debug-trimesh.zip, which provides a dll and lib compiled in Microsoft Visual Studio in debug mode with triangle mesh support and single precision float computation. Also get ode-0.5.tgz, which is the source code.

A Simple Dynamic Simulation

The folder /net/dvfx/CA/ProblemSets/PS3/code/part1_msvc6 contains a simple C program that drops a ball subject to gravity. Copy these files to your own directory and open the .dsw file into MS Visual C++ 6.x (available in the States Cluster and DML lab).
  • Build | Execute (or CTRL+F5) will build and run the program.

The file fall.c (included in the above directory) is a simple C program that drops a ball subject to gravity. It writes a file "output.txt" containing the y-position of the ball over the first ten 0.1 second time-steps. (Observe that dropping a ball using ODE is as simple as creating a world, defining gravity for that world, creating a body in that world, and stepping the time in that world.)

Dropping Balls

Modify the ball dropping program to drop a ball N times, each with a different a time-step, and record the final position of the ball after 1 second (of simulation time, not real time). One way to do this is to create N worlds each with 1 ball each and simply step each with a different time-step size. Specifically, use N=20 and start with a time-step of 1 second decreasing it by half for each instance, i.e. ts=1 for 1 step, ts=0.5 for 2 steps, ts=0.25 for 4 steps, etc. Set gravity to (0.0, -9.80665, 0.0) for convenience, though feel free to play around with it. Discuss your results and observations.


Part 2: Collisions & Friction (50%)

Collisions

The folder /net/dvfx/CA/ProblemSets/PS3/code/part2_msvc6 contains a C program that shows how to connect bodies using joints and perform collision detection on the geometry (corresponding to the bodies). This is a demo of a chain of balls where one end is being tugged with a varying force (in this case the force varies according to a sine function. Collision detection is being performed between all balls that are not connected to each other by a joint and between the balls and the ground.

Dealing with instability
The demo allows you to adjust the the Error Reduction Parameter (ERP) and Constraint Force Mixing (CFM) parameter. (The "{" & "[" keys adjust the ERP; the "}" & "]" keys adjust the CFM.) These parameters provide control over the way computational errors in the simulation are managed. In effect, they can provide a spring and damper effect and thus help control computational instability in the simulation. According to the ODE documentation, ERP = h*kp/(h*kp+kd) and CFM = 1/(h*kp+kd), where kp is the spring constant, kd is the damper constant, and h is the step size. Play around with different combinations of these values and discuss what you observe. Note that this may include a few program crashes. Why? Try modifying the timestep. What effect does this have?

Note that the file test_chain1_mod.c (included in the above directory) is a modified C source of one of the demos found on the v0.5 ODE source code distribution. It leverages the drawstuff library which is bundled with the current (and past) ODE release. (The drawstuff library basically provides a primitive front-end GUI and display for scenes.)

Using the DrawStuff library
In order for it to find its texture files, your working/running directory needs to be the same or the same level as the "drawstuff\textures\" directory. That is, DrawStuff looks for its textures at "..\..\drawstuff\textures\". For example, "Z:\cs4496\ode\ode-0.5\drawstuff\textures\" and "Z:\cs4496\ode\ode-0.5\ode\test\" are equivalent. In MSVC6, goto Project | Settings and click the Debug tab to change the working directory. In our case, it might be best to use "<yourpath>\part2_msvc6\Debug\" as the working directory and nest the drawstuff textures folder as "<yourpath>\drawstuff\textures".

In MSVC6, you also need to make sure your paths are set. Goto Tools | Options and under the Directories tab you can select Include, Library, Executable, and Source file paths from the drop down box. Make sure "ode/ode.h", "drawstuff/drawstuff.h", "ode.lib", "drawstuff.lib", "opengl32.lib", and "glu32.lib" are accesible. Note that "opengl32.lib" and "glu32.lib" may already be accessible.

For help on getting the code to compile and execute in MSVC6, contact the TA

  • jang "at" cc.gatech.edu.

Friction

Create a "billiard table" simulation using ODE. Billiard pockets are not required. The setup doesn't even have to look like a billiard table. The point is to experiment with friction. Four walls, a ground, and a handfull of balls is sufficient. You may want to look at the source code of the demos included with the ODE distribution (nested under the subdirectory "ode\test\" of the source distribution). Information on ODE friction parameters can be found in section 7.3.7 of the ODE documentation. To keep it simple, you can focus on the mu friction parameter, though the bounce parameter will probably come in handy here.

Play around with the friction and the time-step sizes. In particular, what happens with high friction? What about large time-steps?


Part 3: Creative Simulation (20%)

Create a scene or scenario that uses dynamic simulation. For example, create a short sequence of a Rube-Goldberg machine or create an interactive . But don't let this example limit the scope of what you can do. Anything that satisfies the requirements is fine.

Requirements:

  • At least 10 objects. (An object is a component that has at least one degree of freedom from another. For example, a hammer with a head firmly attached to a handle counts as one object, while an arm with an elbow counts as two: the upper arm and the forearm.)
  • At least one joint.
  • At least one collision. (This implies at least 2 collision objects.)

What to turn in:

Part 1:
  1. fall.c source file with your modifications
  2. brief discussion/analysis (in a text file or html doc). Include the recorded numbers.
Part 2:
  1. discussion about the stability of the collisions with respect to the ERP, CFM, and timestep size (textfile/html).
  2. "billiard table" code and instructions on how to compile/run
  3. discussion about the stability with respect to the friction (mu) and timestep size (textfile/html).
Part 3:
  1. code and instructions on how to compile/run (OR a video of your simulation)
  2. explanation of what you did (textfile/html).

You can combine all the discussion in a single textfile/htmldoc if you wish.

You are free to use any platform you wish, but it must be able to run in the States Cluster, the DML lab, or the Mac lab in CoC (specify instructions in a README.TXT file). Depending on your success in getting the Drawstuff library to cooperate, this may involve writing your own front end to display graphics of balls and boxes, e.g. using OpenGL. A menu-driven gui is NOT necessary.

Submit in /net/dvfx/CA/2004/Submit/P3/<username>/ (Include a README.txt file to say which files are which)


Help and Suggestions

  • Part 1: You may want to write out each sequence of positions for the balls to a text file in some excel-readable form. Then make some plots to aid your analysis.
  • Part 2: For the billiard table, you may want to work off of a working copy of the project from the chain of balls. This will save you the hassle of having to setup a project from scratch and making it compile and execute properly.
  • Part 3: If you decide to start your own MSVC6 project from scratch for part 3, you might find the following useful.

Using the DrawStuff library with MSVC6
In order to use the drawstuff library with Visual Studio, one needs to add resources.rc and resource.h to the MSVC6 project. These files are found in the drawstuff\src\ folder of the source code distribution. This basically means that in order to play around with ODE using the drawstuff library in Visual Studio, you need to get the source distribution (or at least these two files).

In addition, be sure to add "opengl32.lib glu32.lib ode.lib drawstuff.lib" to the list of libraries to link in the project settings.

  1. Goto "Project" then "Settings..." in the menu.
  2. Select the active configuration (the drop down list next to "Settings For:"). Selecting "All Configurations" is a good idea.
  3. Select the "Link" tab.
  4. In the Category "General", add the string "opengl32.lib glu32.lib ode.lib drawstuff.lib" to the list of "Object/library modules".


CA 2004 Site Menu: Home | Schedule | CoWeb | Participants | Books | Assignments | Readings | Resources | Information
Additional Inforamtion: CoWeb | DVFX@GT | GVU Center | Readings | Related Classes | Open Dynamics Eng. | Mocap Source | Alias | MAYA

Portions of the GT's CS4496/7496/DVFX Web may be reprinted or adapted for academic nonprofit purposes, providing the source is accurately quoted and duly credited.
The CS4496 Web © 1999-2004, College of Computing, Georgia Institute of Technology.
CopyRight Information and Disclaimer


Last Updated: Tuesday, November 30, 2004 08:11:07 PM