only adding force on primatic_joint

Typically: "How do I... ", "How can I... " questions
Post Reply
Zhuang
Posts: 31
Joined: 02 Aug 2017, 14:43

only adding force on primatic_joint

Post by Zhuang »

only adding force on primatic_joint using

force = {u,0,0} --u is a variable
torque = {0,0,0}
sim.addForceAndTorque(CarHandle ,force, torque)

and then,
The object is spinning

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: only adding force on primatic_joint

Post by coppelia »

Sorry, is that a question? If yes, what exactly is the problem?

Cheers

Zhuang
Posts: 31
Joined: 02 Aug 2017, 14:43

Re: only adding force on primatic_joint

Post by Zhuang »

well, it is difficult to describe it. So there is the file(.ttt). the link is https://www.dropbox.com/s/y39f0bgfv3kgm ... m.ttt?dl=0

Cheers

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: only adding force on primatic_joint

Post by coppelia »

Hello,

your motor is not dynamically enabled, it is in passive mode. You can notice that if you look at the scene hierarchy: there is no bouncing ball next to that joint. So set that joint into force/torque mode, disable its motor. And adjust its range to be large enough (e.g. [-2;+2] meters). Then, make sure that the car and the base are not colliding, otherwise you'll introduce friction. You can adjust that by slightly moving the car higher, or by change the respondable mask. Then it won't spin anymore.

And in that situation, instead of adding an external force, you could also simply enable the motor of the prismatic joint, and adjust its force with sim.setJointMaxForce.

Cheers

Zhuang
Posts: 31
Joined: 02 Aug 2017, 14:43

Re: only adding force on primatic_joint

Post by Zhuang »

Hello,
According to your suggestion, I made the following changes:
1) the type of the joint Motor: setting positive model to force/torque mode
2) the motor enabled of the joint Motor: setting disable
3) the car's position: slightly moving the car higher
4) the friction factor: setting it to 0

However I can not control the joint Motor thought

Code: Select all

if u > 0 then --u is the controlling force
   sim.setJointTargetVelocity(motorHandle, -100)
else
   sim.setJointTargetVelocity(motorHandle, 100)
end
sim.setJointMaxForce(motorHandle, math.abs(u))
 
the model's link is :https://www.dropbox.com/s/t35grb8yo31dc ... m.ttt?dl=0

Cheers

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: only adding force on primatic_joint

Post by coppelia »

you need to:
  • increase the range of your prismatic joint. Currently its limits are [-3;0] (i.e. pos. min is -3, pos. range is 3)
  • the prismatic joint motor needs to be enabled of course. Otherwise you can't control it. But keep the control loop of that joint disabled
Cheers

Post Reply