How I can implement multi-robots path planning with evolutionary methods like pso in v-rep

Typically: "How do I... ", "How can I... " questions
Post Reply
ariyayi
Posts: 16
Joined: 05 May 2018, 13:25

How I can implement multi-robots path planning with evolutionary methods like pso in v-rep

Post by ariyayi »

I used distributed approach that each robot make independent decision, coordinate to determine the next position from its current position in the word map(include obstacle) by evolutionary methods like particle swarm optimization. My algorithm gets the current position of robot and call PSO function to find next position in sensing range. For each step it will call PSO until reach predefined goal position.
I wrote my code in Matlab and also I connected it by remote API. I want to know if it is possible to write it on child scripts(Threaded child scripts or Non-Threaded child scripts?) for each robot or what is the best way to implement it in v-rep. thanks

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

Re: How I can implement multi-robots path planning with evolutionary methods like pso in v-rep

Post by coppelia »

Hello,

since you have a very distributed system, you can ideally do this directly with child scripts, since each child script will run independently from the others (i.e. each script has its own isolated state). Normally you would design one robot with its navigation/path planning algorithm inside of a chiuld script attached to it. Then, you can duplicate that robot as often as needed, creating several independent robots.

Cheers

ariyayi
Posts: 16
Joined: 05 May 2018, 13:25

Re: How I can implement multi-robots path planning with evolutionary methods like pso in v-rep

Post by ariyayi »

hi , thanks for your replay

I used Threaded child scripts for khepera Iv robot in simulation , and write PSO function before
function sysCall_threadmain() , my path planning algorithm work correctly, Know I insert another kheprea Iv and two other dummy 'End' and 'begin' in scene. I copy all code in first one child script in second khepera IV robot and change

Code: Select all

robotHandle=sim.getObjectHandle('Khepera_IV')
    rightMotor=sim.getObjectHandle('K4_Right_Motor')
    leftMotor=sim.getObjectHandle('K4_Left_Motor')
    targetHandle=sim.getObjectHandle('Goal')
   startHandle=sim.getObjectHandle('Start')
to

Code: Select all

robotHandle=sim.getObjectHandle('Khepera_IV#0')
    rightMotor=sim.getObjectHandle('K4_Right_Motor#0')
    leftMotor=sim.getObjectHandle('K4_Left_Motor#0')
    targetHandle=sim.getObjectHandle('End')  -- it's line 227
    beginHandle=sim.getObjectHandle('Begin')
when I run it :

Lua runtime error: [string "CHILD SCRIPT Khepera_IV#0"]:227: Object does not exist. (sim.getObjectHandle)
stack traceback:
[C]: in function 'getObjectHandle'
[string "CHILD SCRIPT Khepera_IV#0"]:227: in function <[string "CHILD SCRIPT Khepera_IV#0"]:220>

ariyayi
Posts: 16
Joined: 05 May 2018, 13:25

Re: How I can implement multi-robots path planning with evolutionary methods like pso in v-rep

Post by ariyayi »

I fixed it , In scene hierarchy in simulation I changed 'End' and 'Begin' to 'End#0' and 'Begin#0' and in child script I changed

Threaded child scripts robot 1

Code: Select all

    robotHandle=sim.getObjectHandle('Khepera_IV')
    rightMotor=sim.getObjectHandle('K4_Right_Motor')
    leftMotor=sim.getObjectHandle('K4_Left_Motor')
    targetHandle=sim.getObjectHandle('Goal')
    beginHandle=sim.getObjectHandle('Start')
Threaded child scripts robot 2

Code: Select all

    robotHandle=sim.getObjectHandle('Khepera_IV')
    rightMotor=sim.getObjectHandle('K4_Right_Motor')
    leftMotor=sim.getObjectHandle('K4_Left_Motor')
    targetHandle=sim.getObjectHandle('End#0') 
    beginHandle=sim.getObjectHandle('Begin#0')
It works correctly.

Post Reply