Gravitational force by a planet/moon
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
Also the position of the planet or especially moon can change over time.
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.
Thanks for your response! Ok, will try. In the past I have successfully used Runge Kutta 4 integration to get stable orbits :)
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.
Thanks 👍