Why did the motor put out the opposite force

Typically: "How do I... ", "How can I... " questions
Post Reply
JuestinHastings
Posts: 10
Joined: 31 Dec 2020, 07:26

Why did the motor put out the opposite force

Post by JuestinHastings »

hi admin
I set the motor to output a positive force of 350 Newtons at the beginning of the simulation, but why the actual output force is opposite ?
the force output code as following:

Code: Select all

function fnTorqOutput(hTargetMotorHandle,dTargetTorq)
    if dTargetTorq<0.0 then 
     vel=-99999
     torq=-dTargetTorq
    else 
    vel=99999
    torq=dTargetTorq
    end
    sim.setJointMaxForce(hTargetMotorHandle,torq)
    sim.setJointTargetVelocity(hTargetMotorHandle,vel)

Code: Select all

function FsmFlight()
    print("fsm:Flight")
    -- take the slider to ZERO position in Flight phase
    local dTargPos3=-0.1
    local targetTorq3=350 --fnSliderTorqueInPosCtrl(dTargPos3)
    print(targetTorq3)
    fnTorqOutput(hMotorHandle[3],targetTorq3)
    -- adjust the attitude of body
    --
end
Image(if the link does not work please click the link https://i.ibb.co/cx2nCqX/Snipaste-2021- ... -48-42.png , this is the graph of the joint force )

JuestinHastings
Posts: 10
Joined: 31 Dec 2020, 07:26

Re: Why did the motor put out the opposite force

Post by JuestinHastings »

my desired force output is like the red line as follows
Image(you can click the link to watch the clearer picture
https://i.ibb.co/sPtrx6D/Snipaste-2021- ... -52-34.png)

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

Re: Why did the motor put out the opposite force

Post by coppelia »

Hello,

you can (and should) only set positive values for the force/torque. If you need a negative force/torque, use a negative maximum velocity for that joint.

Cheers

JuestinHastings
Posts: 10
Joined: 31 Dec 2020, 07:26

Re: Why did the motor put out the opposite force

Post by JuestinHastings »

thanks for your attention.
I have coded just following your advice ,you can check my code in the initial question, the problem still exists.

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

Re: Why did the motor put out the opposite force

Post by coppelia »

Please post a minimalistic scene that allows me to replicate what you mention. That will be easier.

Cheers

Post Reply