CGUI (Control GUI) inherits from QT QWidget class. It is an friendly interface for user to control the telerobot directly. The CGUI object produces an Telerobot object and build the connection between the telerobot object‘s movement functions and the GUI events through the signal and slot” technology

 

Every CGUI object produces one Telerobot object and routineThread object which inherits from QThread. The routineThread does the asking task and it will be hung up when one CGUI events happens (such as button clicked).  The routineThread object contains one guiUpdate object which inherits from QObject. The guiUpdate object works as a bridge between the routineThread and the CGUI widget through “signal and slot ” technology.

 

The functions of CGUI can be divided into three parts.

 

The first part is signal functions (marked in green in Method Summary), which are defined with “signal” keyword in QT. Such functions are invoked if the feedback information or system information updated, and the corresponding slot functions will be invoked to update the GUI surface .

 

The second part is slot functions (marked in blue in Method summary), which are defined with “slot” keyword in QT. These functions are invoked if the GUI events happens , such as  button clicked or slider moved and then the corresponding function of Telerobot object will be invoked immediately.

 

The third part is CGUI routine functions (marked in yellow in Method summary). It works in the background, guarantees the whole widget works well.

 

 

Function description                     

CGUI()

 

Construct function of class CGUI. This function produces a Telerobot object and a routineThread object. We define the routineThread class as a subclass of QThread. The definition of routineThread is made in CGUI.h.  Because the telerobot can only send the feedback information back after it gets the command (movement command or ask command) from the high level software, it must have a daemon ,which runs incessantly in the widget. This thread can be controlled by the CGUI functions. It can be started, terminated and hung up. In order to show the feedback data from QThread on the CGUI, we do not use a global variable, but through special QT “signal and slot” mechanism. Every routineThread contains a QObject, which can join the CGUI slot and signal functions with key word “connect”.  The structure diagram is shown in the following diagram.

 

 

~CGUI()

              Destruct function of class CGUI. It turns off all the hardware output and then  terminates the routineThread object, and at last it terminates the CGUI object.

 

void doConnect()

              This function connects the CGUI object and the telerobot object. Set the Start/Cancel button available. It invokes the robotConnect() function of Telerobot.

 

void doDisconnect()

              This function close all the DC output and disconnects the communication between CGUI object and the telerobot object. Set the Start/Cancel button available. It invokes the robotDisonnect() function of Telerobot.

 

void doStartCancel()

              This function can start or terminate the routineThread object. It depends on a Start/Cancel flag which is defined in the CGUI.h.  The function dostart() and docancel() will be invoked here. This function can enable or disable all the movement control GUI element, such as button and slider.

void doAnalogueDigital()

              This function  switchs the Analogue_flag which is defined in CGUI.h. If Analogue_flag is true, then the sensor channel 6 and 7 of the telerobot  are used as analogue sensor channels, the others are still digital sensors. If Analogue_flag is false , all the sensor channels are used in digital way.

void doMoveForward()

              This function moves the robot forward. The default speed is 70. It invokes the  function

 void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ). This function connects with Forward button on the CGUI.

 

 

 

void doMoveBackward()

              This function moves the robot backward. The default speed is 70.  It invokes the  function

 void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ). This function connects with Backward button on the CGUI.

void doTurnRight()

              This function turns the robot right. The default speed is 70.  It invokes the  function

 void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ). This function connects with Right button on the CGUI.

void doTurnLeft()

              This function turns the robot left. The default speed is 70.  It invokes the  function

 void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ). This function connects with Left button on the CGUI.

void doStop()

              This function turns off all the DC output. It invokes the function void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ). This function connects with Stop button on the CGUI.

void doSpeed(int speed)

              This function adjusts the two PWM output value in the same time. It invokes the function void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d )This function connects with the speed slider on the CGUI.

void doPwm1SpeedChange(int speed)

              This function adjusts  the PWM1 output value. Parameter speed can be either positive integer or negative integer. If speed more than 0, the PWM1 has positive output (PWM motor rotates in positive direction).  If speed less than 0, the PWM1 has negative output (PWM motor rotates in positive direction). If speed is 0, the Pwm1 channel has no output. This function connects with the PWM1 slider on the CGUI.

void doPwm2SpeedChange(int speed)

              This function adjusts  the PWM2 output value. Parameter speed can be either positive integer or negative integer. If speed more than 0, the PWM2 has positive output (PWM motor rotates in positive direction).  If speed less than 0, the PWM2 has negative output (PWM motor rotates in positive direction). If speed is 0, the Pwm2 has no output. This function connects with the PWM2 slider on the CGUI.

void doDc1(int speed)

              This function adjusts  the relay DC1 output value. Parameter speed can be either positive integer or negative integer. If (speed <5 and speed >-5) , relay DC1 has no output. If (speed>=5), the output is positive. If (speed<=-5), the output is negative. This function connects with the DC1 slider on the CGUI.

void doDc2(int speed)

              This function adjusts  the relay DC2 output value. Parameter speed can be either positive integer or negative integer. If (speed <5 and speed >-5) , relay DC2 has no output. If (speed>=5), the output is positive. If (speed<=-5), the output is negative. This function connects with the DC2 slider on the CGUI.

void dostart()

              This function starts the routineThread and enables the movement button and slider to be available. It invokes the  start() function which defined in the QThread class. The routineThread object ask the robot  to send the feedback information in every system period. The routineThread can be terminated by docancel() function and it can be hung up by the movement function such as doMoveForward or setSpeed(int speed);

void docancel()

              This function terminates the routineThread which is started by function dostart() and sets the movement button and slider unavailable.  It invokes the  terminate() function which defined in the QThread class. 

void motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ).

               This function configures 2 PWM output channels and 2 relay DC output channels in the same period. All the sensor channels of the telerobot are used as digital sensor channels.

 

m1d=0: PWM1 channel has no output.

m1d=1: PWM1 channel has positive output.

m1d=1: PWM1 channel has negative output.

m1s is the output power value of the PWM1 channel. The value range is from 0 to 99.

 

m2d=0: PWM2 channel has no output.

m2d=1: PWM2 channel has positive output.

m2d=1: PWM2 channel has negative output.

m2s is the output power value of the PWM2 channel. The value range is from 0 to 99.

 

m3d=0: relay DC1 channel has no output.

m3d=1: relay DC1 channel has positive output.

m3d=1: relay DC1 channel has negative output.

 

m4d=0: relay DC2 channel has no output.

m4d=1: relay DC2 channel has positive output.

m4d=1: relay DC2 channel has negative output.

 

 

void motorConfigure_Asensor(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ).

               This function configures 2 PWM output channels and 2 relay DC output channels in the same time. Sensor channel 6 and 7 are used as analogue sensor channels.

 

m1d=0: PWM1 channel has no output.

m1d=1: PWM1 channel has positive output.

m1d=1: PWM1 channel has negative output.

m1s is the output power value of the PWM1 channel. The value range is from 0 to 99.

 

m2d=0: PWM2 channel has no output.

m2d=1: PWM2 channel has positive output.

m2d=1: PWM2 channel has negative output.

m2s is the output power value of the PWM2 channel. The value range is from 0 to 99.

 

m3d=0: relay DC1 channel has no output.

m3d=1: relay DC1 channel has positive output.

m3d=1: relay DC1 channel has negative output.

 

m4d=0: relay DC2 channel has no output.

m4d=1: relay DC2 channel has positive output.

m4d=1: relay DC2 channel has negative output.

 

All the sensor channels of the telerobot are used as digital sensor channels.

void  ask( ).

               This function asks the telerobot to send the feedback.  Normally this function is invoked by routineThread object.  All the sensor channels of the telerobot are used as digital sensor channels.

void  ask_Asensor( ).

               This function asks the telerobot to send the feedback information.  Normally this function is invoked by routineThread object.   Sensor channel 6 and 7 are used as analogue sensor channels.

void  cguiUpdate( ).

         This function updates the CGUI appearance in every period. In fact, it invokes the void update() function of the Telerobot object to get the telerobot feedback information and updates the buffer and then it invokes the appearance functions (showSensor(char c) , showMotor(char c1, char c2, char c3, char c4, char c5) and showAlarm(char c) ) to update the different information fields (sensor field, motor field, alarm field etc) on  the CGUI separately.

void  showSensor(char c).

              This function shows the status of  8 channels on the sensor field of the CGUI. The eight bits of  char represents the eight sensors.   This function analyses the char c, and invokes the corresponding routine functions such as doSensor2off () to update the sensor field’s appearance.

void  showMotor(char c1, char c2, char c3, char c4, char c5)

              This function shows the DC output on the GUI. We use two QSlider and four QLabel object to express the 2  DC output and 2 PWM output status.

c1=0: PWM1 label shows “pwm1 no output”.

c1=1: PWM1 label shows “pwm1 has positive output”.

c1=2: PWM1 label shows “pwm1 has negative output”.

c2 is the value of PWM1 output channel. It will be shown on the PWM1 progress on CGUI.

 

c3=0: PWM2 label shows “pwm2 no output”.

c3=1: PWM2 label shows “pwm2 has positive output”.

c3=2: PWM2 label shows “pwm2 has negative output”.

c4 is the value of PWM2 output channel. It will be shown on the PWM2 progress on CGUI.

 

c5 contains the two relay DC output channel status, as shown in the following table.

 

void  showAlarm(char c).

              This function shows the alarm status of the telerobot.  If c is 0, the alarm field shows “no alarm”, else it shows “Alarm Alarm Alarm” textually on the GUI.

 

void  Initial().

              This function initializes the CGUI. It set the timer to zero and clean all the buffer.  Furthermore it clears the sensor field, the output field, the task information and the robot information field on the GUI.  This function will be invoked by dostart() and docancel() functions.

void  setSpeed(char c, int speed).

              setSpeed(char c, int speed) function notes the current robot movement status. The first parameter c represents the movement direction and speed represents the movement velocity.  This function works as a bridge to keep the consistency between the different input GUI element. For example,  both of the PWM1 slider and Speed slider can control the PWM1 output. If one slider’s value is changed, the other one must do the corresponding change, in order to keep the same PWM output value appearance on the CGUI.

 

 

 

 

 

 

 

 

 

 

 

 

 

 API Document :  Class CGUI

API

Logo der Universität Hamburg

Constructor Summary

CGUI()

       Constructs a CGUI object More...

~CGUI()

        Destructs the MCGUI object. More...

Method Summary

void

doConnect()

      Connect the telerobot object.  More...

void

doDisconnect()

      Disconnect the telerobot object. More...

void

doStartCancel()

      Switch the Button function of Start/Cancel Button. More...

void

doAnalogueDiagital()

      Switch the Button function of Analogue/Digital Button    

     More…

void

doMoveForward()

      Moves the telerobot forward with default speed. More...

void

doMoveBackware()

     Moves the telerobot backward with default speed. More...

void

doTurnRight()

     Turns the telerobot right with default speed. More...

void

doTurnLeft()

     Turns the telerobot left with default speed. More...

void

doStop()

     Stops the telerobot. It closes all DC outputs. More...

void

doSpeed(int speed)

     Controls the moving speed with the movement of the   

     Speed slider. More...

 void

doPwm1SpeedChange(int speed)

     Controls the moving speed of PWM1 output channel. Int speed can either positive or negative value.   More...

void

doPwm2SpeedChange(int speed)

     Controls the moving speed of PWM2 output channel. Int speed can either positive or negative value.   More…

void

doDC1(int speed)

     Controls the DC1 output. Int speed can either positive or negative value.   More…

void

doDC2(int speed)

     Controls the DC2 output. Int speed can either positive or negative value.   More…

void

dostart()

     Starts the control work. The timer will be started. All the control buttons are available. More…

void

docancel()

     Turns off all the DC output and terminates the control work. All the control buttons are not more available. More…

void

motorConfigure(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ).

     Configure all the dc outputs. More…

void

motorConfigure_Asensor(int m1d, int m1s, int m2d, int m2s, int m3d, int m4d ).

     Configure all the dc outputs and using the sensor channel as   

     analog sensor. More…

void

ask()

     Ask the telerobort status (includes sensor and motor status).

    More…

void

ask_Asensor()

     Ask the telerobot status (includes sensor and motor status) and the sensor channel are used as analogue channel. More…

void

cguiUpdate()

      Updates the GUI appearance in every period. More…

void

showSensor(char c)

       Shows the sensor status on the CGUI. More…

void

showMotor(char c1, char c2, char c3, char c4, char c5)

        Shows the 2 PWM output and 2 dc output status on the

        CGUI. More…

void

showAlarm(char c)

         Shows the alarm status on the GUI. More…

void

Initial()

     Initializes the CGUI. It Lets all the Buttons disable except the connect button. More…

void

setSpeed(char c, int speed)

          This function build the dynamic relationship between control button and the slider. More…

void

wait1Frame()

         Delay the process for one system period

void

doSensor1on()

         Show 1 on the sensor field of  CGUI.

void

dosensor1off()

          Clear the 1 on the sensor field of  CGUI.

void

doSensor2on()

         Show 2 on the sensor field of  CGUI.

 

 

void

dosensor2off()

          Clear the 2 on the sensor field of  CGUI.

void

doSensor3on()

         Show 3 on the sensor field of  CGUI.

void

dosensor3off()

          Clear the 3 on the sensor field of  CGUI.

void

doSensor4on()

         Show 4 on the sensor field of  CGUI.

void

dosensor4off()

          Clear the 4 on the sensor field of  CGUI.

void

doSensor5on()

         Show 5 on the sensor field of  CGUI.

void

dosensor5off()

          Clear the 5 on the sensor field of  CGUI.

void

doSensor6on()

         Show 6 on the sensor field of  CGUI.

void

dosensor6off()

          Clear the 6 on the sensor field of  CGUI.

void

doSensor7on()

         Show 7 on the sensor field of  CGUI.

void

dosensor7off()

          Clear the 7 on the sensor field of  CGUI.

void

doSensor8on()

         Show 8 on the sensor field of  CGUI.

void

dosensor8off()

          Clear the 8 on the sensor field of  CGUI.

void

doPwm1label(QString status)

          Show the status on the pwm1label of  CGUI

void

doPwm2label(QString status)

           Show the status on the pwm2label of  CGUI

void

doDc1label(QString status)

          Show the status on the dc1label of  CGUI

void

doDc2label(QString status)

          Show the status on the pwm2label of  CGUI

void

doAlarm(QString status)

          Show the status on the alarm label of CGUI.

void

doPwm1Speed(int speed)

          Show the speed on the Pwm_output1 progress of  CGUI.

void

doPwm2Speed(int speed)

          Show the speed on the Pwm_output2 progress of  CGUI.

void

doLed()

          Show the period number on the local timer led of CGUI.

c5

DC1

DC2

0000

Positive output

Positive output

0001

Negative output

Positive output

0010

Positive output

Positive output

0011

No output

Positive output

0100

Positive output

Negative output

0101

Negative output

Negative output

0110

Positive output

Negative output

0111

No output

Negative output

1000

Positive output

Positive output

1001

Negative output

Positive output

1010

Positive output

Positive output

1011

No output

Positive output

1100

Positive output

No output

1101

Negative output

No output

1110

Positive output

No output

1111

No output

No output

Char c

Movement

S

Stop

F

Move forward

B

Move backward

L

Turn left

R

Turn right