Skip to content
Snippets Groups Projects
Commit 08e4a161 authored by dawehr's avatar dawehr
Browse files

Updated callbacks.c to work

Callbacks seem to be working now. Response packet is not sending correctly?
parent 5aef4982
No related branches found
No related tags found
No related merge requests found
......@@ -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 logdata(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_setyawp(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_setyawd(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 rollset(modular_structs_t *structs)
int cb_setroll(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_setrollp(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_setrolld(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 pitchset(modular_structs_t *structs)
int cb_setpitch(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_setpitchp(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_setpitchd(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 throttlep(modular_structs_t *structs)
int cb_setheightp(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 throttlei(modular_structs_t *structs)
int cb_setheighti(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 throttled(modular_structs_t *structs)
int cb_setheightd(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;
}
......@@ -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
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