chrono icon indicating copy to clipboard operation
chrono copied to clipboard

Gravitational force by a planet/moon

Open wedesoft opened this issue 1 year ago • 4 comments

Hi, I would like to use ProjectChrono for a space simulator. How can I implement a force (i.e. gravitation) which depends on the position of a spacecraft relative to a planet's or moon's position in order to simulate takeoff, orbiting and landing of a spacecraft? Kind regards Jan

wedesoft avatar Aug 17 '24 14:08 wedesoft

Also the position of the planet or especially moon can change over time.

wedesoft avatar Aug 17 '24 14:08 wedesoft

The most flexible way to do this is probably to use ChLoadBodyBody.

Derive your own class from this and implement the virtual method ComputeBodyBodyForceTorque. You can access the two bodies with GetBodyA and GetBodyB to get their current positions and orientations.

See ChLoadBodyBodyBushingGeneric for an example.

rserban avatar Aug 20 '24 11:08 rserban

Thanks for your response! Ok, will try. In the past I have successfully used Runge Kutta 4 integration to get stable orbits :)

wedesoft avatar Aug 20 '24 11:08 wedesoft

Awesome, it seems to work as long as the time steps are small enough (source code: chronoorbit.cc). I had to compile it with option -DEIGEN_MAX_ALIGN_BYTES=32 because it was crashing otherwise. orbit

wedesoft avatar Aug 20 '24 21:08 wedesoft

Thanks 👍

wedesoft avatar Aug 30 '24 15:08 wedesoft