Cuboid does not move along with the conveyor belt

Typically: "How do I... ", "How can I... " questions
Post Reply
coder212
Posts: 7
Joined: 10 Sep 2021, 13:29

Cuboid does not move along with the conveyor belt

Post by coder212 »

Conveyor belts in version 4.1 has this comment under the sysCall_actuation() function.

--Here we "fake" the transportation pads with a single static rectangle that we dynamically reset
-- at each simulation pass (while not forgetting to set its initial velocity vector)

I am trying to send cuboids along a conveyor. When I commented on the whole code below these two comments, the conveyor belt still keeps working but cuboids do not move on the belt. Why does this happen?

The part I commented out :

Code: Select all

    local relativeLinearVelocity={beltVelocity,0,0}
    -- Reset the dynamic rectangle from the simulation (it will be removed and added again)
    sim.resetDynamicObject(forwarder)
    -- Compute the absolute velocity vector:
    local m=sim.getObjectMatrix(forwarder,-1)
    m[4]=0 -- Make sure the translation component is discarded
    m[8]=0 -- Make sure the translation component is discarded
    m[12]=0 -- Make sure the translation component is discarded
    local absoluteLinearVelocity=sim.multiplyVector(m,relativeLinearVelocity)
    -- Now set the initial velocity of the dynamic rectangle:
    sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_x,absoluteLinearVelocity[1])
    sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_y,absoluteLinearVelocity[2])
    sim.setObjectFloatParameter(forwarder,sim.shapefloatparam_init_velocity_z,absoluteLinearVelocity[3])

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

Re: Cuboid does not move along with the conveyor belt

Post by coppelia »

Hello,

well, you just commented the part out that is in charge if moving stuff lying on top of the conveyor belt. So no wonder that nothing moves. What the code does is similar to moving the entire conveyor a bit towards the movement, then removing the conveyor from the simulation, then adding it again in the initial position. Then repeating in each simulation step.

Cheers

coder212
Posts: 7
Joined: 10 Sep 2021, 13:29

Re: Cuboid does not move along with the conveyor belt

Post by coder212 »

coppelia wrote: 13 Sep 2021, 07:10 Hello,

well, you just commented the part out that is in charge if moving stuff lying on top of the conveyor belt. So no wonder that nothing moves. What the code does is similar to moving the entire conveyor a bit towards the movement, then removing the conveyor from the simulation, then adding it again in the initial position. Then repeating in each simulation step.

Cheers
Thank you

Post Reply