Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
671ad86e
Commit
671ad86e
authored
8 years ago
by
dawehr
Browse files
Options
Downloads
Patches
Plain Diff
WIP - Weird control structure
parent
e89ba7ef
No related branches found
No related tags found
1 merge request
!8
Controller network
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/sw/modular_quad_pid/src/control_algorithm.c
+18
-8
18 additions, 8 deletions
quad/sw/modular_quad_pid/src/control_algorithm.c
with
18 additions
and
8 deletions
quad/sw/modular_quad_pid/src/control_algorithm.c
+
18
−
8
View file @
671ad86e
...
...
@@ -23,15 +23,20 @@ void connect_autonomous(parameter_t* ps) {
graph_set_source
(
graph
,
ps
->
pitch_pid
,
PID_SETPOINT
,
ps
->
clamp_pitch
,
PID_CORRECTION
);
graph_set_source
(
graph
,
ps
->
roll_pid
,
PID_SETPOINT
,
ps
->
clamp_roll
,
PID_CORRECTION
);
graph_set_source
(
graph
,
ps
->
mixer
,
MIXER_THROTTLE
,
ps
->
throttle_trim_add
,
ADD_SUM
);
graph_set_source
(
graph
,
ps
->
yaw_r_pid
,
PID_SETPOINT
,
ps
->
yaw_pid
,
PID_CORRECTION
);
//
graph_set_source(graph, ps->yaw_r_pid, PID_SETPOINT, ps->yaw_pid, PID_CORRECTION);
}
void
connect_manual
(
parameter_t
*
ps
)
{
struct
computation_graph
*
graph
=
ps
->
graph
;
/*
graph_set_source(graph, ps->pitch_pid, PID_SETPOINT, ps->rc_pitch, CONST_VAL);
graph_set_source(graph, ps->roll_pid, PID_SETPOINT, ps->rc_roll, CONST_VAL);
graph_set_source(graph, ps->mixer, MIXER_THROTTLE, ps->rc_throttle, CONST_VAL);
graph_set_source(graph, ps->yaw_r_pid, PID_SETPOINT, ps->rc_yaw, CONST_VAL);
*/
connect_autonomous
(
ps
);
graph_set_source
(
graph
,
ps
->
yaw_r_pid
,
PID_SETPOINT
,
ps
->
rc_yaw
,
CONST_VAL
);
graph_set_source
(
graph
,
ps
->
mixer
,
MIXER_THROTTLE
,
ps
->
rc_throttle
,
CONST_VAL
);
}
int
control_algorithm_init
(
parameter_t
*
ps
)
...
...
@@ -216,8 +221,12 @@ int control_algorithm_init(parameter_t * ps)
// reset flight_mode to MANUAL right away if the flap switch is in manual position
// to engage AUTO mode the code waits for a new packet after the flap is switched to auto
// before actually engaging AUTO mode
if
(
cur_fm_switch
==
MANUAL_FLIGHT_MODE
)
if
(
cur_fm_switch
==
MANUAL_FLIGHT_MODE
)
{
if
(
user_defined_struct
->
flight_mode
==
MANUAL_FLIGHT_MODE
)
{
connect_manual
(
parameter_struct
);
}
user_defined_struct
->
flight_mode
=
MANUAL_FLIGHT_MODE
;
}
// flap switch was just toggled to auto flight mode
if
((
last_fm_switch
!=
cur_fm_switch
)
&&
(
cur_fm_switch
==
AUTO_FLIGHT_MODE
))
...
...
@@ -251,6 +260,7 @@ int control_algorithm_init(parameter_t * ps)
// finally engage the AUTO_FLIGHT_MODE
// this ensures that we've gotten a new update packet right after the switch was set to auto mode
user_defined_struct
->
flight_mode
=
AUTO_FLIGHT_MODE
;
connect_autonomous
(
parameter_struct
);
}
//PIDS///////////////////////////////////////////////////////////////////////
...
...
@@ -287,9 +297,9 @@ int control_algorithm_init(parameter_t * ps)
//memcpy(raw_actuator_struct->controller_corrected_motor_commands, user_input_struct->rc_commands, sizeof(int) * 6);
// don't use the PID corrections if the throttle is less than about 10% of its range
if
((
user_input_struct
->
rc_commands
[
THROTTLE
]
>
118000
)
||
(
user_defined_struct
->
flight_mode
==
AUTO_FLIGHT_MODE
))
{
//
if((user_input_struct->rc_commands[THROTTLE] >
//
118000) || (user_defined_struct->flight_mode == AUTO_FLIGHT_MODE))
//
{
//THROTTLE
actuator_struct
->
pwms
[
0
]
=
graph_get_output
(
graph
,
parameter_struct
->
mixer
,
MIXER_PWM0
);
...
...
@@ -298,14 +308,14 @@ int control_algorithm_init(parameter_t * ps)
actuator_struct
->
pwms
[
2
]
=
graph_get_output
(
graph
,
parameter_struct
->
mixer
,
MIXER_PWM2
);
actuator_struct
->
pwms
[
3
]
=
graph_get_output
(
graph
,
parameter_struct
->
mixer
,
MIXER_PWM3
);
}
else
//
}
/*
else
{
actuator_struct->pwms[0] = user_input_struct->rc_commands[THROTTLE];
actuator_struct->pwms[1] = user_input_struct->rc_commands[THROTTLE];
actuator_struct->pwms[2] = user_input_struct->rc_commands[THROTTLE];
actuator_struct->pwms[3] = user_input_struct->rc_commands[THROTTLE];
}
}
*/
//logging
// here we are not actually duplicating the logging from the PID computation
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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