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
59323cf4
Commit
59323cf4
authored
8 years ago
by
jpbush
Browse files
Options
Downloads
Patches
Plain Diff
Update callbacks.c added some of the getter call backs and some more setters.
There are still more changes needed to have full functionality
parent
9d9e1ee6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/sw/modular_quad_pid/src/callbacks.c
+345
-14
345 additions, 14 deletions
quad/sw/modular_quad_pid/src/callbacks.c
with
345 additions
and
14 deletions
quad/sw/modular_quad_pid/src/callbacks.c
+
345
−
14
View file @
59323cf4
...
@@ -63,6 +63,9 @@ int cb_update(modular_structs_t *structs)
...
@@ -63,6 +63,9 @@ int cb_update(modular_structs_t *structs)
return
0
;
return
0
;
}
}
/* Misc. callbacks */
// This is called on the ground station to begin sending VRPN to the quad
// This is called on the ground station to begin sending VRPN to the quad
int
cb_beginupdate
(
modular_structs_t
*
structs
)
{
int
cb_beginupdate
(
modular_structs_t
*
structs
)
{
structs
->
user_input_struct
.
receivedBeginUpdate
=
1
;
structs
->
user_input_struct
.
receivedBeginUpdate
=
1
;
...
@@ -83,15 +86,18 @@ int cb_response(modular_structs_t *structs)
...
@@ -83,15 +86,18 @@ int cb_response(modular_structs_t *structs)
return
0
;
return
0
;
}
}
int
cb_setyaw
(
modular_structs_t
*
structs
)
/* Callbacks for configuration (setters)*/
int
cb_setyawp
(
modular_structs_t
*
structs
)
{
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
yaw
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
yaw_angle_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
int
cb_setyaw
p
(
modular_structs_t
*
structs
)
int
cb_setyaw
i
(
modular_structs_t
*
structs
)
{
{
structs
->
parameter_struct
.
yaw_angle_pid
.
K
p
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
yaw_angle_pid
.
K
i
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
...
@@ -101,15 +107,15 @@ int cb_setyawd(modular_structs_t *structs)
...
@@ -101,15 +107,15 @@ int cb_setyawd(modular_structs_t *structs)
return
0
;
return
0
;
}
}
int
cb_setroll
(
modular_structs_t
*
structs
)
int
cb_setroll
p
(
modular_structs_t
*
structs
)
{
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
roll
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
roll_angle_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
int
cb_setroll
p
(
modular_structs_t
*
structs
)
int
cb_setroll
i
(
modular_structs_t
*
structs
)
{
{
structs
->
parameter_struct
.
roll_angle_pid
.
K
p
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
roll_angle_pid
.
K
i
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
...
@@ -119,15 +125,15 @@ int cb_setrolld(modular_structs_t *structs)
...
@@ -119,15 +125,15 @@ int cb_setrolld(modular_structs_t *structs)
return
0
;
return
0
;
}
}
int
cb_setpitch
(
modular_structs_t
*
structs
)
int
cb_setpitch
p
(
modular_structs_t
*
structs
)
{
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
pitch
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
pitch_angle_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
int
cb_setpitch
p
(
modular_structs_t
*
structs
)
int
cb_setpitch
i
(
modular_structs_t
*
structs
)
{
{
structs
->
parameter_struct
.
pitch_angle_pid
.
K
p
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
pitch_angle_pid
.
K
i
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
...
@@ -137,9 +143,93 @@ int cb_setpitchd(modular_structs_t *structs)
...
@@ -137,9 +143,93 @@ int cb_setpitchd(modular_structs_t *structs)
return
0
;
return
0
;
}
}
int
cb_set
height
(
modular_structs_t
*
structs
)
int
cb_set
yawratep
(
modular_structs_t
*
structs
)
{
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
alt_pos
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
yaw_ang_vel_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setyawratei
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
yaw_ang_vel_pid
.
Ki
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setyawrated
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
yaw_ang_vel_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setrollratep
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
roll_ang_vel_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setrollratei
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
roll_ang_vel_pid
.
Ki
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setrollrated
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
roll_ang_vel_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setpitchratep
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
pitch_ang_vel_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setpitchratei
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
pitch_ang_vel_pid
.
Ki
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setpitchrated
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
pitch_ang_vel_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setxp
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
local_x_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setxi
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
local_x_pid
.
Ki
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setxd
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
local_x_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setyp
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
local_y_pid
.
Kp
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setyi
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
local_y_pid
.
Ki
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setyd
(
modular_structs_t
*
structs
)
{
structs
->
parameter_struct
.
local_y_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
return
0
;
return
0
;
}
}
...
@@ -157,3 +247,244 @@ int cb_setheightd(modular_structs_t *structs)
...
@@ -157,3 +247,244 @@ int cb_setheightd(modular_structs_t *structs)
{
{
structs
->
parameter_struct
.
alt_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
structs
->
parameter_struct
.
alt_pid
.
Kd
=
uart_buff_data_get_float
(
0
);
}
}
int
cb_setheight
(
modular_structs_t
*
structs
)
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
alt_pos
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setx
(
modular_structs_t
*
structs
)
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
x_pos
=
uart_buff_data_get_float
(
0
);
return
0
;
}
// TODO cb_sety will replace cb_setlat in commands.c once we talk about it
int
cb_sety
(
modular_structs_t
*
structs
)
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
y_pos
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setlon
(
modular_structs_t
*
structs
)
{
// TODO need to be able to take in a lat, lon position and convert it to quad x, y pos
return
0
;
}
int
cb_setlat
(
modular_structs_t
*
structs
)
{
// TODO need to be able to take in a lat, lon position and convert it to quad x, y pos
return
0
;
}
int
cb_setyaw
(
modular_structs_t
*
structs
)
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
yaw
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setpitch
(
modular_structs_t
*
structs
)
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
pitch
=
uart_buff_data_get_float
(
0
);
return
0
;
}
int
cb_setroll
(
modular_structs_t
*
structs
)
{
structs
->
setpoint_struct
.
desiredQuadPosition
.
roll
=
uart_buff_data_get_float
(
0
);
return
0
;
}
/* callbacks for getters */
int
cb_getyawp
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Kp
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
0
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getyawi
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Ki
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
1
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getyawd
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
yaw_angle_pid
.
Kd
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
2
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getrollp
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Kp
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
3
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getrolli
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Ki
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
4
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getrolld
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
roll_angle_pid
.
Kd
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
5
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getpitchp
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Kp
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
6
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getpitchi
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Ki
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
7
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getpitchd
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
pitch_angle_pid
.
Kd
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
8
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getyawratep
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
yaw_ang_vel_pid
.
Kp
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
9
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getyawratei
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
yaw_ang_vel_pid
.
Ki
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
10
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getyawrated
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
yaw_ang_vel_pid
.
Kd
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
11
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getrollratep
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
roll_ang_vel_pid
.
Kp
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
12
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getrollratei
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
roll_ang_vel_pid
.
Ki
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
13
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getrollrated
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
roll_ang_vel_pid
.
Kd
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
14
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getpitchratep
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
pitch_ang_vel_pid
.
Kp
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
15
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getpitchratei
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
pitch_ang_vel_pid
.
Ki
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
16
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
int
cb_getpitchrated
(
modular_structs_t
*
structs
)
{
char
buf
[
255
];
// Message logging number of messages received and size of payload received
int
length
=
snprintf
(
buf
,
sizeof
buf
,
"%f"
,
structs
->
parameter_struct
.
pitch_ang_vel_pid
.
Kd
);
send_data
(
MessageTypes
[
2
].
ID
,
MessageTypes
[
2
].
subtypes
[
17
].
ID
,
0
,
buf
,
length
>=
sizeof
(
buf
)
?
255
:
length
+
1
);
return
0
;
}
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