single acting cylinder

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

single acting cylinder

Postby blackbird_dream » Mon Nov 12, 2018 4:28 am

I guess the best way to do that is with a script and setting SetJointForceCalculation to true and retrieving the info in Unity ? Dunno if possible yet.
I tried to modify the source especially NewtonUserJointSetRowMinimumFriction with an additional parameter as input value: -m_max_reverse_force instead of -m_max-force but I obtained weird behaviors but I understand NewtonUserJointSetRowMinimumFriction and NewtonUserJointSetRowMaximumFriction just gives the bound values of the instant force that controls the joint, not what I want indeed.
Last edited by blackbird_dream on Mon Nov 12, 2018 10:25 am, edited 3 times in total.
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby Julio Jerez » Mon Nov 12, 2018 6:55 am

what is a single acting cylinder?
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Mon Nov 12, 2018 7:49 am

It's a linear actuator which acts in compression only or in traction only. Great actuation force in one direction (F>0), low force in the opposite direction (F<0).
for example:
https://instrumentationtools.com/single-acting-vs-double-acting-actuators/
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby Julio Jerez » Mon Nov 12, 2018 11:58 am

setminimum and maximum friction force is how you do it.
it is the definition the force are asymmetric.

I do not remember if the actuator expose that, I thin the are assumed to be bilateral, but that an easy change, try hacking one by set the min or that max to zero and that should do it.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Tue Nov 13, 2018 6:42 am

ok Thks.
What I did:

Newton Dynamics
in dCustomSliderActuator.h:
Code: Select all
        public:
   CUSTOM_JOINTS_API dFloat GetMaxReverseForcePower() const;
        ...
   CUSTOM_JOINTS_API void SetMaxReverseForcePower(dFloat force);
        ...
   protected:
   dFloat m_maxReverseForce;


in dCustomSliderActuator.cpp:
Code: Select all
       dCustomSliderActuator::dCustomSliderActuator (const dMatrix& pinAndPivotFrame, NewtonBody* const child, NewtonBody* const parent)
   :dCustomSlider(pinAndPivotFrame, child, parent)
        ...
   , m_maxReverseForce(D_CUSTOM_LARGE_VALUE)
        ...
       dCustomSliderActuator::dCustomSliderActuator (const dMatrix& pinAndPivotFrame, dFloat speed, dFloat minPosit, dFloat maxPosit, NewtonBody* const child, NewtonBody* const parent)
   :dCustomSlider(pinAndPivotFrame, child, parent)
        ...
   , m_maxReverseForce(D_CUSTOM_LARGE_VALUE)
        ...
        void dCustomSliderActuator::Serialize(NewtonSerializeCallback callback, void* const userData) const
{
        ...
    callback(userData, &m_maxReverseForce, sizeof(dFloat));
}
         void dCustomSliderActuator::Deserialize (NewtonDeserializeCallback callback, void* const userData)
{
        ...
    callback(userData, &m_maxReverseForce, sizeof(dFloat));
}
        ...
dFloat dCustomSliderActuator::GetMaxReverseForcePower() const
{
   return m_maxReverseForce;
}

void dCustomSliderActuator::SetMaxReverseForcePower(dFloat force)
{
   m_maxReverseForce = dAbs(force);
}
        ...
   NewtonUserJointSetRowMinimumFriction(m_joint, -m_maxReverseForce);



Unity
in dNewtonJointSlider.h:
Code: Select all
        class dNewtonJointSliderActuator : public dNewtonJoint
{
        ...
   void SetMaxReverseForce(dFloat force);       
        ...


in dNewtonJointSlider.cpp:
Code: Select all
void dNewtonJointSliderActuator::SetMaxReverseForce(dFloat force)
{
   dCustomSliderActuator* const joint = (dCustomSliderActuator*)m_joint;
   joint->SetMaxReverseForcePower(dAbs(force));
}


in newton_wrap.cs:
Code: Select all
        public void SetMaxReverseForce(float force) {
    NewtonWrapperPINVOKE.dNewtonJointSliderActuator_SetMaxReverseForce(swigCPtr, force);
  }
        ...
         [global::System.Runtime.InteropServices.DllImport("NewtonWrapper", EntryPoint="CSharp_dNewtonJointSliderActuator_SetMaxReverseForce")]
         public static extern void dNewtonJointSliderActuator_SetMaxReverseForce(global::System.Runtime.InteropServices.HandleRef jarg1, float jarg2);


in NewtonSlider.cs:
Code: Select all
    public class NewtonSliderActuator : NewtonJoint
{
    public override void InitJoint()
    {
        ...
        MaxReverseForce = m_maxReverseForce;
        ...
     
    public float MaxReverseForce
    {
        get
        {
            return m_maxReverseForce;
        }
        set
        {
            m_maxReverseForce = value;
            if (m_joint != null)
            {
                dNewtonJointSliderActuator joint = (dNewtonJointSliderActuator)m_joint;
                joint.SetMaxReverseForce(m_maxReverseForce);
            }
        }
    }
        ...
        public float m_maxReverseForce = 10.0f;




It seems alright.

Here the single acting cylinder:
https://youtu.be/dXzFpwBNi04

Here the double acting cylinder:
https://youtu.be/P_yZYhTu3cQ
Last edited by blackbird_dream on Thu Nov 15, 2018 10:05 am, edited 2 times in total.
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby Julio Jerez » Tue Nov 13, 2018 10:28 am

but why you make so complex, for what I can see you want a slider that can push but does not pull.

all you need to do, is when pushing, you the the max force to the force of the actuator, that simulate the hydrolic pumping fluid, the when cut off you apply a much smaller force to emulate the natural friction.
the the cylinder either state in place or go back under its own weight. the fact that is two ways does not matter because when going in one direction the force mos be valid on the direction. setting the other to anything does nothing.
similarly when going back, is the force on the direction that has to be small, an again the one in the other direction is irrelevant.

the force in the other direction is only valid when some other force is actually pulling the cylinder and you want the cylinder to be allowed to slide.
but I do not think that what you want, since the usage of those hydro are for vehicle whet the weight of the load is enough to push back the cylinder by gravity alone.
basically you just need to set the max force to a small value when you want it to retrieve. and that is all.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Tue Nov 13, 2018 11:01 am

I'm not sure to understand but the issue comes when the fork press the ground.
It makes the front wheels lift off the ground and that's not correct.
I'm sorry, can you explain more clearly ?
double action here:
https://youtu.be/UpfUPPqc-i8
single action here (small reverse force):
https://youtu.be/7uS4OIt-CAo
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby blackbird_dream » Tue Nov 13, 2018 11:21 am

Ah ok I think I understand. Is it when you want to lift up you drive the target position upward with a high MaxForce value and when you want to lift down just lower the MaxForce value so that it moves downward by gravity ?
It should be ok, but maybe the velocity is more difficult to control as well as the transient stages (change of the maxforce value) may generate pulses, dunno.
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby Julio Jerez » Tue Nov 13, 2018 11:54 am

ok I saw the second video, it is the second case I explained.
basically it is like a chain that can pull but that can not push.

if you play the sandbox demo, you will see it behaves similar to yours, I thought that was a cool demonstration but now I see it pendanty stupid demonstration.

The good knew is that is very easy to fix.
basically the actuator has to have a way to be single actuator. is a very small modification that changes very little.

I will make it in the sand box today starting with the slider, and then compile the unity plugin.
maybe we can make the interface to take the max and min force, instead of just one for both direction.

do not do anything until I make that change.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby Julio Jerez » Tue Nov 13, 2018 12:24 pm

this is not related to this issue.
the one part still confused me is why to still think you need to manipulate the acceleration of the joint instead of sound the way I do it.
the way I am doing it not incorrect.
the part move with the desired velocity by applying the necessary force.

do you know how at the fundamental level a rod is constraint works, do you.
basically what the engine does is that it capitalize in some aspect of the math formulation in order to get performance. that's the main difference between newton 1.xx and the newer version. in 1.xx it was a naive system, that use a generic Dangzig solver to solve the generic constraint.
but it was capable to do at most 100 or 150 joints.
that was better or equal that most engine at the time that where doing the same thing because I know few trick of linear algebra that most people done. but in the end is was still a cubic time complexity solver.

later I will try to explain the basic eqution the engine solve. it does not violates any law of physics.
it just calculate a reaction force, that is added to the body and move to the next step.

I hope this combine you that setting the target direction is not wrong, because that is not how the body moves.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby Julio Jerez » Tue Nov 13, 2018 5:03 pm

Ok blackbird_dream I believe I have this fixed now, this was not bug is was a feature :mrgreen:
the interface is now this.
Code: Select all
  dFloat GetMaxForce() const;
  dFloat GetMinForce() const;
   void SetMaxForce(dFloat force);
   void SetMinForce(dFloat force);



this provide low level control, so the joint can be made single director bidirectional,
it will not who in the plugin jet unless you want to make the change yourself, I will try tonight.
but if you since you can play the fork lift in the sandbox and see that now doe no lift the vehicle the
this look more realistic to me now. :D

I make the change to the unity tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Wed Nov 14, 2018 2:24 am

I confess It's difficult for me to follow your last msgs.
I agree this is not a bug of course. :D :!:
The changes I made in the source files do what I expected and in the Unity plugin I just added a field named 'max reverse force' to set the pull force limit.
But if you made equivalent changes in the new build that's cool of course.
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby Julio Jerez » Wed Nov 14, 2018 8:33 am

well, your change may do the effect, but I need to have for everything not just for one plugin.
I made the change to the unity plugin.
now you will find two values for the slider actuator. MinForce and MaxForce

they are set to same default value of 10, but you may need to check them to make sure the tha the proper value.
this will simulate the one way slider they way you describe, or at least that's how I interpreted it.

I was going to make teh same for the hinge actuator, but I can't think of a single case where a functionality like that is necessary for a rotator, so I will hold that until some one need it.
I tested in the sandbox and it seems to work fine with the slider only been one way and is much nicer.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: single acting cylinder

Postby blackbird_dream » Wed Nov 14, 2018 11:07 am

Oh I am very proud of myself today. My "fix" seems to work as yours doesn't
1st time in 12 y !!!!
:shock: :D :D
https://youtu.be/2dL0fJBCOK0
should be the unity plugin as the newton modifications look the same except the sign of the parameter sent to Setminimumfriction
User avatar
blackbird_dream
 
Posts: 269
Joined: Wed Jun 07, 2006 3:08 pm
Location: France

Re: single acting cylinder

Postby Julio Jerez » Wed Nov 14, 2018 12:21 pm

they should be identical yes. It seems to work in the sandbox demo, but when I try to launch the test program in unity I can never get it run.
but if it works with your changes then that's fine.

Edit,
did you apply the settings to all vertical sliders?
Did you compared the two changes, I assume they should be very similar.

I ask because if the force in one side is ten and still can lift the whole thing, that's a sign something is wrong. A force of ten is there just to indicate the sign, but that should not even be enough to light the weight of the lightest part.

This is where it goes to the post I made before that to try to get the effect by microcontroling the velocity at each step, instead of simply saying:
I want to reach this target position with this speed, and this is the force that I can afford.
when the target is far away, the joint compute the acceleration to move one step.
It submit that desired acceleration to the solver alone with the force that is allow to apply.
The solver calculates the force to achieve the velocity on that step, and it clamp it to the allowed forces.

When the calculated force is within the limits, the the part moves to that position.
When it does not, them it simply say I can't do that.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests