A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by JoshKlint » Sun Nov 06, 2022 5:16 am
Thanks, the kinematic joint is working as expected now.
What do the joint SetHighFriction / SetLowFriction methods do?
Can you explain how the joint SetMotorAcceleration method works? How do you enable and disable the joint's motor, and set the force?
-
JoshKlint
-
- Posts: 163
- Joined: Sun Dec 10, 2017 8:03 pm
-
by JoshKlint » Mon Nov 07, 2022 6:01 am
And ndJointHinge::SetOffsetAngle and ndJointSlider::SetOffsetPosit? I want to make sliders and hinges with an optional motor. How do I control these?
-
JoshKlint
-
- Posts: 163
- Joined: Sun Dec 10, 2017 8:03 pm
-
by Julio Jerez » Mon Nov 07, 2022 2:27 pm
the joint are PD controllers.
you set as
void SetAsSpringDamper(ndFloat32 regularizer, ndFloat32 spring, ndFloat32 damper);
them to make a motor, you set void SetOffsetAngle(ndFloat32 angle);
the is far more flexible that the motors in 3.13
because now there joint can have limit and motors at the same time, that was no posible before.
you can get a wide range of effect but selecting parameters apropiatllt.
ndFloat32 regularized, ndFloat32 spring, ndFloat32 damper
-
Julio Jerez
- Moderator
![Moderator Moderator](./images/ranks/newtonstrip.png)
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JoshKlint » Mon Nov 07, 2022 3:03 pm
Sounds good, but I have no idea what the first two parameters of SetAsSpringDamper() actually do.
This makes a springy spring:
SetAsSpringDamper(0, 100, 0)
But this seems to have no effect at all:
SetAsSpringDamper(10000, 0, 0)
This makes the spring slowly oscillate around a different angle:
SetAsSpringDamper(1000, 100, 0)
I found this explanation which is nice, but I still don't know how to use that value or why it is changing the joint spring angle:
viewtopic.php?f=9&t=9655&p=66815&hilit=regularizer#p66817
-
JoshKlint
-
- Posts: 163
- Joined: Sun Dec 10, 2017 8:03 pm
-
by Julio Jerez » Mon Nov 07, 2022 5:33 pm
From the link, r is a fraction, that is scale and added the row diagonal to relax the solver solution. It does not make sense to pass a larger than one value. In fact r ranges from about 0.001 and 0.1
The spring and damper are just like any spring damper system.
The spring is provide the potential energy
The damper act as friction.
By playing with spring and damper, you can make a super critically damp system and that act as a motor with a phase angle. A set of values like:
regularizer 0.001
Spring 1000
Damper 50
Should give you a reasonably start point, and you can tweak from there.
Then, to make a motor, you just animate the target offset thowever you like.
-
Julio Jerez
- Moderator
![Moderator Moderator](./images/ranks/newtonstrip.png)
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JoshKlint » Fri Nov 11, 2022 8:44 am
If I call ndWorld::ReleaseBody in my destructor, the same body shows up later in calls to ndWorld::BodiesInAabb. This shouldn't happen should it?
In general, I get a lot of crashes when quitting my application. One crash occurs in ndFreeListDictionary::Flush. I don't know the correct way to delete an ndWorld, ndBody. ndShape seems to use manual reference counting, which is fine.
-
JoshKlint
-
- Posts: 163
- Joined: Sun Dec 10, 2017 8:03 pm
-
by Julio Jerez » Fri Nov 11, 2022 11:57 am
I do not remember any such ndWorld::ReleaseBody function.
when you add a body, a joint or a model to a world, you are transferring the ownership of that object to the world.
If the world is deleted, it will also delete any objects it owns.
if you want to control your objects, you can add some code, like the one bellow
if (body->GetScene())
{
world->RemoveBody();
}
that will remove the body from that world.
in the demos. I rarely do that because no demo owns the pointer to a body, so I just let the world to delete them.
but if you want to have control of your objects, you can implement a function like
void ndWorld::CleanUp()
in your world destructor, and instead of deletion the bodies, joint or models, just remove them from the world, then, you get an empty world that you are safe to delete or re use.
after that you are safe to delete the bodies, joint and models form your lists.
-
Julio Jerez
- Moderator
![Moderator Moderator](./images/ranks/newtonstrip.png)
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JoshKlint » Fri Nov 11, 2022 2:41 pm
Sorry, I meant ndWorld::RemoveBody
-
JoshKlint
-
- Posts: 163
- Joined: Sun Dec 10, 2017 8:03 pm
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 38 guests