Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
DTR Spring 2022
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
Shahrul Kamil bin Hassan
DTR Spring 2022
Commits
4f0f3948
Commit
4f0f3948
authored
3 years ago
by
Shahrul Kamil bin Hassan
Browse files
Options
Downloads
Plain Diff
Merge branch 'kamil' into main
parents
7457ed78
06657816
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Desktop/main_base/main_base/main_base.ino
+14
-3
14 additions, 3 deletions
Desktop/main_base/main_base/main_base.ino
Main Code/main/main.ino
+14
-11
14 additions, 11 deletions
Main Code/main/main.ino
Main Code/main/networking.ino
+3
-0
3 additions, 0 deletions
Main Code/main/networking.ino
with
31 additions
and
14 deletions
Desktop/main_base/main_base/main_base.ino
+
14
−
3
View file @
4f0f3948
...
...
@@ -21,6 +21,7 @@ typedef struct struct_message {
int
left_output
;
int
right_output
;
int
vertical_output
;
int
catcher_output
;
bool
manual
;
}
struct_message
;
...
...
@@ -84,6 +85,14 @@ void loop() {
manual_mode
=
false
;
}
if
(
PS4
.
R2
()){
message
.
catcher_output
=
1700
;
}
else
if
(
PS4
.
L2
()){
message
.
catcher_output
=
1100
;
}
else
{
message
.
catcher_output
=
1350
;
}
if
(
debug_mode_controller
){
Serial
.
print
(
"LEFT MOTOR: "
);
Serial
.
println
(
LeftMotorOutput
);
...
...
@@ -92,6 +101,8 @@ void loop() {
Serial
.
printf
(
"Left Stick x at %d
\n
"
,
PS4
.
LStickX
());
Serial
.
printf
(
"Left Stick y at %d
\n
"
,
PS4
.
LStickY
());
Serial
.
printf
(
"Right Stick y at %d
\n
"
,
PS4
.
RStickY
());
Serial
.
printf
(
"R2 at %d
\n
"
,
PS4
.
R2
());
Serial
.
printf
(
"L2 at %d
\n
"
,
PS4
.
L2
());
Serial
.
print
(
"MANUAL MODE: "
);
if
(
manual_mode
){
Serial
.
println
(
"ON"
);
...
...
@@ -100,7 +111,7 @@ void loop() {
}
}
if
(
PS4
.
L1
()
||
manual_mode
){
if
(
PS4
.
L1
()
||
manual_mode
||
PS4
.
R2
()
||
PS4
.
L2
()
){
message
.
left_output
=
int
(
LeftMotorOutput
);
message
.
right_output
=
int
(
RightMotorOutput
);
message
.
vertical_output
=
int
(
VerticalMotorOutput
);
...
...
@@ -111,11 +122,11 @@ void loop() {
message
.
right_output
=
0
;
message
.
vertical_output
=
0
;
message
.
manual
=
manual_mode
;
message
.
catcher_output
=
1350
;
esp_err_t
outcome
=
esp_now_send
(
broadcastAddress
,
(
uint8_t
*
)
&
message
,
sizeof
(
message
));
}
// if (outcome == ESP_OK) {
// Serial.println("Mesage sent successfully!");
// }
...
...
This diff is collapsed.
Click to expand it.
Main Code/main/main.ino
+
14
−
11
View file @
4f0f3948
...
...
@@ -31,6 +31,7 @@ static const uint8_t l_motor = 7;
static
const
uint8_t
r_motor
=
6
;
static
const
uint8_t
vertical_motor_1
=
5
;
static
const
uint8_t
vertical_motor_2
=
4
;
static
const
uint8_t
catcher_servo
=
3
;
//GLOBAL VARIABLES
...
...
@@ -86,9 +87,11 @@ typedef struct struct_message {
int
left_output
;
int
right_output
;
int
vertical_output
;
int
catcher_output
;
bool
manual
;
}
struct_message
;
void
data_receive
(
const
uint8_t
*
mac
,
const
uint8_t
*
incomingData
,
int
len
);
struct_message
message
;
void
setup
()
{
...
...
@@ -131,22 +134,22 @@ void setup() {
pwm
.
begin
();
pwm
.
setOscillatorFrequency
(
OSCI_FREQ
);
pwm
.
setPWMFreq
(
BRUSHLESS_FREQ
);
// Analog servos run at ~50 Hz updates
delay
(
1000
);
pwm
.
writeMicroseconds
(
l_motor
,
2000
);
pwm
.
writeMicroseconds
(
r_motor
,
2000
);
pwm
.
writeMicroseconds
(
vertical_motor_1
,
2000
);
pwm
.
writeMicroseconds
(
vertical_motor_2
,
2000
);
delay
(
2000
);
//
delay(1000);
//
pwm.writeMicroseconds(l_motor, 2000);
//
pwm.writeMicroseconds(r_motor, 2000);
//
pwm.writeMicroseconds(vertical_motor_1, 2000);
//
pwm.writeMicroseconds(vertical_motor_2, 2000);
//
delay(2000);
pwm
.
writeMicroseconds
(
l_motor
,
1500
);
pwm
.
writeMicroseconds
(
r_motor
,
1500
);
pwm
.
writeMicroseconds
(
vertical_motor_1
,
1500
);
pwm
.
writeMicroseconds
(
vertical_motor_2
,
1500
);
delay
(
2000
);
pwm
.
writeMicroseconds
(
l_motor
,
1600
);
pwm
.
writeMicroseconds
(
r_motor
,
1600
);
pwm
.
writeMicroseconds
(
vertical_motor_1
,
1600
);
pwm
.
writeMicroseconds
(
vertical_motor_2
,
1600
);
delay
(
2000
);
//
pwm.writeMicroseconds(l_motor, 1600);
//
pwm.writeMicroseconds(r_motor, 1600);
//
pwm.writeMicroseconds(vertical_motor_1, 1600);
//
pwm.writeMicroseconds(vertical_motor_2, 1600);
//
delay(2000);
}
void
loop
()
{
...
...
This diff is collapsed.
Click to expand it.
Main Code/main/networking.ino
+
3
−
0
View file @
4f0f3948
...
...
@@ -4,5 +4,8 @@ void data_receive(const uint8_t * mac, const uint8_t *incomingData, int len) {
memcpy
(
&
message
,
incomingData
,
sizeof
(
message
));
moveBlimp
(
message
.
left_output
,
message
.
right_output
,
message
.
vertical_output
);
manual_mode
=
message
.
manual
;
pwm
.
writeMicroseconds
(
catcher_servo
,
message
.
catcher_output
);
Serial
.
print
(
"CATCHER: "
);
Serial
.
println
(
message
.
catcher_output
);
command_time
=
millis
();
}
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