Hi, I’m trying to use the tick system but it’s getting me crazy. I just want show every second a message in the log when simulation is running, to know how the ticks work.
Also I’ve tried to run this example from the robotstudio help, getting the same results: nothing.
Thanks!
'In TheRoborStudioProject
Dim WithEvents sim As Simulation
Sub InitBoxCtrl()
Set sim = ActiveStation.Simulations(1)
'Set the resoluition of the Simulation to 0.5 seconds
'The simulation will generate a Tick event every 0.5 seconds
sim.Resolution = 0.5
’ Create and add a contoller to the simulation
Dim BoxCtrl As BoxController
Set BoxCtrl = ActiveStation.CreateController(“BoxController”)
Call sim.Controllers.Add(BoxCtrl)
BoxCtrl.IOs.Add
'Start the simulation
sim.Start
End Sub
Sub sim_Tick()
'For instance do collision detection
End Sub
'** This is the Controller class called BoxController, used above
Dim myPart As part
Dim speed As Double
Private Sub Controller_AfterTick(ByVal Time As Double)
myPart.Transform.x = Time * speed
myPart.Entities(1).Color = Array(Int(Time * 100) Mod 255, Int(Time * 200) Mod 255, Int(Time * 300) Mod 255)
End Sub
Private Sub Controller_BeforeTick(ByVal Time As Double, MaxTime As Double)
'Do test if possible to have stepsize Time otherwise
'return max step size in MaxTime
End Sub
Private Sub Controller_Create()
'Called when a controller instance is created
Set myPart = ActiveStation.Parts.Add
Call myPart.CreateSolidBox(New Transform, 0.2, 0.3, 0.4)
End Sub
Private Sub Controller_Start()
speed = 0.5
End Sub
Private Sub Controller_Stop()
'Do tidying up
End Sub