Skip to content
Snippets Groups Projects
Commit 615f97f3 authored by ucart's avatar ucart
Browse files

Removing useless things

parent 9e7cb456
No related branches found
No related tags found
1 merge request!43Resolve "Transition current hardware platform to Vivado"
DEBUG LEVEL ONE
// Sensor blocks
int cur_pitch;
int cur_roll;
int cur_yaw;
int gyro_y;
int gyro_x;
int gyro_z;
int lidar;
int flow_vel_x; // optical flow
int flow_vel_y;
int flow_vel_x_filt;
int flow_vel_y_filt;
int flow_quality; // Quality value returned by optical flow sensor
int flow_distance;
// Sensor processing
int yaw_correction;
int of_angle_corr; // Corrects for the optical flow mounting angle
int of_integ_x; // Integrates the optical flow data
int of_integ_y;
int of_trim_x; // Trim value for optical flow integrated value
int of_trim_y;
int of_trimmed_x; // Trimmed optical flow integrated value (of_integ_x + of_trim_x)
int of_trimmed_y;
DEBUG LEVEL TWO
// PID blocks
int roll_pid;
int pitch_pid;
int yaw_pid;
int roll_r_pid;
int pitch_r_pid;
int yaw_r_pid;
int x_pos_pid;
int y_pos_pid;
int alt_pid;
DEBUG LEVEL THREE
// Velocity nodes
int x_vel_pid;
int y_vel_pid;
int x_vel;
int y_vel;
int x_vel_clamp;
int y_vel_clamp;
int vel_x_gain;
int vel_y_gain;
// VRPN blocks
int vrpn_x;
int vrpn_y;
int vrpn_alt;
int vrpn_pitch, vrpn_roll;
// RC blocks
int rc_pitch;
int rc_roll;
int rc_yaw;
int rc_throttle;
// Desired positions
int x_set;
int y_set;
int alt_set;
int yaw_set;
DEBUG LEVEL FOUR
// Clamps
int clamp_d_pwmP;
int clamp_d_pwmR;
int clamp_d_pwmY;
int yaw_clamp;
// Loop times
int angle_time;
int pos_time;
// Signal mixer
int mixer;
int throttle_trim;
int throttle_trim_add;
int pitch_trim;
int pitch_trim_add;
int yaw_trim;
int yaw_trim_add;
//psi dot integration chain
int psi_dot;
int psi_dot_offset;
int psi_dot_sum;
int psi;
int psi_offset;
int psi_sum;
int mag_yaw; //Complementary filtered magnetometer/gyro yaw
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "debug_rt.h"
/*
Helper to return single bit of u32 data. This returns the "position"'th bit of the given u32,
assuming it is Zero indexed.
*/
u32 read_bit(u32 data, int position){
return (data >> position) & 1;
}
/*
This method is used to configure the bits within the flags struct by reading in the data sent from the user via the groundstation.
Params:
configData: Payload from configuration packet sent from the groundstation. Each bit (starting at 31, downto 10) represents a flag either being disabled (0) or enabled (1)
SensorRTFlags_t * flags: This contains a pointer to the flags struct. This struct is held within the quad's memory and is used to determine which information within the quad's sensors
will be sent back during each control loop. Due to the limited bandwidth capacity of the UART, it is undesirable to have a large amount of these flags enabled
when sending data.
Returns:
int size: Total number of data types desired to be displayed via flight data tool.
*/
int process_configuration_packet(u32 configData, SensorRTFlags_t * flags)
{
int size = 0;
flags -> lidarflags -> quadHeight = read_bit(configData, 31); size += read_bit(configData, 31);
flags -> optflowflags -> x_flow = read_bit(configData, 30); size += 2 * read_bit(configData, 30);
flags -> optflowflags -> y_flow = read_bit(configData, 29); size += 2 * read_bit(configData, 29);
flags -> optflowflags -> x_filter = read_bit(configData, 28); size += 2 * read_bit(configData, 28);
flags -> optflowflags -> y_filter = read_bit(configData, 27); size += 2 * read_bit(configData, 27);
flags -> optflowflags -> x_velocity = read_bit(configData, 26); size += 2 * read_bit(configData, 26);
flags -> optflowflags -> y_velocity = read_bit(configData, 25); size += 2 * read_bit(configData, 25);
flags -> imuflags -> gyro_x = read_bit(configData, 24); size += read_bit(configData, 24);
flags -> imuflags -> gyro_y = read_bit(configData, 23); size += read_bit(configData, 23);
flags -> imuflags -> gyro_z = read_bit(configData, 22); size += read_bit(configData, 22);
flags -> imuflags -> acc_x = read_bit(configData, 21); size += read_bit(configData, 21);
flags -> imuflags -> acc_y = read_bit(configData, 20); size += read_bit(configData, 20);
flags -> imuflags -> acc_z = read_bit(configData, 19); size += read_bit(configData, 19);
flags -> imuflags -> mag_x = read_bit(configData, 18); size += read_bit(configData, 18);
flags -> imuflags -> mag_y = read_bit(configData, 17); size += read_bit(configData, 17);
flags -> imuflags -> mag_z = read_bit(configData, 16); size += read_bit(configData, 16);
flags -> errorflags -> lidar = read_bit(configData, 15); size += read_bit(configData, 15);
flags -> errorflags -> consec_lidar = read_bit(configData, 14); size += read_bit(configData, 14);
flags -> errorflags -> optFlow = read_bit(configData, 13); size += read_bit(configData, 13);
flags -> errorflags -> consec_optFlow = read_bit(configData, 12); size += read_bit(configData, 12);
flags -> errorflags -> imu = read_bit(configData, 11); size += read_bit(configData, 11);
flags -> errorflags -> consec_imu = read_bit(configData, 10); size += read_bit(configData, 10);
flags -> flag_count = size;
return size;
}
/*
This method populates a payload full of sensor data and transmits it to the groundstation (for real-time data logging feature)
Params:
CommDriver *comm: This contains a pointer to the communication medium currently being used to communicate with the groundstation. In its current state, this will be
the UART capabilities located on the quad.
raw_sensor_t * data: This contains a pointer to the struct containing all of the current sensor data that has been collected by the various peripherals on the quad. This
will be used to populate the majority of the information within the payload packet.
SensorRTFlags_t * flags: This contains a pointer to the flags struct. This struct is held within the quad's memory and is used to determine which information within the sensors
will be sent back during each control loop. Due to the limited bandwidth capacity of the UART, it is undesirable to have a large amount of these flags
enabled when sending data. The exact contents of the flags struct are detailed in the process_configuration_packet method as well as the struct definition
within this file's header.
Returns:
bytes_sent: Total number of bytes that were transferred via the communication channel (UART). This number can be used to determine the succesful transfer of data.
*/
int send_RT_data(struct CommDriver *comm, raw_sensor_t * data, SensorRTFlags_t * flags)
{
//include 4 bytes to carry flags info
u32 * payload = malloc(sizeof(u32) * (flags -> flag_count) + 4);
int currentPosition = 0;
u32 flag_info = 0x00000000;
/*
Since payload is calloced (all zeros), a simple | operation should set this properly
*/
if(flags -> lidarflags -> quadHeight)
{
payload[currentPosition] = (u32)(data -> lidar.distance_m);
currentPosition++;
//populate correct bit within flag_info. Due to the fact that enabled flags are stored only on the quad's memory, this information will need to be sent to the groundstation with every
//packet to ensure the correct formatting of data before being graphed.
flag_info |= QUAD_HEIGHT_FLAG;
}
//64-bit data must be sent in two concurrent 32 bit data blocks within the payload. The MSB's of the data are stored first, then the LSB's.
if(flags -> optflowflags -> x_flow)
{
payload[currentPosition] = ((u64)(data -> optical_flow.flow_x_rad)) >> 32; //MSB
currentPosition++;
payload[currentPosition] = ((u64)(data -> optical_flow.flow_x_rad)) & 0x00000000FFFFFFFF; //LSB
currentPosition++;
flag_info |= X_FLOW_FLAG;
}
if(flags -> optflowflags -> y_flow)
{
payload[currentPosition] = ((u64)(data -> optical_flow.flow_y_rad)) >> 32; //MSB
currentPosition++;
payload[currentPosition] = ((u64)(data -> optical_flow.flow_y_rad)) & 0x00000000FFFFFFFF; //LSB
currentPosition++;
flag_info |= Y_FLOW_FLAG;
}
if(flags -> optflowflags -> x_filter)
{
payload[currentPosition] = ((u64)(data -> optical_flow.xVelFilt)) >> 32; //MSB
currentPosition++;
payload[currentPosition] = ((u64)(data -> optical_flow.xVelFilt)) & 0x00000000FFFFFFFF; //LSB
currentPosition++;
flag_info |= X_FILTER_FLAG;
}
if(flags -> optflowflags -> y_filter)
{
payload[currentPosition] = ((u64)(data -> optical_flow.yVelFilt)) >> 32; //MSB
currentPosition++;
payload[currentPosition] = ((u64)(data -> optical_flow.yVelFilt)) & 0x00000000FFFFFFFF; //LSB
currentPosition++;
flag_info |= Y_FILTER_FLAG;
}
if(flags -> optflowflags -> x_velocity)
{
payload[currentPosition] = ((u64)(data -> optical_flow.xVel)) >> 32; //MSB
currentPosition++;
payload[currentPosition] = ((u64)(data -> optical_flow.xVel)) & 0x00000000FFFFFFFF; //LSB
currentPosition++;
flag_info |= X_VELOCITY_FLAG;
}
if(flags -> optflowflags -> y_velocity)
{
payload[currentPosition] = ((u64)(data -> optical_flow.yVel)) >> 32; //MSB
currentPosition++;
payload[currentPosition] = ((u64)(data -> optical_flow.yVel)) & 0x00000000FFFFFFFF; //LSB
currentPosition++;
flag_info |= Y_VELOCITY_FLAG;
}
if(flags -> imuflags -> gyro_x)
{
payload[currentPosition] = (u32)(data -> gam.gyro_xVel_p);
currentPosition++;
flag_info |= X_GYRO_FLAG;
}
if(flags -> imuflags -> gyro_y)
{
payload[currentPosition] = (u32)(data -> gam.gyro_yVel_q);
currentPosition++;
flag_info |= Y_GYRO_FLAG;
}
if(flags -> imuflags -> gyro_z)
{
payload[currentPosition] = (u32)(data -> gam.gyro_zVel_r);
currentPosition++;
flag_info |= Z_GYRO_FLAG;
}
if(flags -> imuflags -> acc_x)
{
payload[currentPosition] = (u32)(data -> gam.accel_x);
currentPosition++;
flag_info |= X_ACCEL_FLAG;
}
if(flags -> imuflags -> acc_y)
{
payload[currentPosition] = (u32)(data -> gam.accel_y);
currentPosition++;
flag_info |= Y_ACCEL_FLAG;
}
if(flags -> imuflags -> acc_z)
{
payload[currentPosition] = (u32)(data -> gam.accel_z);
currentPosition++;
flag_info |= Z_ACCEL_FLAG;
}
if(flags -> imuflags -> mag_x)
{
payload[currentPosition] = (u32)(data -> gam.mag_x);
currentPosition++;
flag_info |= X_MAG_FLAG;
}
if(flags -> imuflags -> mag_y)
{
payload[currentPosition] = (u32)(data -> gam.mag_y);
currentPosition++;
flag_info |= Y_MAG_FLAG;
}
if(flags -> imuflags -> mag_z)
{
payload[currentPosition] = (u32)(data -> gam.mag_z);
currentPosition++;
flag_info |= Z_MAG_FLAG;
}
if(flags -> errorflags -> lidar)
{
payload[currentPosition] = (u32)(data -> lidar.error.errorCount);
currentPosition++;
flag_info |= LIDAR_ERR_FLAG;
}
if(flags -> errorflags -> consec_lidar)
{
payload[currentPosition] = (u32)(data -> lidar.error.consErrorCount);
currentPosition++;
flag_info |= LIDAR_CONSEC_ERR_FLAG;
}
if(flags -> errorflags -> optFlow)
{
payload[currentPosition] = (u32)(data -> optical_flow.error.errorCount);
currentPosition++;
flag_info |= OPTFL_ERR_FLAG;
}
if(flags -> errorflags -> consec_optFlow)
{
payload[currentPosition] = (u32)(data -> optical_flow.error.consErrorCount);
currentPosition++;
flag_info |= OPTFL_CONSEC_ERR_FLAG;
}
if(flags -> errorflags -> imu)
{
payload[currentPosition] = (u32)(data -> gam.error.errorCount);
currentPosition++;
flag_info |= IMU_ERR_FLAG;
}
if(flags -> errorflags -> consec_imu)
{
payload[currentPosition] = (u32)(data -> gam.error.consErrorCount);
currentPosition++;
flag_info |= IMU_CONSEC_ERR_FLAG;
}
//package the last 4 bytes of info as binary representation of the enabled flags
payload[currentPosition] = flag_info;
int bytes_sent = send_data(comm->uart, SEND_RT_ID, 0, (u8*)payload, sizeof(payload));
free(payload);
return bytes_sent;
}
#include <stdio.h>
#include "PID.h"
#include "type_def.h"
#include "communication.h"
#include "computation_graph.h"
#include "timer.h"
#define ON 1
#define OFF 0
#define ERROR -1
#define SEND_RT_ID 20
#define QUAD_HEIGHT_FLAG 0x80000000
#define X_FLOW_FLAG 0x40000000
#define Y_FLOW_FLAG 0x20000000
#define X_FILTER_FLAG 0x10000000
#define Y_FILTER_FLAG 0x08000000
#define X_VELOCITY_FLAG 0x04000000
#define Y_VELOCITY_FLAG 0x02000000
#define X_GYRO_FLAG 0x01000000
#define Y_GYRO_FLAG 0x00800000
#define Z_GYRO_FLAG 0x00400000
#define X_ACCEL_FLAG 0x00200000
#define Y_ACCEL_FLAG 0x00100000
#define Z_ACCEL_FLAG 0x00080000
#define X_MAG_FLAG 0x00040000
#define Y_MAG_FLAG 0x00020000
#define Z_MAG_FLAG 0x00010000
#define LIDAR_ERR_FLAG 0x00008000
#define LIDAR_CONSEC_ERR_FLAG 0x00004000
#define OPTFL_ERR_FLAG 0x00002000
#define OPTFL_CONSEC_ERR_FLAG 0x00001000
#define IMU_ERR_FLAG 0x00000800
#define IMU_CONSEC_ERR_FLAG 0x00000400
void initializeFlags( SensorRTFlags_t * flag_pointer);
void freeFlags(SensorRTFlags_t * flags);
int send_RT_data(struct CommDriver *comm, raw_sensor_t * data, SensorRTFlags_t * flags);
u32 shift(u32 data, int position);
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