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
e7a2ea0a
Unverified
Commit
e7a2ea0a
authored
8 years ago
by
Jake Drahos
Browse files
Options
Downloads
Patches
Plain Diff
Added frontend_setpid
parent
f8cbdaa4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
groundStation/src/frontend/frontend_setpid.c
+65
-0
65 additions, 0 deletions
groundStation/src/frontend/frontend_setpid.c
groundStation/src/frontend/frontend_setpid.h
+17
-0
17 additions, 0 deletions
groundStation/src/frontend/frontend_setpid.h
with
82 additions
and
0 deletions
groundStation/src/frontend/frontend_setpid.c
0 → 100644
+
65
−
0
View file @
e7a2ea0a
#include
<err.h>
#include
<stdio.h>
#include
"frontend_setpid.h"
#include
"pid_common.h"
#include
"frontend_common.h"
int
frontend_setpid
(
struct
backend_conn
*
conn
,
struct
frontend_pid_data
*
pid_data
,
int
mask
)
{
if
(
conn
==
NULL
)
{
return
-
1
;
}
char
*
controller
;
switch
(
pid_data
->
controller
)
{
case
PID_PITCH
:
controller
=
"pitch"
;
break
;
case
PID_ROLL
:
controller
=
"roll"
;
break
;
case
PID_YAW
:
controller
=
"yaw"
;
break
;
/* What is the "throttle" pid constant? */
default:
warnx
(
"Unsupported PID variable"
);
return
-
1
;
}
char
buffer
[
2048
];
/* Set the P, I, and D */
if
(
mask
&
SET_P
)
{
if
(
snprintf
(
buffer
,
2048
,
"set%sp %f
\n
"
,
controller
,
pid_data
->
p
)
>=
2048
)
{
errx
(
0
,
"Buffer to small to format!"
);
}
ucart_backendWrite
(
conn
,
buffer
);
}
if
(
mask
&
SET_I
)
{
if
(
snprintf
(
buffer
,
2048
,
"set%si %f
\n
"
,
controller
,
pid_data
->
i
)
>=
2048
)
{
errx
(
0
,
"Buffer to small to format!"
);
}
ucart_backendWrite
(
conn
,
buffer
);
}
if
(
mask
&
SET_D
)
{
if
(
snprintf
(
buffer
,
2048
,
"set%sd %f
\n
"
,
controller
,
pid_data
->
d
)
>=
2048
)
{
errx
(
0
,
"Buffer to small to format!"
);
}
ucart_backendWrite
(
conn
,
buffer
);
}
return
0
;
}
This diff is collapsed.
Click to expand it.
groundStation/src/frontend/frontend_setpid.h
0 → 100644
+
17
−
0
View file @
e7a2ea0a
#ifndef _FRONTEND_SETPID_H
#define _FRONTEND_SETPID_H
#include
"pid_common.h"
#include
"frontend_common.h"
int
frontend_setpid
(
struct
backend_conn
*
conn
,
struct
frontend_pid_data
*
pid_data
,
int
mask
);
#define SET_P 0x01
#define SET_I 0x02
#define SET_D 0x04
#define SET_ALL (SET_P | SET_I | SET_D)
#endif
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