# Robots in the job market

Introduction
With the ‘robots in the job market’ project, there were three robots involved; one master-robot, and two slave-robots. The master-robot gives out the location of a job to the slave-robots and the two robots (S1 and S2) would each calculate their cost for executing the job and send their calculated job cost to the master-robot. After receiving the costs of execution for each of the slave-robots, the master-robot would then give the slave-robot with the lower execution cost permission to begin the job. If both slave-robots have the same execution costs, the job would be awarded to the first slave-robot (S1) by default.

Objectives
• To accomplish jobs based on lowest determined “cost of accomplishment”
• To use swarm robotics to achieve the most efficient job assignments.

Implementation
The robot world
The project uses an area with equal floor tiling as separate grids to facilitate the calculation of job costs. Calculating the distance between the slave-robots and the job location using the raw distance would involve using a sensor to track the distance to be measured. Thus, any slacks in the perception of data received from the sensor would affect the accuracy of the job cost calculation, and could consequentially affect which slave-robot gets to be awarded the job. The equal tiling of the floor ensures a more accurate calculation of job costs using the Manhattan (i.e. grid-based) distance between the slave-robot and the job location. The Market based algorithm is used in determining which slave robot gets “hired” by simply selecting the slave-robot which would incur the lowest cost in executing the job.

The three pictures below provide an illustration of the cost calculation and job awarding measures employed in this project.

Figure 1- Shows the positions of the master, two slave-robots and the job location

Figure 2 - Shows ‘Figure 1’ and the job cost for each slave-robot

Figure 3 - Shows ‘Figure 1’ and the “hired” slave-robot

Functions used by the master-robot:
These functions deal with the various actions the master-robot completes to ensure that the coordinates of the job location are received by the slave-robots, and that also the slave-robot with the lowest job cost is given permission to execute the job.

 void generate_job_cordinates() creates random job coordinates to be sent to the slave-robots as the coordinates of the job location void send_job_cordinates() sends out the generated job coordinates to the slave-robots void receive_msg() receives all incoming messages informing the master-robot about the job costs of the slave-robots and sends the slave-robot with the lower job cost (or the default robot, i.e. if job costs are coincidentally equal) permission to execute the job

Functions used by the slave-robot:
These functions deal with the various actions the slave-robot completes to ensure that the cost of executing the job is received by the master-robot, and awaits permission from the master-robot to execute the job.

 void generate_self_cordinates() generates random coordinates to be used as the robots starting location void receive_msg() receives all incoming messages from the master-robot concerning the job coordinates and also permission to execute a job; upon receiving the job coordinates, the robot would calculate the job cost for executing the job and send it to the master-robot void compute_job_cost() uses the job coordinates and its coordinates as parameters for the calculation of the job cost as the Manhattan distance between the robot location and the job location

Functions for driving to the job location:
These functions deal with the controlling of two motors (motors A and C) to aid navigation of a slave-robot to the job location.

 void reset_motors() to reset the value of both motors to 0 void drive_one_tile() to move the robot the distance of one tile i.e. one grid void drive_forward(int times) uses the drive_one_tile() function to drive a specified number of times void turn_right() turns the robot 90 degrees to the left void turn_left() turns the robot 90 degrees to the right void about_turn() turns the robot in the opposite direction void get_to_work(int x_cord_j, int y_cord_j, int x_cord, int y_cord) calculates the various differences between the coordinates of the job location, and  the coordinates of the robot, and then navigates the robot to the job location using a combination of the drive functions described above

Challenges faced
The first approach to calculating the job costs for slave robots was done by calculating the shortest path between any two points which often resulted in a diagonal line between the job location and slave-robot location. The problem with using the actual shortest path between the job location and the slave-robot location was that, the angle of the connecting path would have to be calculated for every path. Considering the fact that neither position nor distance sensors were used in this project, it made such an approach less efficient to adopt. This approach was later replaced with the Manhattan distance calculation which only required the robot world to be divided into equal grids.
Also, the Lego NXT educational kit was able to connect the master-robot to the two slave-robots but however, was only capable of sending data to one slave-robot at a time. Attempts to create a Bluetooth connection with a slave-robot, send messages, close that connection and then open another with the second slave-robot for communication via Bluetooth also failed. For demonstration purposes, the code for communicating with the second slave-robot was commented out and replaced code for communicating with the first robot.
To extend this project to run more than once, all that would be needed would be to wrap the main functions for both the slave-robots and the master-robot in a loop. However, with the slave robots driving to and from different directions, it becomes very easy for a slave-robot to drive out of the expected path. This is because, aside the slave-robot’s X and Y coordinates, the slave-robot also has an orientation which specifies which direction in which it is facing. Thus a robot facing the North of an object would go in a different direction from another robot in the same location but facing another direction even though they were given the same instruction. This challenge was corrected by first ensuring that all slave-robots are placed facing the West of the origin of the robot world (coordinate 0,0) and that also upon arrival at any job location the slave-robots would adjust themselves to face the West again using the turn_left(), turn_right() or about_turn()  functions.

Application in real world
The ‘robots in job market’ employs a concept that can be made relevant across several industries in Ghana and beyond. For instance, in agriculture, it can be used to determine which machines and agricultural equipment should be used to spread resources across a particular location. It would be more efficient and reduce wastage if agricultural equipment and machinery were able to spread manure, irrigate or even sow seeds across a specified land with minimum wastage.
Also, the concept of this project can easily be used by the military for determining which officers would be in the best positions to bring new set of weapons to a battlefield or which officers are closest to a military base and thus should bring fuel for their armoured tanks before the fuel reaches its critical level.
Similarly, hospitals could use the concept of the ‘robots in the job market’ in the dispatching of ambulances such that, the ambulance with the shortest distance between the sick or injured person (people) and the hospital is sent out to pick the person (or people).

Figure 4 - Picture showing the master-robot and the two slave-robots