Remote control a robot using an \l;information exchange post\u object\exchange;, so it will pass over the 6 blue waypoints.
The main actors of this exercise are¦:
1) A \l;wheeled grabber\u object\botgr; robot without an energy cell. This is the master you have to program.
2) An \l;information exchange post\u object\exchange; that receives information from the master and then transmits it to the slave.
3) A \l;practice bot\u object\bottr; which waits for orders from the exchange post. This robot has already been programmed.
\image tremot2a 16 8;
An information exchange post stores "name/value" couples. To control the "slave" robot we use two couples¦:
1) name="order", value=order number
2) nom="param", valuer=parameter for the operation
Order #1 means "move" and order #2 means "turn". The parameter is the distance to move or the turning angle. For example to make the slave move 20 meters write¦:
\c;\s; \l;send\u cbot\send;("order", 1, 100); // order "move"
These two instruction send following 2 pieces of information to the exchange post¦:
\c; order=1
param=20
\n;
The slave robot waits for an order and executes it. Once the order has been executed by the slave, it removes the order from the exchange post. Once an order has been sent, the master must wait for the slave finishing the order before sending the next order. This is done by testing if the order is still inside the exchange post. Just write¦:
\c;\s; while ( \l;testinfo\u cbot\testinfo;("order", 100) ) // wait for end of work
\s; {
\s; wait(1);
\s; }
\n;
As we must give more than one order its most convenient to write a \l;function\u cbot\function; \c;SendToPost\n;, that sends the order and wait for its completion¦: