Hi
how to define global variable where all kilobots robots scripts can see this variable in V-REP?
thanks in advance.
How to define global variable? (Kilobot robot)
-
- Posts: 12
- Joined: 21 Jul 2019, 12:33
Re: How to define global variable? (Kilobot robot)
Hello,
you have several possibilities. Simplest is to define an integer, float or string signal:
Using a string signal you can basically convey or share any type of data, for instance:
Cheers
you have several possibilities. Simplest is to define an integer, float or string signal:
Using a string signal you can basically convey or share any type of data, for instance:
Code: Select all
local myDataStructure={}
myDataStructure.id=42
myDataStructure.data={1,2,"Hello"}
sim.setStringSignal("myStringSignal",sim.packTable(myDataStructure))
-
- Posts: 12
- Joined: 21 Jul 2019, 12:33
Re: How to define global variable? (Kilobot robot)
Excuse me, can you give me an example, please? or where can I write the global variable that allow all kilobots child scripts see it?
Re: How to define global variable? (Kilobot robot)
e.g. if you want to share a floating value, you would write and read that variable with:
Cheers
Code: Select all
-- write:
sim.setFloatSignal("myFloatSignal",value)
-- read:
local value=sim.getFloatSignal("myFloatSignal")