simAddForce equivalent in Remote API

Typically: "How do I... ", "How can I... " questions
Post Reply
ch46
Posts: 3
Joined: 09 Jul 2014, 03:16

simAddForce equivalent in Remote API

Post by ch46 » 28 Aug 2014, 04:54

Hello
I'm trying to apply a linear force directly to a respondable body to simulate a boat sliding through the water.

I read about the function simAddForce in the regular API and was trying to find the same function in the Remote API but couldn't find it.
Do you have any suggestions?

Thanks in advance.

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

Re: simAddForce equivalent in Remote API

Post by coppelia » 28 Aug 2014, 22:55

Hello,

not all regular API functions have been exported to the remote API. You have 2 possibilities, where the second one is by far the easiest and more recomended:
  • implement a new function in the remote API
  • simply send a signal to a child script, that will then handle the task for you. For instance:
remote API client part:

Code: Select all

float forceVectorToApply[3];
simxSetStringSignal(clientId,"vectorToApply",(simxChar*)forceVectorToApply,4*3,simx_opmode_oneshot);
child script part (non-threaded child script):

Code: Select all

data=simGetStringSignal("vectorToApply")
if data then
    vector=simUnpackFloats(data)
    simAddForce(shapeHandle,position,vector)
end
Cheers

JJEHL
Posts: 12
Joined: 02 Apr 2015, 10:35

Re: simAddForce equivalent in Remote API

Post by JJEHL » 17 Apr 2015, 10:20

What is the equivalent in python of the following code ?

Code: Select all

float forceVectorToApply[3];
simxSetStringSignal(clientId,"vectorToApply",(simxChar*)forceVectorToApply,4*3,simx_opmode_oneshot);

Maybe, something like :

Code: Select all

simxSetStringSignal(number clientID,"vectorToApply",simxPackFloats(array floatValues),simx_opmode_oneshot)

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

Re: simAddForce equivalent in Remote API

Post by coppelia » 17 Apr 2015, 14:59

Yes, something like that. You'll have to test it though.

Cheers

Post Reply