We used electrical engineering and software engineering.
Designing a virtual Robot that can navigate a course autonomously using a touch sensor and light sensor, as well as a gyroscope to make accurate turns. This simulates a response to a natural disaster.
The robot can run the course autonomously; However, it does so using lengthy codes and motor time, meaning it is inconsistent and inefficient. In addition, the program also may not be adequate for all courses at the time, since it lacks the proper sensors to see its surroundings.
The robot can now navigate the course with the aid of many sensors: gyroscope, touch sensor, light sensor. This allows the robot to navigate courses that are dissimilar in structure, and turn with more precision using the gyroscope compared to the motor timing method before. Furthermore, custom commands are created to optimize the code, making it easier to read and understand, as well as saving space.
The final version of the code adjusted the turning angles to improve preciseness, and edited commands to allow the robot to take a more efficient route. A stop command was also added to stop the robot after the completion of the course.
#pragma config(Sensor, in4, centerLineFollower, sensorLineFollower)
#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, in3, gyroSensor, sensorVirtualCompass)
#pragma config(Sensor, dgtl11, touchSensor, sensorTouch)
#pragma config(Sensor, dgtl8, sonarSensor, sensorSONAR_cm)
#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorServoContinuousRotation, openLoop)
// This absolute number function is required because the built
// in abs function becomes a float and automatically typecasts
// to the higher possible int when cast to an int
int abso(int num){
if (num < 0){
return num * -1;
}
return num;
}
// sync up both the right and left motors to be running
// at the same speed, this used for going straight
void motorSync(int speed){
motor[rightMotor] = speed;
motor[leftMotor] = speed;
}
// This returns the current value of the gyroscope normalized
// to be within 360 degrees and return a positive angle
// regardless of the negative value
int getGyro(){
int deg = SensorValue[gyroSensor] % 3600;
if (deg < 0){
return 3600 + deg;
}
return deg;
}
// This turns the the degree
void turnToDegree(int degs){
// The gyroscope handles degrees in form of tenths of a degree
// for that reason the desired degree is multiplied to match
degs *= 10;
// invert the motor speed values if negative
int motorMult = 1;
// actually check if degree is negative
int calced = abso(getGyro() - degs);
if ( calced > 1800){
motorMult *= -1;
}
if (getGyro() > degs){
motorMult *= -1;
}
// set motor speeds
motor[rightMotor] = -15 * motorMult;
motor[leftMotor] = 15 * motorMult;
// Just keep turning motors until angle is met
// We add 0.2 degrees of leeway
while(abso(getGyro() - (degs)) > 2){}
// Ok now return from subroutine
}
// Move forward until object or line is detected
void moveForward(){
motorSync(120);
while(SensorValue[centerLineFollower] < 1500 && SensorValue[touchSensor] == 0){}
motorSync(-70);
sleep(500);
}
// Move forward just until object
void moveFinish(){
motorSync(120);
while(SensorValue[touchSensor] == 0){}
motorSync(-70);
sleep(500);
}
task main()
{
SensorValue[gyroSensor] = 0;
wait1Msec(2000);
// Run predefined movement functions to escape
int turns[] = {0, 270, 180, 270, 0, 90, 0, 270};
// Lets get the length of the move count
int turnCount = (int) sizeof(turns)/ sizeof(int);
// Lets turn to each angle then go forward until we hit something
for (int i = 0; i < turnCount; i++){
turnToDegree(turns[i]);
if (i == turnCount-1){
moveFinish();
} else {
moveForward();
}
}
//Its over now so turn off the motors
motor[rightMotor] = 0;
motor[leftMotor] = 0;
}
One of the first main challenges during testing was getting turning to work properly. We wanted sub degree accuracy with our turning and doing time based turning simply proved to not be accurate. For this reason we research the gyroscope sense, and mocked up this psuedocode graph as a way to show how the turning function should function.
The robot could solve the course, but required pre-programmed lengths of moving forward, and the turning was done by motor time meaning it was inconsistent
The robot now had wall and line detection where in it would check to see if it has hit a wall or line and would stop and backup. This was done using the touch sensor and light sensor.
The robot now turns to the correct degree to continue within 0.1 degrees of accuracy using the Gyroscope
[1] P. H. Diamandis, P. Diamandis, and Fortune Magazine, “AI and Robotics Are Transforming Disaster Relief,” Singularity Hub, 22-Nov-2019. [Online]. Available: https://singularityhub.com/2019/04/12/ai-and-robotics-are-transforming-disaster-relief/. [Accessed: 17-Jun-2020].
[2] C. Boyette, “Robots and drones: How disaster tech saves lives,” CNN, 05-Oct-2015. [Online]. Available: https://www.cnn.com/2015/08/24/us/robot-disaster-technology/index.html. [Accessed: 17-Jun-2020].
[3] T. Hornyak, “Rescue robots deployed in Japan earthquake ops,” CNET, 14-Mar-2011. [Online]. Available: https://www.cnet.com/news/rescue-robots-deployed-in-japan-earthquake-ops/. [Accessed: 17-Jun-2020].
[4] A. Nicodemo, “Researchers design robots to assist with disaster relief,” Phys.org, 21-Sep-2017. [Online]. Available: https://phys.org/news/2017-09-robots-disaster-relief.html. [Accessed: 17-Jun-2020].
[5] “For Fukushima's nuclear disaster, robots offer a sliver of ...” [Online]. Available: https://www.cnet.com/features/for-fukushimas-nuclear-disaster-robots-offer-a-sliver-of-hope/. [Accessed: 17-Jun-2020].
[6] S. Gossett, “12 Examples of Rescue Robots,” Built In. [Online]. Available: https://builtin.com/robotics/rescue-robots. [Accessed: 17-Jun-2020].
[7] “The Centauro: A new disaster response robot to assist ...” [Online]. Available: https://phys.org/news/2018-07-centauro-disaster-response-robot-workers.html. [Accessed: 17-Jun-2020].
[8] “Humanoid robot supports emergency response teams - Phys.org.” [Online]. Available: https://phys.org/news/2018-02-humanoid-robot-emergency-response-teams.html. [Accessed: 17-Jun-2020].
[9] E. Gardner, “Bomb disposal robots: exploring new innovations in VR and power supply,” Army Technology, 20-Jan-2020. [Online]. Available: https://www.army-technology.com/features/bomb-disposal-robots-the-new-frontier/. [Accessed: 17-Jun-2020].