newton dynamics for python?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

newton dynamics for python?

Postby brightening-eyes » Mon Dec 31, 2018 4:44 am

hi,
I've got the sdk for newton using the latest master from github, and i've seen the swig wrapper
however, when i wanted to compile that, i've got an error meaning that vs 2015 can't call swig provided by newton.
now, i have some questions and suggestions regarding that:
1. is the swig wrapper stable?
2. if no, what's your idea to make it stable, or write something new with the help of cython or boost.python?
3. instead of providing project files, it is better to provide a setup.py that can handle this using the C++ compilers available to python and possibly install it
4. a readme should be provided and instruct users to download the latest version of swig (and that should be placed in the path to be able to call it from within python's setup script, or even the project)
5. do all of newton's features have been included in the swig script?
thanks.
brightening-eyes
 
Posts: 7
Joined: Sun Dec 30, 2018 11:38 pm

Re: newton dynamics for python?

Postby Julio Jerez » Mon Dec 31, 2018 11:08 am

hi
the python swig script was an experiment I started back when we were making the unity plugin, but I never finish it. what I wanted to do was making a single script for csharp and python, but then I realized that was not possible or at least was going to be too difficult to just focus on the csharp for the unity plugin.

you are welcome to make it a contribution in the form of a pull request, I would love to have one for making a blender plugin. but my agenda is quiet busy now, and I do not have time to focus on that.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton dynamics for python?

Postby brightening-eyes » Mon Dec 31, 2018 12:17 pm

so, what should i include in the swig wrapper?
dgNewton, dNewton, dgPhysics, which of them should be included?
i'm a bit confused with the directory structure
brightening-eyes
 
Posts: 7
Joined: Sun Dec 30, 2018 11:38 pm

Re: newton dynamics for python?

Postby Julio Jerez » Mon Dec 31, 2018 12:44 pm

You can check out the unity swig wrapper to get an idea.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton dynamics for python?

Postby brightening-eyes » Mon Dec 31, 2018 2:22 pm

ok, then what are "dAnimation", "dCompilerKit", "dLanguageBinding", "dScene"?
maybe i should implement them in python with boost.python since they have virtual functions etc
also sse, avx, and these kind of stuff are not needed. are they? since they deal with cpu instructions.
brightening-eyes
 
Posts: 7
Joined: Sun Dec 30, 2018 11:38 pm

Re: newton dynamics for python?

Postby brightening-eyes » Wed Jan 02, 2019 4:08 pm

ok, i've coded something in swig
if anything else should be added, let me know since i'm a bit new to newton
this is the swig file newton.i:
Code: Select all
%module newton
%{
#include "newton.h"
#include "dVector.h"
#include "dMatrix.h"
#include "dQuaternion.h"
#include "dLinearAlgebra.h"
#include "dNewton.h"
#include "dNewtonDynamicBody.h"
#include "dNewtonInputManager.h"
#include "dNewtonJoint.h"
#include "dNewtonKinematicBody.h"
#include "dNewtonMaterial.h"
#include "dNewtonMesh.h"
#include "dNewtonPlayerManager.h"
#include "dNewtonRayCast.h"
#include "dNewtonScopeBuffer.h"
#include "dNewtonTransformLerp.h"
#include "dNewtonTransformManager.h"
#include "dNewtonTriggerManager.h"
#include "dNewtonVehicleManager.h"
#include "dMaterialPairManager.h"
#include "dNewtonActuatorJoints.h"
#include "dNewtonBody.h"
#include "dNewtonCollision.h"
#include "dNewtonDynamicBody.h"
#include "dBaseHierarchy.h"
#include "dBezierSpline.h"
#include "dClassInfo.h"
#include "dCRC.h"
#include "dHeap.h"
#include "dList.h"
#include "dMap.h"
#include "dRefCounter.h"
#include "dString.h"
#include "dTree.h"
/*
#include "dCustom6dof.h"
#include "dCustomBallAndSocket.h"
#include "dCustomControllerManager.h"
#include "dCustomCorkScrew.h"
#include "dCustomDoubleHinge.h"
#include "dCustomDoubleHingeActuator.h"
#include "dCustomDryRollingFriction.h"
#include "dCustomFixDistance.h"
#include "dCustomGear.h"
#include "dCustomHinge.h"
#include "dCustomHingeActuator.h"
#include "dCustomInputManager.h"
#include "dCustomInverseDynamics.h"
#include "dCustomJoint.h"
#include "dCustomKinematicController.h"
#include "dCustomMotor.h"
#include "dCustomPathFollow.h"
#include "dCustomPlane.h"
#include "dCustomPlayerControllerManager.h"
#include "dCustomPulley.h"
#include "dCustomRackAndPinion.h"
#include "dCustomSlider.h"
#include "dCustomSliderActuator.h"
#include "dCustomSlidingContact.h"
#include "dCustomTireSpringDG.h"
#include "dCustomTransformManager.h"
#include "dCustomTriggerManager.h"
#include "dCustomUpVector.h"
#include "dCustomVehicleControllerManager.h"
#include "dCustomWheel.h"
#include "dVehicleChassis.h"
#include "dVehicleDashControl.h"
#include "dVehicleInterface.h"
#include "dVehicleManager.h"
#include "dVehicleNode.h"
#include "dVehicleSingleBody.h"
#include "dVehicleSolver.h"
#include "dVehicleVirtualDifferential.h"
#include "dVehicleVirtualEngine.h"
#include "dVehicleVirtualJoints.h"
#include "dVehicleVirtualTire.h"
#include "dAnimationAcyclicJoint.h"
#include "dAnimationAcyclicSolver.h"
#include "dAnimationCharacterRig.h"
#include "dAnimationCharacterRigManager.h"
#include "dAnimationEffectorBlendNode.h"
#include "dAnimationEffectorBlendNodePose.h"
#include "dAnimationEffectorBlendPose.h"
#include "dAnimationEffectorBlendRoot.h"
#include "dAnimationEffectorBlendTwoWay.h"
#include "dAnimationKinematicLoopJoint.h"
#include "dAnimationRigEffector.h"
#include "dAnimationRigForwardDynamicLimb.h"
#include "dAnimationRigHinge.h"
#include "dAnimationRigJoint.h"
#include "dAnimationRigLimb.h"
#include "dAnimationStdAfx.h"
*/

%}

%include "newton.h"
%include "dMathDefines.h"
%include "dVector.h"
%include "dMatrix.h"
%include "dQuaternion.h"
%include "dLinearAlgebra.h"
%include "dStdAfxNewton.h"
%include "dNewtonAlloc.h"
%include "dNewton.h"
%include "dNewtonDynamicBody.h"
%include "dNewtonInputManager.h"
%include "dNewtonJoint.h"
%include "dNewtonKinematicBody.h"
%include "dNewtonMaterial.h"
%include "dNewtonMesh.h"
%include "dNewtonPlayerManager.h"
%include "dNewtonRayCast.h"
%include "dNewtonScopeBuffer.h"
%include "dNewtonTransformLerp.h"
%include "dNewtonTransformManager.h"
//%include "dNewtonTriggerManager.h"
%include "dNewtonVehicleManager.h"
%include "dMaterialPairManager.h"
%include "dNewtonActuatorJoints.h"
%include "dNewtonBody.h"
%include "dNewtonCollision.h"
%include "dNewtonDynamicBody.h"
/*
%include "dContainersStdAfx.h"
%include "dBaseHierarchy.h"
%include "dBezierSpline.h"
%include "dRtti.h"
%include "dClassInfo.h"
%include "dCRC.h"
%include "dHeap.h"
%include "dList.h"
%include "dMap.h"
%include "dRefCounter.h"
%include "dString.h"
%include "dTree.h"
%include "dCustomJointLibraryStdAfx.h"
%include "dCustomAlloc.h"
%include "dCustomJoint.h"
%include "dCustom6dof.h"
%include "dCustomBallAndSocket.h"
%include "dCustomControllerManager.h"
%include "dCustomCorkScrew.h"
%include "dCustomDoubleHinge.h"
%include "dCustomDoubleHingeActuator.h"
%include "dCustomDryRollingFriction.h"
%include "dCustomFixDistance.h"
%include "dCustomGear.h"
%include "dCustomHinge.h"
%include "dCustomHingeActuator.h"
%include "dCustomInputManager.h"
%include "dCustomInverseDynamics.h"
%include "dCustomKinematicController.h"
%include "dCustomMotor.h"
%include "dCustomPathFollow.h"
%include "dCustomPlane.h"
%include "dCustomPlayerControllerManager.h"
%include "dCustomPulley.h"
%include "dCustomRackAndPinion.h"
%include "dCustomSlider.h"
%include "dCustomSliderActuator.h"
%include "dCustomSlidingContact.h"
%include "dCustomTireSpringDG.h"
%include "dCustomTransformManager.h"
%include "dCustomTriggerManager.h"
%include "dCustomUpVector.h"
%include "dCustomVehicleControllerManager.h"
%include "dCustomWheel.h"
%include "dStdafxVehicle.h"
%include "dVehicleChassis.h"
%include "dVehicleDashControl.h"
%include "dVehicleInterface.h"
%include "dVehicleManager.h"
%include "dVehicleNode.h"
%include "dVehicleSingleBody.h"
%include "dVehicleSolver.h"
%include "dVehicleVirtualDifferential.h"
%include "dVehicleVirtualEngine.h"
%include "dVehicleVirtualJoints.h"
%include "dVehicleVirtualTire.h"
%include "dAnimationAcyclicJoint.h"
%include "dAnimationAcyclicSolver.h"
%include "dAnimationCharacterRig.h"
%include "dAnimationCharacterRigManager.h"
%include "dAnimationEffectorBlendNode.h"
%include "dAnimationEffectorBlendNodePose.h"
%include "dAnimationEffectorBlendPose.h"
%include "dAnimationEffectorBlendRoot.h"
%include "dAnimationEffectorBlendTwoWay.h"
%include "dAnimationKinematicLoopJoint.h"
%include "dAnimationRigEffector.h"
%include "dAnimationRigForwardDynamicLimb.h"
%include "dAnimationRigHinge.h"
%include "dAnimationRigJoint.h"
%include "dAnimationRigLimb.h"
%include "dAnimationStdAfx.h"
*/


and, here is the setup script for python setup.py:
Code: Select all
from distutils.core import setup, Extension
import os

#getting the include dirs
includes=[]
swigopts=["-c++"]
for path, subdirs, files in os.walk("include"):
   includes.append(path)
   swigopts.append("-I{0}".format(path))


setup(name="newton", ext_modules=[Extension(name="_newton", sources=["newton.i"], include_dirs=includes, library_dirs=["lib"], libraries=["dAnimation_d", "dContainers_d", "dCustomJoints_d", "dgCore_d", "dgPhysics_d", "dMath_d", "dNewton_d", "dScene_d", "dVehicle_d", "newton_d"], swig_opts=swigopts)])

if anything else should be added or deleted, please let me know.
thanks.
brightening-eyes
 
Posts: 7
Joined: Sun Dec 30, 2018 11:38 pm

Re: newton dynamics for python?

Postby Julio Jerez » Wed Jan 02, 2019 4:35 pm

these "dCompilerKit", "dLanguageBinding" are not part of the engine, they are part of an old project I work form time to time.

also you do not need to add anything from dgPhysics and dgCore,
and from dgNewton only newton.h
That's unless you wnat to use core funtionality directly bypassing newton.h

you can start very eassy and buidl form there, for example if you do something like this:
Code: Select all
%module newton
%{
  #include "newton.h"
  #include "dVector.h"
  #include "dMatrix.h"
  #include "dQuaternion.h"
%}

%include "newton.h"
%include "dVector.h"
%include "dMatrix.h"
%include "dQuaternion.h"

That will give to the bear minimum essentials to start the engine and have rigid bodies with collision.
then if you want joints, you can add them on demand starting from the base, for example if you want hinges, you add these:
Code: Select all
dCustomJoint.h
dCustomHinge.h

and so on as you need funtionality

The reason reason I do it that way is because, I can fix all the differences between C++ and the target language as they show up.
for example ther are operator overload thet probably need soem special swig script
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: newton dynamics for python?

Postby brightening-eyes » Thu Jan 03, 2019 2:02 am

then in dCustomJoints, we Have dGearboxJoint, and it is declared in dVehicle as well!.
for adding vehicle, do i need to add only the VehicleControllerManager? i don't remember it's class name.
brightening-eyes
 
Posts: 7
Joined: Sun Dec 30, 2018 11:38 pm

Re: newton dynamics for python?

Postby Julio Jerez » Thu Jan 03, 2019 6:54 am

Do not try to get a head of yourself,
Fort get the bidica going.
Get the essential minimum and make a few demos to try the functionality,
There is pleant to test first with all the collision shapes type.

The add the basic joints, the liteners. And test those.
The you can start add-on the high level. Libraries like the scene and vehicles.

Start thinking vehicle first and special joints is a top down thinking and is going to frustrate you.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 12 guests