2.5 Types and modes for compile time guarantee of correct robot actions

Once the T-R procedures extension was up and running our application interest switched to using the T-R extended Qu-Prolog and the Pedro communication server for programming reasoning robotic device control agents. We made use of the Pedro Java and Python APIs to allow such agents to send action commands and receive sensor readings as fully instantiated (ground) Qu-Prolog terms. One of our first experiments was the control of a second generation Lego Mindstorms robot. We used a Qu-Prolog/T-R programmed agent running on an Android mobile phone mounted on the robot.

The camera on the phone, using simple image analysis, provided a stream of percept facts regarding relative direction (left, right or centre), and approximate distance from robot. Objects were identified by their distinct colour and assumed to have a fixed size. The robot control was provided by a non-terminating T-R procedure call. On each update of the agent’s percepts the call was re-evaluated and the action it determined was sent to the robot via the on-board Pedro process. The robot task was to locate, approach and capture a red ball and then deliver the red ball to be close to a blue ball. The action repertoire allowed it to turn on the spot in either direction, move backwards or forwards with an optional turn to left or right, and to raise and lower a rectangular grid at the front of the robot. Lowering the raised grid when the ball was immediately in front of the robot usually captures the ball.

That was a toy control application for which failure to send a fully instantiated action term, or an action term with wrongly typed or wrongly ordered arguments, could be tolerated. For control of industrial robots, always sending fully instantiated correctly constructed and typed action terms is essential.

We therefore decided to type the T-R procedures, the robotic actions, and the relations that were queried directly or indirectly from the T-R rules. The relations defined by rules and fixed facts comprised the knowledge of the robotic agent. The relations defined by percept facts comprised its beliefs. This type system, with system defined types for all primitive relations, and compulsory declaration of types for all program defined relations and T-R procedures, allowed us to guarantee at compile time that the action terms sent to robotic devices would be correctly typed.

To guarantee they would also be fully instantiated, relation type declarations also had to include mode annotations. These indicated which arguments must be given in any call to the relation, which of these arguments could be given as a partially instantiated term or as an unbound variable, and which of these arguments would become fully instantiated if the call succeeded. The moded type declarations enabled a compile time check, using abstract interpretation of each T-R procedure call, that each of its action rules would have a fully instantiated and correctly typed action if it was fired.

We also slightly modified the syntax of the typed declared knowledge relation rules and T-R rules. We changed the :- operator of knowledge relation rules to the word if, and replaced the use of comma for conjunction in these rules, and in T-R rules, by &. This was the state of the software around 2014. The typed and moded knowledge relations rules were our embryonic QuLog, and the typed T-R procedures our embryonic TeleoR.


On This Site