Skip to content
Snippets Groups Projects
Commit 59323cf4 authored by jpbush's avatar jpbush
Browse files

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
No related tags found
No related merge requests found
......@@ -63,6 +63,9 @@ int cb_update(modular_structs_t *structs)
return 0;
}
/* Misc. callbacks */
// This is called on the ground station to begin sending VRPN to the quad
int cb_beginupdate(modular_structs_t *structs) {
structs->user_input_struct.receivedBeginUpdate = 1;
......@@ -83,15 +86,18 @@ int cb_response(modular_structs_t *structs)
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;
}
int cb_setyawp(modular_structs_t *structs)
int cb_setyawi(modular_structs_t *structs)
{
structs->parameter_struct.yaw_angle_pid.Kp = uart_buff_data_get_float(0);
structs->parameter_struct.yaw_angle_pid.Ki = uart_buff_data_get_float(0);
return 0;
}
......@@ -101,15 +107,15 @@ int cb_setyawd(modular_structs_t *structs)
return 0;
}
int cb_setroll(modular_structs_t *structs)
int cb_setrollp(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;
}
int cb_setrollp(modular_structs_t *structs)
int cb_setrolli(modular_structs_t *structs)
{
structs->parameter_struct.roll_angle_pid.Kp = uart_buff_data_get_float(0);
structs->parameter_struct.roll_angle_pid.Ki = uart_buff_data_get_float(0);
return 0;
}
......@@ -119,15 +125,15 @@ int cb_setrolld(modular_structs_t *structs)
return 0;
}
int cb_setpitch(modular_structs_t *structs)
int cb_setpitchp(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;
}
int cb_setpitchp(modular_structs_t *structs)
int cb_setpitchi(modular_structs_t *structs)
{
structs->parameter_struct.pitch_angle_pid.Kp = uart_buff_data_get_float(0);
structs->parameter_struct.pitch_angle_pid.Ki = uart_buff_data_get_float(0);
return 0;
}
......@@ -137,9 +143,93 @@ int cb_setpitchd(modular_structs_t *structs)
return 0;
}
int cb_setheight(modular_structs_t *structs)
int cb_setyawratep(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;
}
......@@ -157,3 +247,244 @@ int cb_setheightd(modular_structs_t *structs)
{
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;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment