Developed a prototype of Artifical Intelligence robot, that can walk a maximum of 5 kilometer on battery charge
For each 1 kg of weight additional charge is used.
Please see the full source code
/**
*
*/
package com.konzerntech.airobo.model;
/**
* @author konzerntech
*
*/
public class AIRobot {
// MILEGE IN KILO METER
private static final float MAX_MILEAGE = 5;
// BATTERY RESERVICE IN PERCENAGE
private static final float BATTERY_RESERVE = 15;
// EXTRA PERCENTAGE REDUCTION PER KILO METER
private static final float EXTRA_REDUCE_PKM_WGT = 2;
// private battery consumption per kilo meter
private static final float BATTERY_CONSUMPTION_PKM = 20;
// WEIGHT IN KILO GRAM
private static final float MAX_WEIGHT = 10;
private float batteryStatus = 0;
private boolean display = false;
private String message = null;
private float weightCarried = 0;
public boolean isDisplay() {
return display;
}
public void setDisplay(boolean display) {
this.display = display;
}
public String getMessage() {
if (null == message) {
message = "";
}
return message;
}
public void setMessage(String message) {
this.message = message;
}
public float getBatteryStatus() {
return batteryStatus;
}
public void setBatteryStatus(float batteryStatus) {
this.batteryStatus = batteryStatus;
}
public float getWeightCarried() {
return weightCarried;
}
public void setWeightCarried(float weightCarried) {
this.weightCarried = weightCarried;
}
public void walk(float kilometer) {
if (checkMaxDistance(kilometer))
batteryConsumption(kilometer, getWeightCarried());
print();
}
public void walkWithWeight(float kilometer, float kilogram) {
/*setWeightCarried(kilogram);
if (checkMaxWeight(kilogram) && checkMaxDistance(kilometer)) {
walk(kilometer);
print();
}*/
carriesWeight(kilogram);
walk(kilometer);
}
public void carriesWeight(float kilogram) {
if (checkMaxWeight(kilogram))
setWeightCarried(kilogram);
}
private boolean checkMaxDistance(float kilometer) {
if (calcMaxMilege(kilometer) < kilometer) {
return false;
}
return true;
}
private float calcMaxMilege(float kilometer) {
float weight = getWeightCarried();
float maxMilege = 100 / (BATTERY_CONSUMPTION_PKM + (EXTRA_REDUCE_PKM_WGT * weight));
return maxMilege;
}
private void batteryConsumption(float kilometer, float weight) {
float charge = getBatteryStatus();
float extraChargeConsumed = weight * EXTRA_REDUCE_PKM_WGT;
float chargeConsumed = kilometer * (BATTERY_CONSUMPTION_PKM + extraChargeConsumed);
setBatteryStatus(charge - chargeConsumed);
}
private boolean checkMaxWeight(float weight) {
if (MAX_WEIGHT < weight) {
setMessage("OverWeight");
print();
removeWeight();
return false;
}
return true;
}
private void print() {
System.out.println(isDisplay() ? "Red" : "");
System.out.println(getMessage());
checkBatteryStatus(0);
}
public void chargeRobot() throws InterruptedException {
// float currentCharge = getBatteryStatus();
// while (currentCharge <= 100) {
// Thread.sleep(500);
// System.out.println("Battery charging...");
// currentCharge += 10;
// }
// System.out.println("Robot Battery full charged");
// batteryStatus = (currentCharge > 100) ? 100 : currentCharge;
batteryStatus = 100;
}
private boolean checkBatteryStatus(float kilometer) {
System.out.println(" Current battery charge : " + getBatteryStatus());
return true;
}
public void removeWeight() {
if(getWeightCarried()==0) {
setMessage("No weight to remove");
print();
}
setWeightCarried(0);
}
public void scan(Barcode b) {
// TODO Auto-generated method stub
System.out.println();
}
}
url : http://konzerntech.com/
For each 1 kg of weight additional charge is used.
Please see the full source code
/**
*
*/
package com.konzerntech.airobo.model;
/**
* @author konzerntech
*
*/
public class AIRobot {
// MILEGE IN KILO METER
private static final float MAX_MILEAGE = 5;
// BATTERY RESERVICE IN PERCENAGE
private static final float BATTERY_RESERVE = 15;
// EXTRA PERCENTAGE REDUCTION PER KILO METER
private static final float EXTRA_REDUCE_PKM_WGT = 2;
// private battery consumption per kilo meter
private static final float BATTERY_CONSUMPTION_PKM = 20;
// WEIGHT IN KILO GRAM
private static final float MAX_WEIGHT = 10;
private float batteryStatus = 0;
private boolean display = false;
private String message = null;
private float weightCarried = 0;
public boolean isDisplay() {
return display;
}
public void setDisplay(boolean display) {
this.display = display;
}
public String getMessage() {
if (null == message) {
message = "";
}
return message;
}
public void setMessage(String message) {
this.message = message;
}
public float getBatteryStatus() {
return batteryStatus;
}
public void setBatteryStatus(float batteryStatus) {
this.batteryStatus = batteryStatus;
}
public float getWeightCarried() {
return weightCarried;
}
public void setWeightCarried(float weightCarried) {
this.weightCarried = weightCarried;
}
public void walk(float kilometer) {
if (checkMaxDistance(kilometer))
batteryConsumption(kilometer, getWeightCarried());
print();
}
public void walkWithWeight(float kilometer, float kilogram) {
/*setWeightCarried(kilogram);
if (checkMaxWeight(kilogram) && checkMaxDistance(kilometer)) {
walk(kilometer);
print();
}*/
carriesWeight(kilogram);
walk(kilometer);
}
public void carriesWeight(float kilogram) {
if (checkMaxWeight(kilogram))
setWeightCarried(kilogram);
}
private boolean checkMaxDistance(float kilometer) {
if (calcMaxMilege(kilometer) < kilometer) {
return false;
}
return true;
}
private float calcMaxMilege(float kilometer) {
float weight = getWeightCarried();
float maxMilege = 100 / (BATTERY_CONSUMPTION_PKM + (EXTRA_REDUCE_PKM_WGT * weight));
return maxMilege;
}
private void batteryConsumption(float kilometer, float weight) {
float charge = getBatteryStatus();
float extraChargeConsumed = weight * EXTRA_REDUCE_PKM_WGT;
float chargeConsumed = kilometer * (BATTERY_CONSUMPTION_PKM + extraChargeConsumed);
setBatteryStatus(charge - chargeConsumed);
}
private boolean checkMaxWeight(float weight) {
if (MAX_WEIGHT < weight) {
setMessage("OverWeight");
print();
removeWeight();
return false;
}
return true;
}
private void print() {
System.out.println(isDisplay() ? "Red" : "");
System.out.println(getMessage());
checkBatteryStatus(0);
}
public void chargeRobot() throws InterruptedException {
// float currentCharge = getBatteryStatus();
// while (currentCharge <= 100) {
// Thread.sleep(500);
// System.out.println("Battery charging...");
// currentCharge += 10;
// }
// System.out.println("Robot Battery full charged");
// batteryStatus = (currentCharge > 100) ? 100 : currentCharge;
batteryStatus = 100;
}
private boolean checkBatteryStatus(float kilometer) {
System.out.println(" Current battery charge : " + getBatteryStatus());
return true;
}
public void removeWeight() {
if(getWeightCarried()==0) {
setMessage("No weight to remove");
print();
}
setWeightCarried(0);
}
public void scan(Barcode b) {
// TODO Auto-generated method stub
System.out.println();
}
}
/**
*
*/
package com.konzerntech.airobo.model;
/**
* @author konzerntech
*
*/
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
AIRobot robo = new AIRobot();
try {
robo.chargeRobot();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// robo.carriesWeight(2f);
// robo.walk(3f);
robo.removeWeight();
robo.removeWeight();
Barcode b = new Barcode();
robo.scan(b);
robo.walkWithWeight(2f, 3f);
}
}
No comments:
Post a Comment
Your feedback may help others !!!