APPENDIX E - GLOBAL DEFINITIONS FOR SOFTWARE

E.1 Introduction:

The entire simulation program has been broken into a large number of modules. Each of these modules has a set of basic functions to perform. The modules must communicate with the other modules as well. This communication has been simplified by globalizing a number of basic definitions. These definitions include global constants, variables, and functions.

All of these definitions have been placed in a single include file, which will be included at the top of the main program. Thus, these definitions will be global to all other modules.

There are a number of functions which are to be used globally. The neural network subroutines are incorporated as part of the global definition, so that they may be used by any program module. Some function names have been defined in this block, for global functions which exist in the modules (C++ would be nice for this). These functions are defined this way to allow complete sharing between modules, while still allowing the functions to be stored in separate modules. The modules which have their function names in this block are the endpoint buffer management functions, the algorithmic path planning functions, and the neural network path planning functions. The user interface subroutines will be defined at the user interface level. (Note: this is clarified in the user interface program description)

There are a number of global variables defined. These variables define file names, default values, work variables, and miscellaneous option flags. A number of ‘flags’ are defined globally so that they may be used to pass options between the program modules. A set of labelled constants are also defined to ease the assignment of flags. This means that the program will specify ‘elbow = ELBOW_UP’ instead of ‘elbow = 1’. This makes the code much easier to read, and write.

A data structure is defined which will be used through most of the path planning subroutines. This structure will allow trajectories to be stored. Paths may be stored as sequential lists of trajectories. This structure keeps position, velocity, acceleration and torque. As well, it also records output errors for neural networks, and will maintain coordinates in joint and cartesian space. This structure is very memory intensive, but can store path planner output, as well as neural network training sets in the same file.

The definition file follows, and is commented. These comments will be of use for general understanding. The actual use of the definitions will become clear as the other program modules are examined, in the subsequent Appendices.

 

/*

* ROBOT TRAJECTORY GENERAL DEFINITIONS PROGRAM

*

* This code is intended to provide general definitions used by all modules

* of this program. These definitions include constants, variables, and

* function names.

*

* August 16th, 1990.

*/

 

 

#include "/usr/people/hugh/neural/netter.c" /* Neural Network Subroutines */

 

#define NEW 2 /* Internal Control codes */

#define UPDATE 3

 

#define CASE_1 1 /* Motion Planning Algorithm Types */

#define CASE_2 2

#define CASE_3 3

#define CASE_4 4

#define CASE_5 5

#define NETWORK 6

#define SET_FILE 7

#define NN_TRACK 8

 

#define MEAN_ERROR 0 /* Different types of Control Output */

#define POSITION 1

#define VELOCITY 2

#define ACCELERATION 3

#define TORQUE 4

 

#define T_POSITION 5 /* Different Graphs Available */

#define T_VELOCITY 6

#define T_ACCELERATION 7

#define T_TORQUE 8

#define T_ERROR 9

#define T1_POSITION 10

#define T1_VELOCITY 11

#define T1_ACCELERATION 12

#define T1_TORQUE 13

#define T1_ERROR 14

#define T2_POSITION 15

#define T2_VELOCITY 16

#define T2_ACCELERATION 17

#define T2_TORQUE 18

#define T2_ERROR 19

 

#define ELBOW_UP 1 /* Internal flags for elbow up/down */

#define ELBOW_DOWN 2

 

#define JOINT_1 1 /* Internal flags for data to plot */

#define JOINT_2 2

#define BOTH 3

 

#define LEN_1 0.5 /* Physical parameters for robot */

#define LEN_2 0.5 /* including joint lengths, mass etc.*/

#define MASS_1 50.0

#define MASS_2 30.0

#define MASS_PAYLOAD 0.0

#define GRAVITY 0.0

 

#define LENGTH_1 100 /* Robot Link lengths in pixels */

#define LENGTH_2 100

 

#define VMAX_T1 10.0 /* Maximum actuator values, assuming */

#define VMAX_T2 10.0 /* Symmetry for negative and positive */

#define AMAX_T1 10.0 /* values, these are typically used */

#define AMAX_T2 10.0 /* in combinations */

#define TMAX_T1 10.0

#define TMAX_T2 10.0

 

double T_STEP = .5; /* Default Controller Time step */

 

#define PI 3.141592654 /* Obvious */

#define BUFFER_SIZE 150 /* Size of the buffer of endpoints */

#define TRAIN_SET 1200 /* training set size */

 

 

void b_delete(), /* These are the functions contained in */

b_down(), /* the include file "rt_fun.c" */

b_insert(),

b_load(),

b_save(),

b_tload(),

b_tsave(),

b_up(),

kin_forward(),

kin_inverse(),

get_trajectory(),

tra_1(),

tra_2(),

tra_3(),

tra_4(),

tra_5();

int b_goto();

 

 

void nt_trajectory(), /* These are the functions cont- */

nt_save(), /* ained in the include file */

nt_add(), /* "rt_net.c" */

nt_tracker(),

nt_clear(),

nt_build(),

nt_new(),

nt_create(),

nt_set_scramble(),

nt_train(),

nt_t_gen(),

nt_t_1(),

nt_t_2(),

nt_t_3(),

nt_t_4(),

nt_t_5(),

nt_t_6(),

nt_test();

int nt_load();

 

 

typedef struct { /* This structure may be used to */

double t1_start; /* describe path end_points */

double t2_start;

double t1_end;

double t2_end; } trajectory;

 

typedef struct { /* This structure is intended for */

double x_target; /* description of paths, based upon */

double y_target; /* trajectories */

double x_position;

double y_position;

double x_velocity;

double y_velocity;

double x_acceleration;

double y_acceleration;

double x_output;

double y_output;

double t1_target;

double t2_target;

double t1_position;

double t2_position;

double t1_velocity;

double t2_velocity;

double t1_acceleration;

double t2_acceleration;

double t1_torque;

double t2_torque;

double t1_output;

double t2_output;

double t1_error;

double t2_error; } train_data;

 

typedef struct { /* A description for joint config */

double theta_1;

double theta_2; } joint_coordinates;

 

trajectory buffer[BUFFER_SIZE], /* Stores Path Endpoints */

current; /* Keeps current endpoints */

 

train_data t_set[TRAIN_SET+1]; /* Keeps data for path training */

 

int buffer_point = 0, /* Points to current line in buffer[] */

end_of_buffer = 0, /* Points to end of data in buffer[] */

batch_mode = 0, /* Can quit prints, if a batch job */

x_y_flag = 0, /* Will flag joint or cart on screen */

end_train = 0, /* Indicates end of data in t_set[] */

trace_flag = 0, /* Flag for path trace just done */

n_width = 20, /* Default network width */

n_layers = 3, /* Default network layers */

n_iterations = 100, /* Default training iterations */

n_type = SIGMOID, /* Network starts with sigmoid activ. */

n_output = POSITION, /* Network output is position */

n_bias = 0, /* No bias applied to neurons */

n_position = 0, /* No position input to network */

n_velocity = 0, /* No velocity input to network */

n_acceleration = 0, /* No acceleration input to network */

n_target = 0, /* No target input to network */

n_difference = 0, /* No difference error input to net */

n_torque = 0, /* No torque input to network */

t_number = CASE_1, /* Tajectory planner is max velocity */

train_up = 0, /* Disable joint limits of arm */

train_alt = 0, /* Will train without path reversal */

train_opt = 0, /* Will train with optimal path */

train_flag = 0, /* Will be set when net is training */ train_sim = 0, /* Will be set when joints finish simul.*/

test_flag = 0, /* Set when test network steady state */

net_loaded_flag = 0, /* Set when a network is loaded */

elbow_flag = 0, /* Will indicate elbow up/down */

joints_plot = JOINT_1, /* Will plot joint # 1 */

data_plot = POSITION; /* Will plot position of joints */

 

 

char file[100] = {"test.net"}, /* default network file */

b_file[100] = {"test.rt"}, /* default trajectory file */

dater_file[100] = {"test.data"},/* data dump file */

run_title[100] = {"Neural Network Test Algorithm\000"},

str_1[100] = {"20"}, /* Net width string */

str_2[100] = {"3"}, /* Net layers string */

str_3[100] = {"100"}, /* Training iter. string */

str_4[100] = {"0.8"}, /* Learning Rate string */

str_5[100] = {"0.8"}, /* Smoothing rate string */

str_6[100] = {"test.train"}, /* Default training set file */

t_file[100] = {"test.train"},

str_7[100] = {"0.5"}; /* Time step default time */

 

double theta1= 90.0, /* Start angles for manipulator */

theta2= -90.0,

x_global, /* x & y position of end effector */

y_global,

net_average_error, /* Variables for keeping statistics */

net_deviation, /* of current data errors */

n1_error,

n1_deviation,

n2_error,

n2_deviation,

n_smooth = 0.8, /* smoothing rate for training */

n_learn = 0.8; /* learning rate for training */

 

 

double in1_1[TRAIN_SET], in2_1[TRAIN_SET], /* memory for training */

in1_2[TRAIN_SET], in2_2[TRAIN_SET],

in1_3[TRAIN_SET], in2_3[TRAIN_SET],

out1[TRAIN_SET], out2[TRAIN_SET];

 

[an error occurred while processing this directive]