Robot Controller GUI

To build the Robot Controller GUI you must use first compile the the following commands. The first four commands are to build the object files. The fifth command builds the executalbe form the object codes.


To build main.cpp type:
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl -I/usr/include -DNEED_GNOMESUPPORT_H -I/usr/lib/gnome-libs/include -I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/lib/glib/include -I/usr/X11R6/include -g -O2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -c main.cpp

To build Support.cpp type:
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl -I/usr/include -DNEED_GNOMESUPPORT_H -I/usr/lib/gnome-libs/include -I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/lib/glib/include -I/usr/X11R6/include -g -O2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -c Support.cpp

To build GUI.cpp type:
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl -I/usr/include -DNEED_GNOMESUPPORT_H -I/usr/lib/gnome-libs/include -I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/lib/glib/include -I/usr/X11R6/include -g -O2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -c GUI.cpp

To build EventHandlers.cpp type:
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl -I/usr/include -DNEED_GNOMESUPPORT_H -I/usr/lib/gnome-libs/include -I/usr/lib/glib/include -I/usr/X11R6/include -I/usr/lib/glib/include -I/usr/X11R6/include -g -O2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -c EventHandlers.cpp RobotAPI.cpp

To build the executable type:
gcc -g -O2 -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -o seniordesign RobotAPI.o main.o Support.o GUI.o EventHandlers.o -rdynamic -L/usr/lib -L/usr/X11R6/lib -rdynamic -lgnomeui -lart_lgpl -lgdk_imlib -lSM -lICE -lgtk -lgdk -lgmodule -lXi -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lm -ldb1 -lglib -ldl -lpthread -lgthread


Note: You must have all the appropriate libraries installed for these commands to work. They can all be obtained on a standard Red Hat Linux 7.0 install.



main.cpp

File Description
The main file of the program.
ImportantVariables
GtkWidget *GUIWindowThis is a pointer to the main graphics window. This is the window that displays all relevant information about the robot
Important Functions Defined
int main(int argc, char *argv[])This is the main funciton of the application. It handles the setting up of the application and showing the main window. This function will return 0 is everything exits properly.
Important Functions Called
create_window()This function is defined in GUI.cpp. It handles creating the GUI window, placing all of the GUI components, and connecting the signal handlers with GUI components.


Support.cpp
File Description
None of the functions in the file are implemented. It has been included for possible future expansion.


GUI.cpp
File Description
This file contains the function which setups up the GUI.
Important Functions
GtkWidget* create_GUIWindow(void)This function setups of the GUI window. It contains function calls to the GTK libraries which setup the attributes of the GUI componenets. This function is also responsible for connecting the signal handlers to their respective components.
Important Variables
GtkWidget *GUIWindow(void)Main window which all other compnents will be displayed in.
GtkWidget *vbox1(void)Holds the menu bar.
GtkWidget *vbox2(void)Holds the RobotMap.
GtkWidget *menubar1(void)Menu bar which contains the Exit Button.
GtkWidget *hbox1(void)Horizontal box which Start, Faster, and Slower buttons.
GtkWidget *Start(void)Start Button
GtkWidget *Faster(void)Faster Button
GtkWidget *Slower(void)Slower Button
GtkWidget *RobotMap(void)Place where robot is displayed and all animation takes place.

EventHandlers.cpp

File Description
This file contains all the event handlers for the GUI. It draws out the checker board and animates the robot.
Important Variables
static GtkWidget *DrawingSurfaceThis widget stores the RobotMap so it does not have to be passed to drawing functions
static int scrollrateThis variable stores information about the current speed.
static gint orientationThis variable stores information about the current orientation.
static int PointXStores information about the current desired path's x location.
static int PointYStores information about the current desired path's y location.
TesterClass NetThis class is responsible for network functions
int StartClickedFlag which allows the draw_Grid function to determine whether start has been clicked.
Important Functions
void draw_Grid(GtkWidget *, gint, gint)The GtkWidget being passed into this function is the GUI component to which the checker board and the robot will be drawn and animated in. The two integers represent the x component and y component of total speed respectivley. This function is responsible for drawing the checker board grid and also for animating the robot. This method is also responsible for scrolling the background so that the robot appears to be moving in the direction specified.
void draw_Arrow(GtkWidget *)The GtkWidget being passed into this function is the GUI component where the robot is to be draw on. This function draws the robot in a direction which is specified by the user. The default direction is pointing up, this is equal to 0 degrees. 90 degress is pointing right, 180 degrees is pointing down, and 270 degrees is pointer to the left.
void scroll_map(void)This function is called to start the robot in motion, and also to update the input speed. This function also determines the x component of the speed, and y component of the speed. These calculations are made using the orientation angle set by the user. If the user has not yet enter an orientation the default is 0 degrees.
on_RobotMap_expose_event(GtkWidget *, GdkExposeEvent *, gpointer)The GtkWidget being passed into this method is the RobotMap when it needs redrawing. The function does not use the other data which is passed. This data is present to match the type of event being called the by the GTK event handling libraries. This function is called when any portion of the RobotMap needs to be redrawn. It calls the draw_Grid function to redraw the grid and the robot.
on_RobotMap_configure_event(GtkWidget *, GdkEventConfigure *, gpointer)he GtkWidget being passed into this method is the RobotMap when it needs redrawing. The function does not use the other data which is passed. This function is called when the application is starting up. It instantiates the class Tester which is used to implement the network functions and transmit commands.
void on_Start_Clicked(GtkButton *, gpointer)The GtkButton which is passed into this function is the button which was clicked. This function is called whenever the start button is clicked. It sets a StartClicked flag then calls the scroll_map function which will in turn call the draw_Grid function. The draw_Grid function will recongonize that the start button has been clicked, via the flag set, and that there either a x component or y component of speed. This will cause the map to begin scrolling
on_Faster_clicked(GtkButton *, gpointer)The GtkButton which is passed into this function is the button which was clicked. This function is called whenever the Faster button is clicked. This causes the speed of the robot to be incremented by a unit of 5, unless the speed of the robot is already set to a maximum of 120.
on_Slower_clicked(GtkButton *, gpointer)The GtkButton which is passed into this function is the button which was clicked. This function is called whenever the Slower button is clicked. This causes the speed of the robot to be decremented by a unit of 5, unless the speed of the robot is already set to a minmum of -120.
void on_Map_clicked(GtkWidget *, GdkEventButton *, GtkWidget *)The GtkWidget which is passed is the main window of the application This information is not used. The GdkEventButton stores information about where the clicked occured. This function takes the information given by the GdkEventButton and stores it into a global variable. So the draw_Grid function will have easy access to the data. The information contained in the second GtkWidget is not used.
void modify_Path(int, int)The integers passed into this this function are the x component and y component of the speed that the robot is traveling. This function calculates the direction which the path should be appearing to move. The new values are stored into the global variable which represent where the path should be drawn to. Due to integer chopping there is a small discrepency in the exact location of the newly calculated path.
void on_Key_Press(GtkWidget *, GdkEventKey *)The GtkWidget which is passed into this function is the area in which the key press event occured. This information is not need, therefore it is ignored. The GdkEventKey contains information about the key pressed. This information is used to decide the desired action to take.
'w' or 'W' = increment speed
'a' or 'A' = turn left
's' or 'S' = decrement speed
'd' or 'D' = turn right
'z' or 'Z' = stop all (stops any speed and stops any turning)
'o' or 'O' = stop orientation rate
'q' or 'Q' = stop motor rate


Class Tester
This file contains all the event handlers for the GUI. It draws out the checker board and animates the robot.
Method Summary
runMe()This method establishs the network connection between the controller and the simulated/actual robot.
void changeOrientation(int)Sends a command for the robot to change its orientation to passed in integer
void changeSpeed(int)Sends a command for the robot to change its speed to the passed in integer
void statusCheck()Sends a command for the robot to send a status check back.
void steerMotorSends a command for the robot to change its current rate of orientation change.
void receiveCommand ( char InstructionCode, RobotCommand* NewCommand) This method is called by the RobotAPI when it receives a command. The InstructionCode is a character representing the command. This is useful when setting up a switch statement to handle the incoming commands easily. When the program finishes with the RobotCommand be sure to delete so the program does not leak memory.