conveyor belt control - Matlab

Typically: "How do I... ", "How can I... " questions
Post Reply
Pinkazous
Posts: 2
Joined: 12 Nov 2015, 20:01

conveyor belt control - Matlab

Post by Pinkazous » 22 Mar 2016, 13:37

Hi everyone!

It's the first time I'm working with this brilliant simulator. I ran successfully the test example of Remote Api for V-REP with Matlab, and I’m working with delta robot, camera and conveyor belt, camera and delta robot was sucsessfully controlled but I can´t control the conveyor belt.

My goal is to:
1 - identify all objects position and dimensions with artifitial vision (I get image from V-rep and process in matlab)
2- move the conveyor only from point a to point b (in point a i take the picture)
3 -in point b matlab send position from detected object to delta robot
4- Delta robot takes each object and put it on a table. depends color, form or size

delta robot moves ok, take the picture ok, but i can´t take control to conveyor belt, how can i do this?

Thanks for your support and cooperation

Best regards to you all!

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

Re: conveyor belt control - Matlab

Post by coppelia » 22 Mar 2016, 16:27

Hello,

in order to make your conveyor belt move, have a look at the child script attached to it. For instance in Models/equipment/conveyors/conveyor belt (efficient).ttm, you have following code:

Code: Select all

if (sim_call_type==sim_childscriptcall_initialization) then 
    pathHandle=simGetObjectHandle("ConveyorBeltPath")
    forwarder=simGetObjectHandle('ConveyorBelt_forwarder')
    simSetPathTargetNominalVelocity(pathHandle,0) -- for backward compatibility
end 

if (sim_call_type==sim_childscriptcall_actuation) then 
    local beltVelocity=simGetScriptSimulationParameter(sim_handle_self,"conveyorBeltVelocity")
    local dt=simGetSimulationTimeStep()
    local pos=simGetPathPosition(pathHandle)
    pos=pos+beltVelocity*dt
    simSetPathPosition(pathHandle,pos) -- update the path's intrinsic position
    
    
    -- 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) :
    
    local relativeLinearVelocity={beltVelocity,0,0}
    -- Reset the dynamic rectangle from the simulation (it will be removed and added again)
    simResetDynamicObject(forwarder)
    -- Compute the absolute velocity vector:
    local m=simGetObjectMatrix(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=simMultiplyVector(m,relativeLinearVelocity)
    -- Now set the initial velocity of the dynamic rectangle:
    simSetObjectFloatParameter(forwarder,sim_shapefloatparam_init_velocity_x,absoluteLinearVelocity[1])
    simSetObjectFloatParameter(forwarder,sim_shapefloatparam_init_velocity_y,absoluteLinearVelocity[2])
    simSetObjectFloatParameter(forwarder,sim_shapefloatparam_init_velocity_z,absoluteLinearVelocity[3])
end 
In that code, the conveyor belt velocity is taken from the attached script simulation parameter conveyorBeltVelocity. So instead, you could take it from a float signal. Instead of:

Code: Select all

    local beltVelocity=simGetScriptSimulationParameter(sim_handle_self,"conveyorBeltVelocity")
do

Code: Select all

    local beltVelocity=simGetFloatSignal("conveyorBeltVelocity")
Then, on your remote API client side, you can change that velocity with simxSetFloatSignal('conveyorBeltVelocity', theVelocity)

You can also send data to V-REP in various other ways, e.g. with simxCallScriptFunction

If you need to move to a specific position, then you could instead send the desired position to the conveyor belt, which will run as long as the position has not yet been reached.

Cheers

Pinkazous
Posts: 2
Joined: 12 Nov 2015, 20:01

Re: conveyor belt control - Matlab

Post by Pinkazous » 22 Mar 2016, 16:51

A lot of Thanks for your reply.

I will try and then I will post the results.

Best Regards

BartaG
Posts: 1
Joined: 17 Dec 2018, 12:21

Re: conveyor belt control - Matlab

Post by BartaG » 18 Dec 2018, 10:58

coppelia wrote:
22 Mar 2016, 16:27

If you need to move to a specific position, then you could instead send the desired position to the conveyor belt, which will run as long as the position has not yet been reached.
How can i set the desired position for the conveyor belt
How to get? How to set the target position?
i want to achieve that it behave as a servo motor joint so it should have acceleration and deceleration

Post Reply