R2R
Classes | Macros | Enumerations | Functions
Utilities.h File Reference

utilities header More...

Go to the source code of this file.

Classes

struct  control_data_t
 

Macros

#define DECIMATION   10
 
#define REFERENCE_DATA   10000
 
#define BUFLEN   10000
 

Enumerations

enum  mode {
  IDLE, PWM, HOLD, TRACK,
  ITRACK, ITEST, ISENSE, ICALIB
}
 

Functions

void setNclient (int n)
 Recieve number of values to store in position data arrays from client. More...
 
int boundInt (int a, int n)
 Bounds a given input to a range of values. More...
 
int maxInt (int a, int b)
 returns the large value of the two More...
 
mode getMODE ()
 Return the Mode of the robot. More...
 
void setMODE (mode newMODE)
 Sets the Mode of the robot. More...
 
void setN (void)
 Receive number N of samples to save into data buffer. More...
 
int getN (void)
 Returns the number of samples. More...
 
void write_refPos (int position, int index, int motor)
 Writes the reference position. More...
 
int get_refPos (int index, int motor)
 Gets the reference position. More...
 
int buffer_empty (void)
 Returns true if the buffer is empty. More...
 
int buffer_full (void)
 Returns true if the buffer is full. More...
 
int buffer_read_position (int motor)
 Reads position from the current buffer location. More...
 
int buffer_read_u (int motor)
 Reads current value from current buffer location. More...
 
void buffer_read_increment (void)
 Increments the buffer read index. More...
 
void buffer_write (int M1_actPos, int M2_actPos, int M1_u, int M2_u)
 Write data to buffer. More...
 
void send_data (void)
 Send data to client when it becomes available. More...
 

Detailed Description

utilities header

This file contains the communication buffer and mode functions

Author
Benjamen Lim
Huan Weng
Blake Strebel

Enumeration Type Documentation

◆ mode

enum mode

Data structure containing the modes of the system

Enumerator
IDLE 

Sets motor effort to 0

PWM 

PWM directly set by user

HOLD 

Sets motor effort to holding position

TRACK 

Sets motor effort to tracking mode

ITRACK 

Track reference current

ITEST 

Test current control

ISENSE 

Read current for N samples

ICALIB 

Calibrate current sensing offsets

Function Documentation

◆ boundInt()

int boundInt ( int  a,
int  n 
)

Bounds a given input to a range of values.

Parameters
inta the input value
intn the range of the bounds
Returns
int the bounded output

◆ buffer_empty()

int buffer_empty ( void  )

Returns true if the buffer is empty.

READ == WRITE

Parameters
Void
Returns
int true if buffer is empty

◆ buffer_full()

int buffer_full ( void  )

Returns true if the buffer is full.

(WRITE + 1) % BUFLEN == READ

Parameters
Void
Returns
int true if buffer is full

◆ buffer_read_increment()

void buffer_read_increment ( void  )

Increments the buffer read index.

Parameters
Void
Returns
Void

◆ buffer_read_position()

int buffer_read_position ( int  motor)

Reads position from the current buffer location.

This function assumes that buffer is not empty

Parameters
intmotor the motor that is read from
Returns
int position of the current buffer location

◆ buffer_read_u()

int buffer_read_u ( int  motor)

Reads current value from current buffer location.

This function assumes that buffer is not empty

Parameters
intmotor motor that is read from
Returns
int current value in buffer

◆ buffer_write()

void buffer_write ( int  M1_actPos,
int  M2_actPos,
int  M1_u,
int  M2_u 
)

Write data to buffer.

Parameters
intM1_actPos motor 1 position
intM2_actPos motor 2 position
intM1_u motor 1 effort
intM1_u motor 2 effort
Returns
Void

◆ get_refPos()

int get_refPos ( int  index,
int  motor 
)

Gets the reference position.

Parameters
intindex
intmotor
Returns
int returns the reference position

◆ getMODE()

mode getMODE ( )

Return the Mode of the robot.

Parameters
modeoperating mode of the robot
Returns
Void

◆ getN()

int getN ( void  )

Returns the number of samples.

Parameters
Void
Returns
int the number of samples

◆ maxInt()

int maxInt ( int  a,
int  b 
)

returns the large value of the two

Parameters
inta one input value
intb the other input value
Returns
int the larger value

◆ send_data()

void send_data ( void  )

Send data to client when it becomes available.

Parameters
Void
Returns
Void

◆ setMODE()

void setMODE ( mode  newMODE)

Sets the Mode of the robot.

The avaliable modes are IDLE, HOLD, TRACK, PWM, ISENSE, ITEST, ITRACK, ICALIB

Parameters
modeoperating mode of the robot
Returns
Void

◆ setN()

void setN ( void  )

Receive number N of samples to save into data buffer.

Parameters
Void
Returns
Void

◆ setNclient()

void setNclient ( int  n)

Recieve number of values to store in position data arrays from client.

Parameters
Void
Returns
Void

◆ write_refPos()

void write_refPos ( int  position,
int  index,
int  motor 
)

Writes the reference position.

Parameters
intposition
intindex
intmotor
Returns
Void