Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART_17-18
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
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
bbartels
MicroCART_17-18
Commits
08e4a161
Commit
08e4a161
authored
8 years ago
by
dawehr
Browse files
Options
Downloads
Patches
Plain Diff
Updated callbacks.c to work
Callbacks seem to be working now. Response packet is not sending correctly?
parent
5aef4982
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
quad/sw/modular_quad_pid/src/callbacks.c
+16
-195
16 additions, 195 deletions
quad/sw/modular_quad_pid/src/callbacks.c
quad/sw/modular_quad_pid/src/callbacks.h
+1
-1
1 addition, 1 deletion
quad/sw/modular_quad_pid/src/callbacks.h
with
17 additions
and
196 deletions
quad/sw/modular_quad_pid/src/callbacks.c
+
16
−
195
View file @
08e4a161
...
...
@@ -65,12 +65,12 @@ int cb_update(modular_structs_t *structs)
}
// This is called on the ground station to begin sending VRPN to the quad
int
beginupdate
(
modular_structs_t
*
structs
)
{
int
cb_
beginupdate
(
modular_structs_t
*
structs
)
{
structs
->
user_input_struct
.
receivedBeginUpdate
=
1
;
return
0
;
}
int
log
data
(
modular_structs_t
*
structs
)
int
cb_
log
(
modular_structs_t
*
structs
)
{
size_t
length
;
unsigned
char
*
packet
=
uart_buff_get_raw
(
&
length
);
...
...
@@ -78,7 +78,7 @@ int logdata(modular_structs_t *structs)
return
0
;
}
int
response
(
modular_structs_t
*
structs
)
int
cb_
response
(
modular_structs_t
*
structs
)
{
size_t
length
;
char
*
packet
=
uart_buff_get_raw
(
&
length
);
...
...
@@ -86,256 +86,77 @@ int response(modular_structs_t *structs)
return
0
;
}
// ------------------------------------------------------------------
// Quad side implementation
// TODO: Erase memory leaks
int
yawset
(
modular_structs_t
*
structs
)
int
cb_setyaw
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
setpoint_struct
.
desiredQuadPosition
.
yaw
=
uart_buff_data_get_float
(
0
);
// Debug print statement
//printf("function for yawset: %f\n", structs->setpoint_struct.desiredQuadPosition.yaw);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set desired yaw to %.2f radians
\r\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
yaw
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
yawp
(
modular_structs_t
*
structs
)
int
cb_set
yawp
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{
0
};
structs
->
parameter_struct
.
yaw_angle_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
printf
(
"function for yawp: %f
\n
"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Kp
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set yaw Kp to %.2f
\r\n
"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Kp
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
yawd
(
modular_structs_t
*
structs
)
int
cb_set
yawd
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
yaw_angle_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
printf
(
"function for yawd: %f
\n
"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Kd
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set yaw Kd to %.2f
\r\n
"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Kd
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
roll
set
(
modular_structs_t
*
structs
)
int
cb_set
roll
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
setpoint_struct
.
desiredQuadPosition
.
roll
=
uart_buff_data_get_float
(
0
);
printf
(
"function for rollset: %f
\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
roll
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set desired roll to %.2f radians
\r\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
roll
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
rollp
(
modular_structs_t
*
structs
)
int
cb_set
rollp
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
roll_angle_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
printf
(
"function for rollp: %f
\n
"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Kp
);
// Send a reply to the ground station
size_t
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set roll Kp to %.2f
\r\n
"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Kp
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
rolld
(
modular_structs_t
*
structs
)
int
cb_set
rolld
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
roll_angle_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
printf
(
"function for rolld: %f
\n
"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Kd
);
// Send a reply to the ground station
size_t
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set roll Kd to %.2f
\r\n
"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Kd
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
pitch
set
(
modular_structs_t
*
structs
)
int
cb_set
pitch
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
setpoint_struct
.
desiredQuadPosition
.
pitch
=
uart_buff_data_get_float
(
0
);
printf
(
"function for pitchset: %f
\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
pitch
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set desired pitch to %.2f radians
\r\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
pitch
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
pitchp
(
modular_structs_t
*
structs
)
int
cb_set
pitchp
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
pitch_angle_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
printf
(
"function for pitchp: %f
\n
"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Kp
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set pitch Kp to %.2f
\r\n
"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Kp
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
pitchd
(
modular_structs_t
*
structs
)
int
cb_set
pitchd
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
pitch_angle_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
printf
(
"function for pitchd: %f
\n
"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Kd
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set desired yaw to %.2f
\r\n
"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Kd
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
// ------------------------------------------------------------
// These should be renamed to altitude!
int
throttleset
(
modular_structs_t
*
structs
)
int
cb_setheight
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
setpoint_struct
.
desiredQuadPosition
.
alt_pos
=
uart_buff_data_get_float
(
0
);
printf
(
"function for throttleset: %f
\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
alt_pos
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set desired altitude to %.2f meters
\r\n
"
,
structs
->
setpoint_struct
.
desiredQuadPosition
.
alt_pos
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
throttle
p
(
modular_structs_t
*
structs
)
int
cb_setheight
p
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
alt_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
printf
(
"function for throttlep: %f
\n
"
,
structs
->
parameter_struct
.
alt_pid
.
Kp
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set alt Kp to %.2f
\r\n
"
,
structs
->
parameter_struct
.
alt_pid
.
Kp
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
throttle
i
(
modular_structs_t
*
structs
)
int
cb_setheight
i
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
alt_pid
.
Ki
=
uart_buff_data_get_float
(
0
);
printf
(
"function for throttlei: %f
\n
"
,
structs
->
parameter_struct
.
alt_pid
.
Ki
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set alt Ki to %.2f
\r\n
"
,
structs
->
parameter_struct
.
alt_pid
.
Ki
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
throttle
d
(
modular_structs_t
*
structs
)
int
cb_setheight
d
(
modular_structs_t
*
structs
)
{
char
buf
[
255
]
=
{};
structs
->
parameter_struct
.
alt_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
printf
(
"function for throttled: %f
\n
"
,
structs
->
parameter_struct
.
alt_pid
.
Kd
);
// Send a reply to the ground station
int
length
=
snprintf
(
buf
,
sizeof
(
buf
),
"Successfully set alt Kd to %.2f
\r\n
"
,
structs
->
parameter_struct
.
alt_pid
.
Kd
);
send_data
(
MessageTypes
[
5
].
ID
,
MessageTypes
[
5
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
// These should be renamed to altitude!
// ------------------------------------------------------------
int
accelreq
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
gyroresp
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
pitchangleresp
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
rollangleresp
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
gyroreq
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
pitchanglereq
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
rollanglereq
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
int
accelresp
(
modular_structs_t
*
structs
)
{
printf
(
"function for accelreq
\n
"
);
return
0
;
}
This diff is collapsed.
Click to expand it.
quad/sw/modular_quad_pid/src/callbacks.h
+
1
−
1
View file @
08e4a161
...
...
@@ -5,6 +5,6 @@
#include
"type_def.h"
/* Make commands.c happy */
typedef
void
(
command_cb
)(
modular_structs_t
*
structs
);
typedef
int
(
command_cb
)(
modular_structs_t
*
structs
);
#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