Unity plugin progress?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Unity plugin progress?

Postby Sweenie » Sun Feb 12, 2017 12:01 pm

Looks good :)

Unsure if I did something wrong or used wrong angles but couldn't get the limits to work.

The spring damper worked fine though.

Well, option 2 (callback) seems indeed cleaner but that would also add more calls across the Native-Managed boundary.

Option 1 would be better for performance i think.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 12:59 pm

is not enough to set the angles you need to check the bool enable limits as well

Sweenie wrote:Well, option 2 (callback) seems indeed cleaner but that would also add more calls across the Native-Managed boundary.

I was going to asked next, setting callback using delegate people say is quite expensive, so I guess we state with, we state with properties even if it is more tedious to set up.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 1:32 pm

ups I made a mistake,
the parameter are specified in degrees, but the engine use then in radians I was no applying the scale factor.

please try again.
I now completed the full interface for hinges and hinge actuators.

we should be abo to build some basic scenes, and I am sure there will be lot of bug fixes, but maybe we sould try an we where we are.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 1:42 pm

we can probably recreate this now
https://www.youtube.com/watch?v=dP2mDIwFYSg
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 2:05 pm

ok there are few problems.

1- the actuator joint is not working, I do not know why.
2- the we have to do the same trick we did for bodies, to the joint, we need to keep an array of them so that we can destroyed the before unity, because unit delete out of order and the body the try to delete the twice. no sure what is going on there but Is bad.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Sweenie » Sun Feb 12, 2017 2:28 pm

Added a hingeactuator but the body dropped down and next time i ran the scene the editor crashed.
Tracked it down to the wrapperSDK, the wrong parent was set.
Instead of setting the parent to NULL, body0 was set as both child and parent.

The same with the Hinge, but on the the function that takes two bodies.(body0 & body 1)

Now the body doesn't drop down but i cant the actuator working. No matter what values i try the body is perfectly still.

The regular hinge limits works fine now by the way. :)

Added a new scene, Demo_03_HingeActuator
I've added a small script that updates the target angle.
You can see that it's being updated if you run the scene, switch to the scene tab and select the gameobject. The TargetAngle is increasing but the body isn't rotating.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 3:02 pm

Sweenie wrote:Added a hingeactuator but the body dropped down and next time i ran the scene the editor crashed.

yea, we discovered the same thing. That was the cause of both bugs.
I expect there will be few more bugs like this, we are going on a rush here. but all in all is going quite well.

I just check in the fix and I replaced the regular hinge with an actuator that spins 500 degrees and stops. the speed is 50 degrees per second

now we can write a script that simple set the target angle and it will move at to the new target at the same speed. we can even put a load and is the low is lower than the max it will push it.

please check it out.

PS:
The regular hinge limits works fine now by the way.
Added a new scene, Demo_03_HingeActuator


I did no read that, is that checked in?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Sweenie » Sun Feb 12, 2017 3:28 pm

Yes, the added scene is checked in, an hour before you checked in your latest fix.

I'm not sure my script is correct though.
I keep updating the target angle every frame, 1 degree per second.
i want the actuator to just spin around like a motor.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 3:44 pm

Oh yes I found it,
your script is not correct, this the style people are used to with other physics engines, but that is not how real robotic actuators works.
void Update () {

angle += 1.0f * Time.deltaTime;
if (angle >= 360)
angle = angle - 360.0f;

if (na)
{
na.TargetAngle = angle;
}

Robotic actuators do a lot of housework on behave of the controller, the controller is not responsible for integrating the angle, it just tells the actuator where is wants to go and the actuator goes to that position. The controller just measure the position of the effector and decide to stop or change direction when it is required.
I will modify the script so that you can have a sample. give me few minutes.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Sweenie » Sun Feb 12, 2017 3:53 pm

Yep, i just figured it out. I'm an idiot. :oops:

I changed the script so it bounces back and forth.

I suppose it can't rotate forever in one direction, unless i set the max angle to a very large number.
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 4:00 pm

ok I made a change, but some how when is reach the end it stops because the joint goes to sleep.
we need to expose functionality to wake up a body from a controller.
but you can get the idea how it should work.

yes to make a motor without limit, you can make the limits a very large value and it will never stop.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 4:13 pm

ok I made so that it read the limit from the hinge pane.
The local flow should be the other way, the scrip can set the limits.

the part that concern me now is that we read the joint form the start function, what if the joint has not been created yet, it has no happen yet but I can see this happing down the line and cause unpredictable results.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby Sweenie » Sun Feb 12, 2017 4:34 pm

The managed instance of the GameObject and it's components will exist at that point.

As long as all getters, setters and functions just make sure the native joint is created before using it.
Like you done here.

Code: Select all
       if (m_joint != null)
            {
                dNewtonHingeActuator hinge = (dNewtonHingeActuator)m_joint;
                hinge.SetTargetAngle(m_targetAngle, m_minAngle, m_maxAngle);
            }


Calling for example, GetJointAngle from the Start function would only return 0.

Or did you mean something else?

[EDIT]

By the way, i've checked in another scene. I connected 10 boxes with the actuator. It looks so awesome. :mrgreen:
Sweenie
 
Posts: 498
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Unity plugin progress?

Postby Julio Jerez » Sun Feb 12, 2017 5:06 pm

oh man isn't that cool? now you can see the power and versatility of realistic physics without massaging and hacks, let us just say with a minimum amount of that.

Bare in mind that this demos are in fact useless, the real power comes when we try to do mundane practical stuff like placing a cup on a desk, opening a cabinet door, having a hanging lamp.
Little mundane things like that is where some engines tricks like making the mass or inertial 10 time bigger come short. It end up with cabinet doors made of playwood acting stronger than the Donald Trump gate of his imaginary wall of Mexico.

I have to take a break now, by brain is producing brain farts, and when that happens bad thing start to look good.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Unity plugin progress?

Postby JoeJ » Sun Feb 12, 2017 5:18 pm

Sweenie wrote:By the way, i've checked in another scene. I connected 10 boxes with the actuator. It looks so awesome. :mrgreen:


I'm glad the days of manual tests coding are almost over :D
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 43 guests