\b;Exercise
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"
\s;	\l;send\u cbot\send;("param", 20, 100);  // distance 20 meters
\n;
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:
\c;\s;void object::SendToPost(float order, float param)
\s;{
\s;	send("param", param, 100);  // send the parameter
\s;	send("order", order, 100);  // send the order
\s;
\s;	while ( testinfo("order", 100) )  // wait for end of work
\s;	{
\s;		wait(1);
\s;	}
\s;}
\n;
To move forward by 20 meters, you must write in the main program:
\c;\s;	SendToPost(1, 20);  // move(20);
\n;
This is the route the robot must travel through:

\image tremot2b 8 8;
It's up to you to finish the programming.

\t;See also
\l;Programming\u cbot;, \l;types\u cbot\type; and \l;categories\u cbot\category;.
