Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
car-controlserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenzhongjian
car-controlserver
Commits
cb35e55f
Commit
cb35e55f
authored
Dec 20, 2025
by
957dd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化了大车转向代码
parent
80e4a340
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
13 deletions
+28
-13
main
build/main
+0
-0
car0101_control.c
drivers/devicecontrol/car0101_control.c
+2
-2
tank_common.c
drivers/devicecontrol/tank_common.c
+4
-2
gpio_control.c
drivers/gpio/gpio_control.c
+12
-6
tank_angle.c
drivers/sensors/tank_angle.c
+1
-1
tank_angle.h
drivers/sensors/tank_angle.h
+3
-1
mqtt_infor_handle.c
modules/mqtt/mqtt_infor_handle.c
+6
-1
No files found.
build/main
View file @
cb35e55f
No preview for this file type
drivers/devicecontrol/car0101_control.c
View file @
cb35e55f
...
@@ -55,7 +55,7 @@ void car0101_mode_2_back(unsigned char gval) {
...
@@ -55,7 +55,7 @@ void car0101_mode_2_back(unsigned char gval) {
void
car0101_mode_3_left
(
unsigned
char
gval
)
{
void
car0101_mode_3_left
(
unsigned
char
gval
)
{
int
b
=
1
0
;
int
b
=
1
5
;
if
(
gval
<
45
){
if
(
gval
<
45
){
car_calculate_L_R
(
90
);
car_calculate_L_R
(
90
);
}
else
if
(
gval
<
70
){
}
else
if
(
gval
<
70
){
...
@@ -66,7 +66,7 @@ void car0101_mode_3_left(unsigned char gval) {
...
@@ -66,7 +66,7 @@ void car0101_mode_3_left(unsigned char gval) {
}
}
void
car0101_mode_4_right
(
unsigned
char
gval
)
{
void
car0101_mode_4_right
(
unsigned
char
gval
)
{
int
b
=
2
0
;
int
b
=
1
0
;
if
(
gval
<
45
){
if
(
gval
<
45
){
car_calculate_L_R
(
90
);
car_calculate_L_R
(
90
);
}
else
if
(
gval
<
70
){
}
else
if
(
gval
<
70
){
...
...
drivers/devicecontrol/tank_common.c
View file @
cb35e55f
...
@@ -134,13 +134,15 @@ static void tankshot_detectionback(){
...
@@ -134,13 +134,15 @@ static void tankshot_detectionback(){
if
(
digitalRead
(
12
)
==
LOW
)
{
if
(
digitalRead
(
12
)
==
LOW
)
{
s_back_status
=
true
;
s_back_status
=
true
;
index
=
1
;
index
=
1
;
g_device_delay_back_count
=
0
;
delay_ms
(
100
);
// 延时 100ms,防止抖动
delay_ms
(
100
);
// 延时 100ms,防止抖动
g_device_delay_back_count
=
0
;
softPwmWrite
(
27
,
0
);
softPwmWrite
(
27
,
0
);
set_backshotstatus
(
false
);
set_backshotstatus
(
false
);
my_zlog_info
(
"检测引脚12拉低"
);
my_zlog_info
(
"检测引脚12拉低"
);
}
}
if
(
s_back_status
==
true
&&
index
==
1
)
tank_delay_shot_back
();
if
(
s_back_status
==
true
&&
index
==
1
)
{
tank_delay_shot_back
();
}
tankshot_detectionback_count
++
;
tankshot_detectionback_count
++
;
if
(
tankshot_detectionback_count
>
3000
){
if
(
tankshot_detectionback_count
>
3000
){
softPwmWrite
(
27
,
0
);
softPwmWrite
(
27
,
0
);
...
...
drivers/gpio/gpio_control.c
View file @
cb35e55f
...
@@ -176,23 +176,29 @@ void tank_angle_limit_function(){
...
@@ -176,23 +176,29 @@ void tank_angle_limit_function(){
limit_status
=
angle_limit
();
limit_status
=
angle_limit
();
if
(
limit_status
==
LIMIT_LIFT
)
{
if
(
limit_status
==
LIMIT_LIFT
)
{
device_gpio_control
(
g_device_type
,
5
,
0
);
device_gpio_control
(
g_device_type
,
5
,
0
);
my_zlog_info
(
"lift limit stop"
);
if
(
limit_log_count
>
100
){
my_zlog_info
(
"right limit"
);
limit_log_count
=
0
;
}
}
}
else
if
(
limit_status
==
LIMIT_RIGHT
)
{
else
if
(
limit_status
==
LIMIT_RIGHT
)
{
device_gpio_control
(
g_device_type
,
7
,
0
);
device_gpio_control
(
g_device_type
,
7
,
0
);
my_zlog_info
(
"right limit stop"
);
if
(
limit_log_count
>
100
){
my_zlog_info
(
"lift limit"
);
limit_log_count
=
0
;
}
}
}
if
(
limit_status
==
0
)
{
else
if
(
limit_status
==
0
)
{
limit_log_count
++
;
limit_log_count
++
;
if
(
limit_log_count
>
100
){
if
(
limit_log_count
>
100
){
my_zlog_info
(
"limit stop"
);
my_zlog_info
(
"limit stop"
);
limit_log_count
=
0
;
limit_log_count
=
0
;
}
}
delay_ms
(
5
);
}
}
delay_ms
(
8
);
}
}
}
}
...
...
drivers/sensors/tank_angle.c
View file @
cb35e55f
...
@@ -15,7 +15,7 @@ double tank_angle(){
...
@@ -15,7 +15,7 @@ double tank_angle(){
int
angle_limit
(){
int
angle_limit
(){
if
(
ANGLE_LIMIT_INDEX
==
1
){
if
(
ANGLE_LIMIT_INDEX
==
1
){
int
tank_limit_angele
=
tank_angle
();
int
tank_limit_angele
=
(
int
)
tank_angle
();
if
(
tank_limit_angele
>=
LIFT_LIMIT
&&
tank_limit_angele
<=
MIDDLE_LIMIT
)
return
1
;
if
(
tank_limit_angele
>=
LIFT_LIMIT
&&
tank_limit_angele
<=
MIDDLE_LIMIT
)
return
1
;
else
if
(
tank_limit_angele
>=
MIDDLE_LIMIT
&&
tank_limit_angele
<=
RIGHT_LIMIT
)
return
2
;
else
if
(
tank_limit_angele
>=
MIDDLE_LIMIT
&&
tank_limit_angele
<=
RIGHT_LIMIT
)
return
2
;
return
0
;
return
0
;
...
...
drivers/sensors/tank_angle.h
View file @
cb35e55f
...
@@ -5,12 +5,14 @@
...
@@ -5,12 +5,14 @@
#define MIDDLE_LIMIT 180
#define MIDDLE_LIMIT 180
#define RIGHT_LIMIT 200
#define RIGHT_LIMIT 200
#define ANGLE_LIMIT_INDEX 1 //是否开启角度
旋转
#define ANGLE_LIMIT_INDEX 1 //是否开启角度
限制
double
tank_angle
();
double
tank_angle
();
int
angle_limit
();
int
angle_limit
();
void
settank_angle
(
double
angle
);
float
low_pass_filter_360
(
float
prev_angle
,
float
new_angle
,
float
alpha
);
float
low_pass_filter_360
(
float
prev_angle
,
float
new_angle
,
float
alpha
);
void
set_tank_angle_count
();
//计时
void
set_tank_angle_count
();
//计时
...
...
modules/mqtt/mqtt_infor_handle.c
View file @
cb35e55f
...
@@ -78,9 +78,14 @@ void angle_mqtt_send() {
...
@@ -78,9 +78,14 @@ void angle_mqtt_send() {
char
TOPIC_send_angle
[
26
];
char
TOPIC_send_angle
[
26
];
static
double
prev_angle
=
0
;
static
double
prev_angle
=
0
;
static
double
rounded_angle
;
static
double
rounded_angle
;
rounded_angle
=
low_pass_filter_360
(
prev_angle
,
tank_angle
(),
0
.
8
);
rounded_angle
=
low_pass_filter_360
(
prev_angle
,
tank_angle
(),
0
.
7
);
sprintf
(
TOPIC_send_angle
,
"dev_rtinfo/%s"
,
mqtt_topic_pure_number
());
sprintf
(
TOPIC_send_angle
,
"dev_rtinfo/%s"
,
mqtt_topic_pure_number
());
cJSON_AddStringToObject
(
root
,
"type"
,
"tank_angle"
);
cJSON_AddStringToObject
(
root
,
"type"
,
"tank_angle"
);
if
(
rounded_angle
>
160
&&
rounded_angle
<
180
){
rounded_angle
=
160
;
}
else
if
(
rounded_angle
<
200
&&
rounded_angle
>
180
){
rounded_angle
=
200
;
}
cJSON_AddNumberToObject
(
root
,
"angle"
,
rounded_angle
);
cJSON_AddNumberToObject
(
root
,
"angle"
,
rounded_angle
);
char
*
payload
=
cJSON_PrintUnformatted
(
root
);
char
*
payload
=
cJSON_PrintUnformatted
(
root
);
angle_i
++
;
angle_i
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment