How do I rotate a single object around 1 axis in simulation?

Typically: "How do I... ", "How can I... " questions
geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: How do I rotate a single object around 1 axis in simulat

Post by geerten »

But that is the simulation time step, if I slow down the simulation will that give an unchanged value?

Is that representative for the real time that has passed?

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

Re: How do I rotate a single object around 1 axis in simulat

Post by coppelia »

Try also
Cheers

geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: How do I rotate a single object around 1 axis in simulat

Post by geerten »

Yes, I found all these functions in the API docs. But I would like an explanation for the specific case I'm asking you about..Can I use those function for what I'm trying to achieve? Just pointing me to functions I already found does not really help me...

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

Re: How do I rotate a single object around 1 axis in simulat

Post by coppelia »

Geerten,

this is not a programming course, questions and answers should be specific to V-REP (i.e. I pointed you to the right API functions). Regarding Lua programming language or its constructs, please refer to their website and other online documentation.
Make sure also you read and search the V-REP documentation, that contains most answers.


But here it goes:

Code: Select all

simSetThreadSwitchTiming(200)
simDelegateChildScriptExecution()
handle=simGetObjectAssociatedWithScript(sim_handle_self)
rot=1 -- rad/sec (in real-time)

while (simGetSimulationState()~=sim_simulation_advancing_abouttostop) do
	oldTime=simGetSystemTime()
	simSwitchThread()
	newTime=simGetSystemTime()
	realTimePassed=newTime-oldTime

	m=simGetObjectMatrix(handle,sim_handle_parent )
	mRot=simBuildMatrix({0,0,0},{0,0,rot*realTimePassed})
	newM=simMultiplyMatrices(m,mRot)
	simSetObjectMatrix(handle,sim_handle_parent ,newM)
end
Cheers

geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: How do I rotate a single object around 1 axis in simulat

Post by geerten »

Thanks for the code that is exactly the code I had in mind. But it still does not answer my previously asked questions, I want to know how this code is handled in V-REP. I would like an answer on the following things (from previous posts):
  • About the problem in general:
    As far as I understand it now, it will rotate now for every pass through the child script. If I slow down the simulation, will it rotate faster?
  • About the simulation time functions:
    But that is about the simulation time step, if I slow down the simulation will that give an unchanged value?
    Is that representative for the real time that has passed?

nikolaus
Posts: 18
Joined: 13 Feb 2013, 23:17

Re: How do I rotate a single object around 1 axis in simulat

Post by nikolaus »

If you used simGetSimulationTime, and then rotated based upon that, then it wouldn't matter how fast your simulation was running - you'd be turning based on the simulation's internal time.

However, if you use simGetSystemTime, then if you slow down the simulation your object will rotate faster, as its rotation is based on your computer's clock and not on the simulation's clock.

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

Re: How do I rotate a single object around 1 axis in simulat

Post by coppelia »

Thanks Nikolaus!

That's exactly it.

Cheers

geerten
Posts: 77
Joined: 14 Feb 2013, 13:57

Re: How do I rotate a single object around 1 axis in simulat

Post by geerten »

Thanks Nikolaus, for clarifying this for me.

Post Reply