Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Blimp Autonomy
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arnhold
Blimp Autonomy
Commits
5db78230
Commit
5db78230
authored
4 years ago
by
Shahrul Kamil bin Hassan
Browse files
Options
Downloads
Patches
Plain Diff
Delete feather_main_i2c.ino
parent
1a3e64f8
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Codes/Main Code/feather_main_i2c.ino
+0
-168
0 additions, 168 deletions
Codes/Main Code/feather_main_i2c.ino
with
0 additions
and
168 deletions
Codes/Main Code/feather_main_i2c.ino
deleted
100644 → 0
+
0
−
168
View file @
1a3e64f8
#include
<Wire.h>
#include
<Adafruit_MotorShield.h>
#include
"ArnholdMesh.h"
#include
<Arduino.h>
#include
<string>
#include
<vector>
#include
"LedPanel.h"
#include
"Camera.h"
openmv
::
rpc_scratch_buffer
<
256
>
scratch_buffer
;
// All RPC objects share this buffer.
openmv
::
rpc_i2c_master
interface
(
0x12
,
100000
);
//to make this more robust, consider making address and rate as constructor argument
const
int
BAUD_RATE
=
115200
;
const
int
MAX_SPEED
=
255
;
const
double
RESOLUTION_W
=
360.0
;
const
double
RESOLUTION_H
=
240.0
;
int
SEEKING_SPEED
=
100
;
int
FIND
=
1
;
//based on the same code from openMV. Determine the color you want to find
int
NOMINAL_PERCENTAGE
=
60
;
//in percent
bool
SEEKING
=
true
;
char
newPTCL
=
'1'
;
// Create the motor shield object with the default I2C address
Adafruit_MotorShield
AFMS
=
Adafruit_MotorShield
();
// Select motor ports
Adafruit_DCMotor
*
motorVertical
=
AFMS
.
getMotor
(
1
);
Adafruit_DCMotor
*
motorLeft
=
AFMS
.
getMotor
(
2
);
Adafruit_DCMotor
*
motorRight
=
AFMS
.
getMotor
(
4
);
//ArnholdMesh thisNode;
Camera
cam
(
&
interface
);
void
setup
()
{
Serial
.
begin
(
BAUD_RATE
);
Wire
.
begin
();
cam
.
begin
();
AFMS
.
begin
();
// create with the default frequency 1.6KHz
interface
.
begin
();
//thisNode.init();
//thisNode.mesh.onReceive(receivedCallback);
}
void
loop
()
{
if
(
Serial
.
available
()){
char
test
=
Serial
.
read
();
Serial
.
println
(
test
);
if
(
test
==
'1'
||
test
==
'2'
||
test
==
'3'
||
test
==
'4'
)
{
newPTCL
=
test
;
}
}
if
(
newPTCL
==
'1'
){
cam
.
exe_face_detection
();
}
else
if
(
newPTCL
==
'2'
){
cam
.
exe_color_detection
(
30
,
100
,
-
68
,
-
13
,
30
,
127
);
}
else
if
(
newPTCL
==
'3'
)
{
cam
.
exe_qrcode_detection
();
}
else
if
(
newPTCL
==
'4'
)
{
cam
.
exe_led_detection
();
}
// if (buff[0] == 0){
// //do nothing
// } else if (buff[0] == 'n'){ //if we didn't receive data or the data says no blob
// //This should set the vertical motor to produce enough trust for it to stay afloat
// //the left and right motor should turn the blimp as it seek for new blob
// if (SEEKING){
// motorVertical->setSpeed(0);
// motorVertical->run(FORWARD);
// // turn on motor
// motorVertical->run(RELEASE);
// motorLeft->setSpeed(SEEKING_SPEED*NOMINAL_PERCENTAGE/100.0);
// motorLeft->run(FORWARD);
// motorRight->setSpeed(SEEKING_SPEED*NOMINAL_PERCENTAGE/100.0);
// motorRight->run(BACKWARD);
// } else {
// motorVertical->setSpeed(0);
// motorVertical->run(FORWARD);
// // turn on motor
// motorVertical->run(RELEASE);
// motorLeft->setSpeed(0);
// motorLeft->run(FORWARD);
// motorRight->setSpeed(0);
// motorRight->run(BACKWARD);
// }
// } else {
// int i = 0;
// while (buff[i] != 'e'){ //while we are not at the end of the data
// String temp = String(buff[i]);
// int code = temp.toInt();
// if (code == FIND){ //if the desired color that we want to track is in the data
// //light up based on the position data specified
// String horizontal = String(buff[i+1]) + String(buff[i+2]) + String(buff[i+3]);
// int x = horizontal.toInt();
// String vertical = String(buff[i+4]) + String(buff[i+5]) + String(buff[i+6]);
// int y = vertical.toInt();
//
// //Planning for motor speed
// int dy = y - RESOLUTION_H/2.0;
// int dx = x - RESOLUTION_W/2.0;
// int y_speed = abs(dy/(RESOLUTION_H/2.0))*MAX_SPEED*NOMINAL_PERCENTAGE/100.0;
// int x_speed = abs(dx/(RESOLUTION_W/2.0))*MAX_SPEED*NOMINAL_PERCENTAGE/100.0;
// int lockon_speed = MAX_SPEED*NOMINAL_PERCENTAGE/200.0;
// //Serial.print("y value: ");
// //Serial.println(y);
// //Serial.print("velocity: ");
// //Serial.println(velocity);
// if (dy < 0) {
// //Serial.println("up");
// motorVertical->setSpeed(y_speed);
// motorVertical->run(BACKWARD);
// } else {
// //Serial.println("down");
// motorVertical->setSpeed(y_speed);
// motorVertical->run(FORWARD);
// }
// if (dx < 0) { //
// motorRight->setSpeed(SEEKING_SPEED);
// motorRight->run(BACKWARD);
// motorLeft->setSpeed(min(255, SEEKING_SPEED + x_speed)); //this need to be higher
// motorLeft->run(BACKWARD);
// } else {
// motorRight->setSpeed(min(255, SEEKING_SPEED + x_speed)); //this need to be higher
// motorRight->run(BACKWARD);
// motorLeft->setSpeed(SEEKING_SPEED);
// motorLeft->run(BACKWARD);
// }
// break; //we only track one blob
// } else { //if the blob is not the desired color, check the next blob
// i = i + 7;
// }
// }
// }
// //End of Demo 3
delay
(
1
);
// Don't loop to quickly.
//thisNode.update();
}
//static void receivedCallback( uint32_t from, String &msg ) {
// //This function is where the translation
// Serial.println(msg);
// if (msg[0] == '0'){
// for (int i = 1; i < 6; i++){
// int code = msg[1] - '0' ;
// if (code == i){
// FIND = code;
// Serial.print("the code is: ");
// Serial.println(FIND);
// }
// }
// } else if (msg[0] == '1'){ //speed change
// String k = msg.substring(1);
// int v = k.toInt();
// if (v < 100){
// NOMINAL_PERCENTAGE = v;
// }
// } else if (msg[0] == '2') {
// if (msg[1] == '0'){
// SEEKING = false;
// } else if (msg[1] == '1') {
// SEEKING = true;
// }
// }
// String sendConfirmation = "R";
// thisNode.sendTo(from, sendConfirmation);
//}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment