Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
November 2021 Blimp Competition
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
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
Shahrul Kamil bin Hassan
November 2021 Blimp Competition
Commits
bbd26630
Commit
bbd26630
authored
3 years ago
by
Zhaoliang Zheng
Browse files
Options
Downloads
Patches
Plain Diff
add print info once function
parent
14d1253e
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/ESP32_communication/Two-way/Previous_version/ESP32_slave/ESP32_slave.ino
+79
-11
79 additions, 11 deletions
...tion/Two-way/Previous_version/ESP32_slave/ESP32_slave.ino
with
79 additions
and
11 deletions
Code/ESP32_communication/Two-way/Previous_version/ESP32_slave/ESP32_slave.ino
+
79
−
11
View file @
bbd26630
...
...
@@ -8,7 +8,8 @@ uint8_t broadcastAddress[] = {0xC4, 0xDD, 0x57, 0x9E, 0x8A, 0x98};
String
success
;
// Define variables to store BME280 readings to be sent
String
sentDebugM
=
""
;
int
count
=
0
;
int
print_count
=
0
;
// Define variables to store incoming readings
String
strData
=
""
;
double
valData
=
0.0
;
...
...
@@ -55,12 +56,14 @@ void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
Serial
.
println
(
receivedData
.
ValD
);
strData
=
receivedData
.
StrD
;
valData
=
receivedData
.
ValD
;
count
=
0
;
print_count
=
0
;
}
// =====================================================================================
void
setup
()
{
// Init Serial Monitor
Serial
.
begin
(
1152
00
);
Serial
.
begin
(
96
00
);
// Set device as a Wi-Fi Station
WiFi
.
mode
(
WIFI_STA
);
...
...
@@ -94,20 +97,29 @@ void setup() {
void
loop
()
{
ChangeVariables
();
if
(
lidar_thres
<
300
&&
seeking_speed
<
50
){
receivedData
.
DebugM
=
"catch ball and seeking for goal"
;
send_message
();
receivedData
.
DebugM
=
"ca b se g"
;
send_message_once
();
}
else
if
(
lidar_thres
<
300
&&
seeking_speed
>
50
){
receivedData
.
DebugM
=
"catch ball"
;
send_message
();
send_message_once
();
}
else
if
(
lidar_thres
>
300
&&
seeking_speed
<
50
){
receivedData
.
DebugM
=
"seeking"
;
send_message
();
send_message
_once
();
}
print_allvariables
();
//-------------------------------------------------------------------------------------
}
void
send_message_once
(){
if
(
count
==
0
){
send_message
();
count
+=
1
;
}
}
void
send_message
(){
esp_err_t
result
=
esp_now_send
(
broadcastAddress
,
(
uint8_t
*
)
&
receivedData
,
sizeof
(
receivedData
));
// esp_now_send(RxMACaddress, (uint8_t *) &sentData, sizeof(sentData));
...
...
@@ -147,9 +159,9 @@ void ChangeVariables(){
threshold
[
4
]
=
Bmin
;
threshold
[
5
]
=
Bmax
;
//-------base_speed,seeking_speed,lidar_thres-----------------
base_speed
=
abs
(
get
Int
Val
(
strData
,
"bsp"
,
valData
,
base_speed
));
seeking_speed
=
abs
(
get
Int
Val
(
strData
,
"ssp"
,
valData
,
seeking_speed
));
lidar_thres
=
abs
(
getInt
Val
(
strData
,
"lth"
,
valData
,
lidar_thres
)
)
;
base_speed
=
abs
(
get
Double
Val
(
strData
,
"bsp"
,
valData
,
base_speed
));
seeking_speed
=
abs
(
get
Double
Val
(
strData
,
"ssp"
,
valData
,
seeking_speed
));
lidar_thres
=
getDouble
Val
(
strData
,
"lth"
,
valData
,
lidar_thres
);
}
double
getDoubleVal
(
String
checkData
,
String
Ans
,
double
val
,
double
ori_val
){
...
...
@@ -172,3 +184,59 @@ int getIntVal(String checkData,String Ans,double val,int ori_val){
return
ori_val
;
}
}
void
print_allvariables
(){
if
(
print_count
<=
1
){
Serial
.
print
(
"---------------"
);
Serial
.
print
(
"base speed:"
);
Serial
.
print
(
base_speed
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"seeking speed:"
);
Serial
.
print
(
seeking_speed
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"lidar thres:"
);
Serial
.
println
(
lidar_thres
);
Serial
.
print
(
"threshold:"
);
Serial
.
print
(
threshold
[
0
]);
Serial
.
print
(
"|"
);
Serial
.
print
(
threshold
[
1
]);
Serial
.
print
(
"|"
);
Serial
.
print
(
threshold
[
2
]);
Serial
.
print
(
"|"
);
Serial
.
print
(
threshold
[
3
]);
Serial
.
print
(
"|"
);
Serial
.
print
(
threshold
[
4
]);
Serial
.
print
(
"|"
);
Serial
.
println
(
threshold
[
5
]);
Serial
.
print
(
"gid:"
);
Serial
.
print
(
goal_id
[
0
]);
Serial
.
print
(
goal_id
[
1
]);
Serial
.
println
(
goal_id
[
2
]);
Serial
.
print
(
"Kpx:"
);
Serial
.
print
(
Kpx
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"Kix:"
);
Serial
.
print
(
Kix
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"Kdx:"
);
Serial
.
print
(
Kdx
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"Kdy:"
);
Serial
.
print
(
Kdy
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"Kiy:"
);
Serial
.
print
(
Kiy
);
Serial
.
print
(
"|"
);
Serial
.
print
(
"Kpy:"
);
Serial
.
println
(
Kpy
);
print_count
+=
1
;
}
}
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