R2R
Functions
Utilities.c File Reference

The source code for utilities. More...

#include "r2r.h"
#include "Utilities.h"

Functions

void setMODE (mode newMODE)
 Sets the Mode of the robot. More...
 
mode getMODE ()
 Return the Mode of the robot. More...
 
void setN (void)
 Receive number N of samples to save into data buffer. More...
 
void setNclient (int n)
 Recieve number of values to store in position data arrays from client. 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 ()
 Returns true if the buffer is empty. More...
 
int buffer_full ()
 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 ()
 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...
 
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...
 

Detailed Description

The source code for utilities.

This file contains the buffer and mode functions

Author
Benjamen Lim
Huan Weng
Blake Strebel

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