Anti-Sway Capstone 1.0
Loading...
Searching...
No Matches
tracking.c File Reference

Tracking Mode Control Law. More...

#include <stdbool.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include "setup.h"
#include "io.h"
#include "thread-lib.h"
#include "discrete-lib.h"
#include "record.h"
#include "tracking.h"
Include dependency graph for tracking.c:

Data Structures

struct  TrackingControlScheme
 Tracking Mode Feedback Control Block. More...
 

Macros

#define NOMINAL_REFERENCE_ANGLE   0.0
 Reference Angle (rad)
 
#define T_s   0.1
 The settling time (0.1 s)
 
#define os   0.05
 The overshoot fraction (5%)
 
#define DATA_LEN   12
 The number of entries.
 

Functions

static void SetupScheme (TrackingControlScheme *scheme, Proportional K_o, Proportional K_i, Proportional B)
 
static void * TrackingModeThread (void *resource)
 
static int TrackingControlLaw (Angle angle_ref, Angle angle_input, Velocity pos_vel, TrackingControlScheme *scheme, int(*SetVoltage)(Voltage voltage))
 
int TrackingFork ()
 
int TrackingJoin ()
 

Variables

pthread_t tracking_thread
 Thread ID.
 
ThreadResource resource
 Thread Resources (Shared Resources)
 
static TrackingControlScheme x_control
 The Control Scheme for the X Motor.
 
static TrackingControlScheme y_control
 The Control Scheme for the Y Motor.
 
static int error
 Local Error Flag.
 
static FileID_t file = -1
 The file ID.
 
static char * data_file_name = "tracking.mat"
 The file Name.
 
static char * data_names [DATA_LEN]
 The data names.
 
static double data [DATA_LEN]
 Buffer for data.
 
static double * data_buff = data
 Pointer to next data point to insert into buffer.
 
static int id = 1
 ID variable.
 

Detailed Description

Tracking Mode Control Law.

Author
Anti-Sway Team: Nguyen, Tri; Espinola, Malachi; Tevy, Vattanary; Hokenstad, Ethan; Neff, Callen)
Version
0.1
Date
2024-06-03

Function Documentation

◆ SetupScheme()

static void SetupScheme ( TrackingControlScheme * scheme,
Proportional K_o,
Proportional K_i,
Proportional B )
inlinestatic

Sets up a TrackingControl Scheme

Parameters
schemeThe scheme to setup
K_oThe outer loop gain
K_iThe inner loop gain
BThe artificial damping to impose
Postcondition
scheme is setup with appropriate outer/inner-loop control characteristics

◆ TrackingControlLaw()

static int TrackingControlLaw ( Angle angle_ref,
Angle angle_input,
Velocity pos_vel,
TrackingControlScheme * scheme,
int(* SetVoltage )(Voltage voltage) )
inlinestatic

Executes 1 timestep for the Tracking Mode Control Law for its input to the plant

Parameters
angle_refThe reference angle for Tracking Mode
angle_inputThe measured rope angle for Tracking Mode
pos_velThe measured velocity of the motor
schemeA pointer to the TrackingControlScheme structure used to execute the control law
SetVoltageThe function that sets the voltage of the appropriate motor
Returns
0 upon success, negative otherwise
Precondition
scheme was not modified before use of this function
Postcondition
scheme is now updated with the input and outputs for the respective control scheme

◆ TrackingFork()

int TrackingFork ( )

Executes Tracking Mode (concurrently)

Precondition
Tracking Mode is not already running
Returns
0 upon success, negative if error
Here is the call graph for this function:

◆ TrackingJoin()

int TrackingJoin ( )

Stops Tracking Mode (concurrent process)

Returns
0 upon success, negative if error
Here is the call graph for this function:

◆ TrackingModeThread()

static void * TrackingModeThread ( void * resource)
static

The Thread Function for Tracking Mode

Parameters
resourceA pointer to a Resource sturcture for Tracking Mode
Returns
NULL
Here is the call graph for this function:

Variable Documentation

◆ data_names

char* data_names[DATA_LEN]
static
Initial value:
= {"id", "t",
"angle_x", "angle_y",
"trolley_pos_x", "trolley_pos_y",
"trolley_vel_x", "trolley_vel_y",
"inner_x", "voltage_x",
"inner_y", "voltage_y"}

The data names.