using sim.addForceAndTorque to apply torque to a wheel's y axis

Typically: "How do I... ", "How can I... " questions
Post Reply
shac12
Posts: 9
Joined: 06 Jul 2019, 13:21

using sim.addForceAndTorque to apply torque to a wheel's y axis

Post by shac12 » 10 Nov 2019, 07:48

Hi,

After reading the documentation of the sim.addForceAndTorque fucntion in more detail. I have realised that if a wheel is desired to steer and to drive, the torque value applied to the wheel has to change according to the yaw of the wheel as the sim.addForceAndTorque applies torque in the absolute frame.

Is there any way to avoid this and to just apply torque about the Y axis of the wheel as opposed to the global Y axis ?

Kind Regards,
Sharif

shac12
Posts: 9
Joined: 06 Jul 2019, 13:21

Re: using sim.addForceAndTorque to apply torque to a wheel's y axis

Post by shac12 » 10 Nov 2019, 08:28

Hi,

So ive tried this and it seems to work okay. Not sure if I have my coords correct tho. uH is the handle to the steering mechanism that holds the wheel. I am receiving my torque command from a separate function hence the getstringsignal.

local absAngles = sim.getObjectOrientation(uH, -1)
force = {0, 0, 0}
local E = simGetStringSignal(("motE" .. mot_num))
if E then
local ang = absAngles[3] +math.pi/2
local t = (tonumber(E) * 30.0)
sim.addForceAndTorque(wheelH, force, {math.cos(ang)*t, math.sin(ang)*t, 0})
end

Post Reply