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

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

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

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

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