I'd like to use the examples that come with Bullet to try to make a very simple physics simulator. The simulator would be used to test online servo/controller designs under different motor strengths, parameter settings, etc
The physical system is a simple inverted compound pendulum, just a single rigid uniform rod. It's constrained to vertical planar motion, around the origin, by using a simple hinge constraint. Torque can be applied by a controller motor.
It seems this is nearly the same as the example
Code: Select all
bullet3/examples/Constraints/TestHingeTorque.cpp
Here's a youtube video of similar physical system, and an online controller design - [Inverted Pendulum Swing-Up Design](https://www.youtube.com/watch?v=C39sm1L2g60)
For the physics simulation I'd like to just focus on one application of the servo/controllers action, which happens at the start of the simulation.
If say, theta_t is the angle of the rod with the vertical axis, at time step t. Then the inputs are, the initial state, ( theta_0 , angular velocity_0 ), and the torque impulse u applied by the the controller motor, at the start of the simulation, (timestep t=0).
I'd like to render an image of the pendulum at t=0.
Then, use Bullet to run the simulation for say T=3 or 4 or 5 steps/frames.
Then render an image of the pendulum at T, and output the final state, (theta_T , angular velocity_T )
I've tried doing this in Blender, but I found it would be very messy getting the controllers input into it, [Setup an inverted pendulum simulation with BGE](http://blender.stackexchange.com/questi ... 3693_33806)
At the moment I only want to render two frames, from one hard coded camera perspective, and the images can be greyscale, and small say 150x150 pixels. So, I think simulation using Bullet, and simple OpenGL rendering is the simplest way to do this?
##---------------------------------------
To get started, (I'm beginner), I think nearly all of the code I need is already in the examples? The problems pure dynamics, and (I think) there's no collision detection needed? An outline of the code I think is useful is,
i) adapt the HelloWorld example for the basic setup and simulation loop.
ii) adapt/understand the TestHingeTorque example
Code: Select all
bullet3/examples/Constraints/TestHingeTorque.cpp
iii) adapt the rendering example,
Code: Select all
bullet3/examples/SimpleOpenGL3/main.cpp
iv) try to do this all with the Lua bindings - my controller code is written in Lua - I think this is possible?
[Bullet SWIG (Simplified Wrapper Interface Generator) 4 Lua](http://www.bulletphysics.org/Bullet/php ... lua#p12524)
##---------------------------------------
I'd just like to ask if people think this is the right way to do it, and if there's already code of something similar out there that I could build from?
Kind regards,
Aj