Mobile Robot | Mars Prospecting Robot

01. Demand analysis

The “Mars prospecting robot” aims to develop several autonomous robots and send them to Mars to search for and collect mineral resources on Mars.

The Martian environment is unknown to developers and autonomous robots in advance, but it is conceivable that the surface of Mars will have a variety of terrain conditions, such as rivers, boulders, pits, etc., and the robot will encounter various obstacles during the movement;

In addition, there may be some unknown dynamic factors (such as storms, etc.) on Mars, which will change the state of the environment.

To sum up, the Martian environment is open, dynamic, unknowable, and difficult to control.

In order to simplify the development and demonstration of the case, the area of the robot prospecting (that is, the motion environment of the robot) can be simplified and abstracted into M×M cells, each cell represents a certain Mars area, and Mars minerals are distributed in these cells , and there are obstacles in these cells that hinder the robot’s operation.

Prospecting robots move in these grids and decide their own behaviors autonomously according to the perceived grid environment information.

If there are minerals in the cell, collect the minerals; if it detects that there are minerals in the nearby cells, move to the cell; if there are obstacles in the surrounding cells, avoid these obstacles.

The environment grid has two special cells: one is the mineral accumulation cell, which is used to store the minerals collected by the robot, as shown in the lower left corner in Figure 1; the other is the energy replenishment cell, from which the robot can obtain energy.

Figure 1 Schematic diagram of the environment of the Mars prospecting robot case

The design goal of the “Mars prospecting robot” is to collect Martian minerals and bring them to a predetermined area.

To this end, the robot has the following set of basic capabilities.

  • move. It is capable of moving across the surface of Mars, moving from a cell to its adjacent cells above, below, to the left, and to the right.

  • probing. It is equipped with a variety of sensors and has a certain degree of environmental awareness, including detecting the distribution of minerals and obstacles in a certain range around (such as how many adjacent cells).

  • collection. It can harvest Martian minerals in the cell it is in.

  • uninstall. It is capable of unloading the minerals it collects and places within its body.

  • interact. It can interact and cooperate with other robots to collect minerals more efficiently. For example, if a robot detects a large area of minerals, it can tell other robots about the minerals so that they can come to the area to collect minerals.

In order to fully reflect the actual situation of prospecting robots, we have made the following assumptions about the robots:

①The capacity of each robot to store minerals has a certain limit, that is, there is only a limited space inside the robot to store minerals. Once the minerals collected by the robot exceed its storage capacity, it must unload these minerals to a specific location area so that it can be collected again mineral.

②The energy of each robot has a certain limit. The robot will consume energy during the process of moving, detecting, collecting, and unloading. Therefore, the robot must replenish energy (such as charging) before its energy is exhausted.

③ The perception ability of each robot is limited, it can only perceive the environmental conditions within a certain range around it, such as the cells adjacent to two units.

The following describes how robots collect Martian minerals in the above-mentioned Martian environment through multiple scenarios. These scenarios describe different working modes of robot mining, reflecting the different degrees of difficulty in realizing these autonomous robots.

Scenario 1: Collect minerals independently.

In this scenario, multiple autonomous robots are involved in the collection of Martian minerals. Each robot has the ability to move, detect, collect, and unload. They move randomly on the surface of Mars and detect mineral information based on their location. and obstacles and other environmental information to implement behaviors autonomously.

However, these robots work alone without any interaction and cooperation between them.

Therefore, each robot in this scenario can be abstracted and designed as an autonomous Agent.

Scenario 2: Cooperative mining of minerals.

In this scenario, multiple autonomous robots participate in the collection of Martian minerals. Each robot has the ability to move, detect, collect, and unload. They also interact with each other while completing their respective mineral collection tasks. and collaborate to work more efficiently.

For example, if a robot detects a large area of mineral information, it can tell the information to other robots, or request other robots to mine in the area.

Therefore, the robot in this scenario can be abstracted and designed as a multi-agent system composed of multiple autonomous agents.

The design and implementation of the system should not only consider each autonomous Agent, but also consider the interaction and collaboration among these Agents.

Scenario 3: Multi-role cooperation to collect minerals.

In this scenario, there are multiple robots with different responsibilities and roles participating in the collection of Martian minerals. Each type of robot undertakes a certain task in mineral collection (such as detection and collection). Cooperate to complete the mineral collection task, that is, there are many types of robots in this scene, including:

① Mining robot, collecting minerals and transporting them to designated areas;

② The detection robot is responsible for detecting minerals and notifying the mining robot of the detected mineral information.

Therefore, the robot in this scenario can be abstracted and designed as a multi-agent system composed of multiple autonomous agents.

The design and implementation of the system should not only consider each autonomous Agent, but also consider the interaction and collaboration among these Agents.

Obviously, this scenario is more complex than the previous one, and it involves more types and quantities of Agents, interactions and cooperative relationships, etc.

02. Design and implementation

The following describes how to develop the “Mars prospecting robot” case based on the multi-agent system development framework JADE.

In order to simplify the design and focus on the construction and implementation of the Agent, the environment in the case of the “Mars prospecting robot” is designed as an M×M grid, each grid cell represents a geographic location, and different grid cells have different Terrain information, there may be obstacles that affect the movement of the robot, and Martian minerals are unevenly distributed in the grid cells.

The robot resides in the grid environment, can move in different grids, and senses the environmental information around the grid, such as minerals, obstacles, etc. If it finds that there are minerals in the grid, then it will mine the minerals.

The entire application interface is shown in Figure 2.

The left part of the interface shows the environment of the robot (represented by a grid), which provides a variety of icons and digital information to represent the robots, minerals, obstacles, etc. in the environment and their distribution in the environment.

The robot runs in the grid, so at any time the robot has the position of the cell it is in.

The right part of the interface shows the description of various icon information and the changes in the number of robots, minerals, etc. in the system and environment.

The lower part of the interface provides various dynamic information during the operation of the entire system, such as a robot detecting minerals, a robot moving from one location to another, etc.

Figure 2 The running interface of the multi-agent system for Mars prospecting

When the system is initialized, it will automatically generate the operating environment of the robot, including the distribution of minerals and obstacles.

Users can configure the robot information when the system is running, including the type and number of robots, and set the basic attributes of the robot, such as the observation range of the robot, the initial energy value of the robot, etc., as needed.

In actual development, we have the following basic assumptions: Starting from the initial position, the agent moves randomly and single-step on the map, can automatically avoid obstacles when encountering obstacles, can automatically detect whether there are minerals around it, and can only collect one mineral at a time. Ship it to the designated mineral warehouse.

1. Design and implementation of the environment

We designed an environment class (corresponding to the environment.java file) to represent and handle the environment in the application.

This class encapsulates the following set of properties and behaviors.

  • For the minerals in the environment, define a one-dimensional dynamic array to store the positions of the minerals ArrayListMinePositions, where Coordinate is a class that defines the coordinates of the grid.

  • Obstacles in the environment, define a one-dimensional dynamic array to store the position of obstacles ArrayListObstaclePositions.

  • Robots in the environment, ArrayListrobots, this attribute defines a group of robots in the environment.

  • InitEnv() method, which generates a grid environment and randomly generates minerals and obstacles in the environment.

2 ●Agents and behaviors in the system

According to the application case description, we designed a set of Agents and behaviors as shown in Figure 3 to support the realization of Scenarios 1 to 3.

Figure 3 Schematic diagram of Agent and its behavior in the system

  • BasicRobot is a basic Agent robot, which can walk in the environment and has the behavior of random walking RandomWalkBev.

  • In this case, BasicRobot does not need to generate a specific Agent instance, but is inherited by other Agents.

  • ExploreRobot is an Agent robot specially designed for Scenario 1. It inherits the attributes, methods and behaviors of the “BasicRobot” Agent, and has three behaviors: DetectMineBev for detecting minerals, DigMineBev for collecting minerals, and DumpMineBev for dumping minerals.

  • In other words, the Agent can independently complete the functions of prospecting, mining and depositing.

  • However, ExploreRobot does not have the ability to interact and collaborate with other Agents.

  • In scenario one, the system may generate one or more “ExploreRobot” Agent robots.

  • ExploreCoopRobot is an Agent robot specially designed for Scenario 2. It inherits the attributes, methods and behaviors of the “ExploreRobot” Agent, and also has the interactive cooperation CooperationBev behavior, which can cooperate with other Agent robots to inform the detected mineral information.

  • In scenario two, the system may generate one or more “ExploreCoopRobot” Agent robots.

  • Scenario 3 contains two different types of Agent robots:

  • One is DetectMineRobot, a robot specialized in prospecting, which has two behaviors of detecting minerals DetectMineBev and interactive cooperation CooperationBev, which can realize prospecting and tell other Agent robots the detected mineral information;

  • The other type is DigMineRobot, which has three behaviors: mining DigMineBev, dumping mineral DumpMineBev, and interactive cooperation CooperationBev. It can implement functions such as mining and depositing, process messages sent by other Agents, and tell mining information to other agents in the environment.

3 ●Design and implementation of Agent class

The design and implementation of the Agent class need to pay attention to the following points:

① Inherit the Agent class or its subclasses;

②Initialize the basic properties of Agent in the constructor;

③In the Setup() method, add corresponding behaviors to the Agent through the addBehaviour() statement, so that these behaviors can be executed after the Agent is created.

The following takes the “ExploreRobot” Agent as an example to introduce how to design and implement the Agent.

Any Agent class must inherit JADE’s Agent class or its subclasses. For example, BasicRobot inherits the Agent class, and its code framework is as follows.

import jade.core.Agent;
public class BasicRobot extends Agent{…}

The “ExploreRobot” Agent inherits the “BasicRobot” Agent, and the “BasicRobot” Agent is a subclass of the Agent class. The code framework of this part is shown below.

import jade.core.Agent;
public class ExploreRobot extends BasicRobot{…}

In the constructor part of each Agent, the programmer needs to complete the initialization work for some properties of the Agent.

For example, for each “ExploreRobot” Agent, after it is instantiated, the position of the Agent robot in the environment (that is, the grid) needs to be randomly generated for it, and at the same time, the information about the minerals in the environment obtained by the robot needs to be initialized.

The code framework of this part is described as follows.

import jade.core.Agent;
public class ExploreRobot extends BasicRobot{
Coordinate position;
ArrayList<Coordinate>FoundMine;
…
 public ExploreRobot(){
    ...;
    position=env.CreateRandomPosition();
    FoundMine=new ArrayList<Coordinate>();
 }
…
}

Among them, position is an attribute of type Coordinate, which defines the coordinates of the Agent robot in the grid; FoundMine is a dynamic array of type Coordinate, which defines the location information of the minerals detected by the Agent robot.

In the above statement, CreateRandomPosition() is a method to generate a random environment position, and the FoundMine=new ArrayList() statement generates a dynamic array of type Coordinate.

The design of the Agent class usually requires instantiation of the setup() method.

For this case, we need to add a set of behaviors to this method so that ExploreRobot can execute these behaviors after creation. The code framework is described as follows.

import jade.core.Agent;
public class ExploreRobot extends BasicRobot{
…
public void setup(){
   addBehaviour(new DetectMineBehaviour(this));
   addBehaviour(new DigMineBehaviour(this));
   addBehaviour(new DumpMineBev(this));
}
…
}

Among them, the statement addBehaviour (new DetectMineBehaviour (this)); aims to add a mineral detection behavior, the statement addBehaviour (new DigMineBehaviour (this)); aims to add a mining behavior, the statement addBehaviour (new DumpMineBev (this)); Aim to add an behavior of unloading ore to the ore warehouse.

4. Design and implementation of behavior class

The design and implementation of behavior classes need to pay attention to the following points:

① Analyze the characteristics of the behavior to be implemented, and determine what kind of base class behavior the behavior class should inherit;

② Write specific behavior codes in the publicvoidaction() method.

The following uses the DetectMineBehaviour behavior as an example to introduce how to design and implement the behavior.

First of all, the DetectMineBehaviour behavior is designed to detect whether there are minerals around the Agent. This detection needs to be carried out continuously. Therefore, this behavior belongs to a type of periodic behavior and needs to inherit the CyclicBehaviour class in JADE. Its code framework is shown below.

import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
…
public class Detect MineBev extends CyclicBehaviour{
   …
   public DetectMineBev(BasicRobot robot){
   …
   }
   public void action(){
        …
   }
}

Among them, DetectMineBev() is a constructor, which can complete some initialization work; public void action() defines the behavior body.

Second, the program code for the behavior needs to be defined in the public void action() method.

For the DetectMineBev behavior, its behavior part is mainly to obtain whether there are minerals around its current location, and if so, add the information of these minerals (that is, the coordinates of the minerals) to the FoundMine dynamic array of the Agent robot.

5 ●Design and implementation of interaction between Agents

Scenario 2 and Scenario 3 both involve the interaction and collaboration between Agent robots.

The following takes DetectRobot in Scenario 3 as an example to introduce how to implement FIPA ACL-based interaction and collaboration between Agents.

Once a DetectRobot detects certain minerals, it needs to notify the “DigRobot” Agent robot in the environment of the mineral information it has detected.

The following program code describes how the Agent robot sends the detected mineral information to other Agents in the DetectMineBehaviour behavior.

First, generate an ACL message of “notification” type through the newACLMessage (ACLMessage.INFORM) statement, then use the mineral coordinates as the content of the message, then add other Agents to the receiver list of the message, and finally send the ACL message.

public class DetectMineBehaviour extends CyclicBehaviour {
    …
    //behavior
    public void action(){
        Coordinate target =RandomWalkBev.RandomNextpoint(ui.myGrid);
        int RobotNum = en. getrobotArryList(). size();
         …
        //generate message type
        ACLMessage msg =new ACLMessage(ACLMessage.INFORM);
        //Generate message content
        for(int i=0;i<en.getMinePositions().size();i++ ){
            targetposi.x = en.getMinePositions().get(i).x;
            targetposi.y = en.getMinePositions().get(i).y;
            try {
               msg.setContentObject((Serializable) targetposi);
            } catch(IOException e){
                 //TODO Auto-generated catch block
                 e.printStackTrace();
            }
        }
        //Receiver of generated message
        for(int i=0;i<en.getrobotArryList().size();i ++ ){
            msg.addReceiver(new AID("Dig" + i, AID.ISLOCALNAME));
        }
        thisRobot.send(msg);//Send message
    }
    …
}