User interface

From Rsewiki
(Difference between revisions)
Jump to: navigation, search
(Extended Backus–Naur form (EBNF))
 
(59 intermediate revisions by one user not shown)
Line 1: Line 1:
  
==Screen dumps==
+
Back to [[regbot | Regbot]] main page
  
The user interface can configure and run the robot, as well as inspecting almost all values on the robot. Written in python using Qt GUI library.
+
==Overview==
  
The interface looks like on figures below.
+
Connection is either using USB or network if the robot has wifi.
  
 +
On Windows USB is com3, com4 or any higher, see the device-list in the control panel.
  
[[File:Gui_robot.png]]
+
On Linux USB is /dev/ttyACM0 or /dev/ttyACM1 if /dev/ttyACM0 is used for other devices.
  
Figure 1. The general settings for the robot. The left panel is the general connection status and space for some messages from the robot. The central tab is mostly for configuration of the robot and some sensor and calculated values like pose and tilt. To the right is a fast graph of the last mission.
 
  
=== Data logger ===
+
The user interface can configure and run the robot, as well as inspect almost all values on the robot. Written in python using Qt GUI library.
  
[[File:Gui_rev0.png]]
+
The interface looks like on figures below.
  
Figure 2. The data logging options. A number of sensor values and interface points in the robot software can be logged. The text window shows loaded data from a mission. The log format is designed to be directly compatible with the 'load' function in MATLAB.
+
In general:
 +
* Yellow fields are read-only (updates from the robot when connected).
 +
* White fields are editable
 +
* Editable fields require (in general) that an "edit" button be pressed first and a "save" button after the edit.
 +
* Many check-boxes get implemented as they are checked/unchecked, but not all.
 +
* Data is updated from the robot at a relatively low update rate; if data is to be used for documentation, then use the onboard log function.
  
The control details gives detaild at datapoints connected to or inside the general PID controler design used for all control settings. These control datapoints is illustrated in the figure below.
 
  
=== Controller block overview===
+
[[File:Gui_robot.png | 800px]]
  
[[File:Gui_control_data_points.png]]
+
Figure 1. The general settings for the robot. The left panel is the general connection status and space for some messages from the robot. The central tab is primarily for the configuration of the robot and some sensors and calculated values like pose and tilt. To the right is a fast graph of the last mission.
 +
NB! The data rate is low, so to get an overview, use the log function for more details.
  
Figure 3. The general PID controller design with additional optional controller parts. "'''r'''" is reference input. And after the optional "'''pre-filter'''" the reference is compared with the measured value "'''m'''", optionally through a Lead filter. The "'''m-dot'''" is an optionally derivative of the measurement, that can be used for a less noisy Lead (with tau_d as normal, but no pole). The error signal "'''e'''" is fed through a gain "'''Kp'''", an optional Lead and an optional integrator. After this the output "'''u1'''" is summed from "'''up'''" (proportional/Lead), "'''ui'''" integrator term and "uf" from an optional feed forward branch. The output "'''u1'''" can further optionally be integrated (if '''Kz'''=0, if '''Kz'''=1 then the post-integrator has a zero). The output is finally limited to signal "'''u'''".
+
=== Data logger ===
  
The yellow circles indicate the datapoints that can be logged.
+
[[File:Gui_rev0.png | 800px]]
  
All integrators can be limited. The integrators are further disabled if the output limiter limits the output. Some of the control interfaces (all but the balance controllers) further disables integrators when there is defined an acceleration limit in the mission, and this actually is limiting the acceleration.
+
Figure 2. The data logging options. A number of sensor values and interface points in the robot software can be logged. The text window shows loaded data from a mission. The log format is designed to be directly compatible with the 'load' function in MATLAB.
  
The "'''post-integrator'''" is usable in the balance controller, as is the "'''m-dot'''" that is connected to tilt velocity from the gyro.
+
Use a script like this in MATLAB
  
===Controller configuration===
+
clear
 +
close all
 +
% Liv (36)
 +
%  1    time 2.005 sec
 +
%  2  3  4  5  (mission 0), state 2, entered (thread 1, line 1), events 0x0 (bit-flags)
 +
%  6  7 Motor voltage [V] left, right: 0.49 -2.11
 +
%  8  9 Encoder left, right: 4294967021 25
 +
% 10 11 Wheel velocity [m/s] left, right: -0.0885 0.0759
 +
% 12 15 Chirp amplitude=0, frequency =0 rad/s, phase=0 rad, value=0
 +
%%
 +
data = '''load('log_position-liv36_b.txt')''';
 +
%% plot motor voltage and velocity
 +
figure(100)
 +
hold off
 +
plot(data(:,1), data(:,6), 'linewidth', 2)
 +
hold on
 +
plot(data(:,1), data(:,10), ':', 'linewidth', 2)
 +
grid on
 +
legend('left voltage [V]', 'left vel [m s^{-1}]', 'location','northwest');
 +
xlabel('Time [sec]')
  
All controllers can be configured from the "control" page. See [[Design_overview]] for more control details.
+
The top text lines of the log file are copied to the MATLAB script to ease the identification of data to plot.
  
[[File:Gui_control.png]]
+
====ACC and gyro====
  
Figure 4. All control values are set from this page, click on the relevant controller and enter the relevant values in the dialogue window shown below.
+
Acceleration logs the acceleration values in m/s^2 on all 3 axes (x (forward if in balance),y (left), z (up if in balance))
  
[[File:Gui_control_dialog.png]]
+
Gyro is rotation velocity around the same 3-axis. Unit is degrees per second (after calibration offset).
  
Figure 5. This dialogue configures the wheel velocity controller - shown as a PI-controller with output limit at (+/-) 9V and an integrator limit of (+/-) 4V. All other options are disabled.
+
====Encoder====
  
 +
Encoder values for wheel rotation (left, right) 48 values per rotation, increases on forward.
  
=== IMU===
+
====Motor voltage====
  
The IMU page shows data from the IMU, and is used for tilt measurement for the balance controller only.
+
Is the motor voltage - before conversion to PWM, compensated for changes in battery voltage.
  
[[File:Gui_IMU.png]]
+
====Motor current====
  
Figure 5.1 IMU data. The graph shows calibrated values, and the gyro is calibrated by keeping the robot satble and press the "calibrate" button. (remember to save the result in robot flash). The servos drift slightly, so repeat if needed.
+
Filtered current sensor values. zero current is calibrated just before the start of a mission - this calibration sometimes makes a mistake, resulting in a wrong offset of the logged current. Value is in Amps. The value is filtered to match the log interval if the interval is > 2ms.
  
 +
====Wheel velocity====
  
=== Menu ===
+
Based on the time between encoder tics. If more tics are within 1 ms, then the interval time is averaged. When there is a long time between tics (>50ms), then the time since the last tick is used to calculate velocity, i.e. velocity goes towards zero with time if no encoder pulses arrive.
  
 +
==== Turn rate ====
  
 +
The turn rate is based on encoder tics (not the gyro), the unit is radian/sec
  
[[File:regbot_gui_show_menu.png]]
+
==== Robot pose ====
  
Figure 6. Other tab pages are available from the "show" menu.
+
The robot pose is position since the start of the mission (odometry coordinates), x,y,h,t where h is heading in radians (positive counterclockwise), and t is a tilt in radians (zero is in balance, positive is forward).
  
==Mission==
+
==== Line sensor ====
  
Missions are entered through the mission tab:
+
All values related to the line sensor, including AD value from each sensor.
  
[[File:Gui_mission.png]]
+
==== IR sensor ====
  
Figure 7. Missions atr entered in the left (white) area, and can be syntax tested with the button above.
+
Is distance converted to meters for each sensor (default is sensor 1 to the right and sensor 2 is forward).
The result of the check is shown in the yellow area (right).
+
==== Battery ====
The mission actually on the robot can be fetched to the right area.
+
Missions (the left area) can me saved and loaded from text files with the buttons below.
+
  
If you copy-paste from another application, so make sure not to include any formatting, 7-bit ASCII characters are allowed only.
+
Battery voltage in Volts.
  
Missions are not saved to the robot before you press "save to robot".
+
==== Extra ====
  
The mission is lost for the robot after a power cycle, unless you save the configuration to robot flash - using the "save to robot flash" to in the left pane.
+
Debug feature for log of extra values.
  
=== Mission lines ===
+
==== Mission ====
  
Mission specification consist of mission lines, each line consist of two (lower case) parts divided by ':'
+
State, Thread, Line, Event. Where State is mission state (should always be 2 or 8 when stopping), thread number and line number in that thread, for the latest line activated (if more than one is activated in the same log interval, then the latest is logged. An event is a 32-bit integer where each bit corresponds to an event number, and events are accumulated over the logging period.
  
drive parameter: continue condition (conditions are OR'ed)
+
==== Motor ref ====
  
e.g.:
+
Is the desired motor velocity (input to velocity controller) - in m/s
  
vel=-0.2, acc=3.0 : dist=1, time=12
+
==== Control time ====
  
Drive backwards at a speed of 0.2m/s, accelerate with 3m/s2 for 1 meter (or max 12 seconds)
+
Is the time taken to handle sensor data, calculate control values and advance in mission lines - this should be finised within 1ms. Value is in microseconds, so it should be below 1000 to ensure valid control calculations.
  
 +
==== Control details ====
  
==== Extended Backus–Naur form (EBNF) ====
+
Value order: r, m, m2, uf, r2, ep, up, ui, u1, u
* Full_mission = {[thread_id] mission};
+
* thread_id = 'thread=' id '\n';
+
* id = integer number
+
* mission = { mission_line };
+
* mission_line = [parameter], {',' prameter}, [':' , [continue_condition], {',' continue_condition}] '\n';
+
* parameter = parameter_name '=' value | command;
+
* command = 'cmd=', "'", '"' , string, "'", '"';
+
* string = ? any command string known by the firmware ?;
+
* parameter_name = 'vel' | 'acc' | 'log' | 'tr' | 'bal' | 'head' | 'topos' | 'edgel' | 'edger' | 'white' | 'irsensor' | 'irdist' |'servo' | 'pservo' | 'label' | 'goto' | 'event';
+
* value = ? float or integer ?;
+
* continue_condition = condition_name '=' value;
+
* condition_name = 'dist' | 'time' | 'turn' | 'count' | 'xb', | 'xw' | 'lv' | 'ir1' | 'ir2' | 'tilt' | 'event' | 'log' | 'head';
+
  
(NB! string command not implemented yet).
+
The control details give details at data points connected to or inside the general PID controller design used for all control settings. These control data points are illustrated in the figure below.
  
=== Drive values ===
+
===Controller configuration===
  
* VEL is velocity in m/s - positive is forward, 0=stop. uses last value if omitted.
+
All controllers can be configured from the "control" tab. See the [[Control]] page for more control details.
  
* ACC is acceleration limit in m/s2. Uses last value if omitted.
+
[[File:Gui_control.png | 800px]]
  
* TR is turnradius in metre - positive, 0 is turn on the spot. straight if omitted. NB! in balance the minimum turn radius is about 0.07m, as balance requires that at least one wheel can give a forward acceleration.
+
Figure 4b. All control values are set from this page; click on the relevant controller and enter the relevant values in the dialogue window shown below.
  
* BAL is balancing, uses last value if omitted, e.g.:
+
[[File:Gui_control_dialog.png | 500px]]
  
bal=1, vel=0: time = 2
+
Figure 5. This dialogue configures the wheel velocity controller - shown as a PI-Lead-controller with feed-forward and an output limit at (+/-) 9V. All other options are disabled. The blue frame boxes indicate a traditional PID controller with lead in forward (and)/or in the feedback branch.
vel=0.4 : dist = 0.5
+
tr=0.2 : turn=-90
+
bal=0, vel=0
+
  
This code starts getting into balance and set velocity to 0 for 2 seconds (it is a good idea to allow the robot to stabilize before continuing).
+
When "enable controller" is disabled, then the control is disabled.  
Then runs 0.5m and turns 90 degree to the right (CV) with a turn radius of 20cm - and while balancing. Then stop and go out of balance.
+
  
* HEAD is reference heading in degrees (-180 .. 180), set as heading reference. This is primarily for small heading changes, else use the turn radius command "TR"
+
To use feed-forward only (i.e. set output directly from ref), enable controller, but set Kp=0, and enable feed-forward with some value for Kf (when Kf = 1, then ref is used directly as output).
  
vel=0.3,acc=3 : dist=0.2
+
NB! As velocity measurements are rather noisy, the filter in the feedback path (Lead/Lag feedback) could be implemented as a low-pass filter with tau_zero = 0 and tau_pole = 0.005 (recommended).
head = 30 : dist=0.3
+
  
This mission starts straight for 20cm (heading 0), then changes heading to 30 degrees (CCV) for another 30cm. This will make the left wheel slow down and potentially go backwards to get to the new angle as fast as acceleration allows (here 3m/s2).
+
=== IMU===
  
* TOPOS engages a position controller that runs to this position (forward or backwards) relative to current position, e.g.:
+
The IMU page shows data from the IMU and is used for tilt measurement for the balance controller only.
  
topos=1 : time=5
+
[[File:Gui_IMU.png | 800px]]
topos=-1 : time=5
+
  
This goes forward for 1 meter (starting with the maximum velocity the controller allows) and stops here. And stays here until the 5 seconds is passed, then goes back to the start position.
+
Figure 5.1 IMU data. The graph shows calibrated values, and the gyro is calibrated by keeping the robot stable and pressing the "calibrate" button. (remember to save the result in robot flash). The servos drift slightly, so repeat if needed.
  
====Log====
+
A new feature has been added to set the orientation of the IMU board, but it is not shown in the image.
  
* LOG is log interval in milliseconds. Once started it continues until buffer is full.
+
=== Menu ===
  
To log a velocity step response, a mission could be:
 
  
vel=0.3,log=1:time=0.3
 
vel=0.5:log=0
 
  
The first line starts the robot with a velocity of 0.3m/s and starts logging (log=1) the log value is log interval in ms.
+
[[File:regbot_gui_show_menu.png | 600px]]
  
After 0.3 seconds velocity is stepped to 0.5m/s until the log is full (the log=0 after the ':' - see continue condition below)
+
Figure 6. Other tab pages are available from the "show" menu.
  
Note that the log is generated in RAM on the robot with limited space (approximately 30kBytes - which gives from 40 (all points) to 2000 samples), so limit the interface points logged to get longer logging time.
+
===Mission===
  
====GOTO====
+
Missions are entered through the mission tab:
  
* LABEL is a label number that can be used by GOTO.
+
[[File:Gui_mission.png | 700px]]
  
* GOTO is a jump to the label number given. This can be limited to COUNT use of goto, the count is then reset after the first skip. The goto can also be skipped if any other conditions are true when this line is reached. A line with a goto will never wait.
+
Figure 7. Missions are entered in the left (white) area, and can be syntax tested with the button above.
 +
The result of the check is shown in the yellow area (right).
 +
The mission of the robot can be fetched to the right area.
 +
Missions (the left area) can be saved and loaded from text files with the buttons below.
  
See a GOTO example below under threads.
+
If you copy-paste from another application, so make sure not to include any formatting; 7-bit ASCII characters are allowed only.
  
====Line-sensor====
+
Missions are not saved to the robot before you press "save to robot".
  
If a line sensor is installed, then the following should work too:
+
The mission is lost for the robot after a power cycle unless you save the configuration to robot flash - using the "save to robot flash" in the left pane.
  
* EDGER is following Right edge of line at -2..2 (in cm), positive is right
+
==== Mission lines ====
  
* EDGEL is following Left edge of line at -2..2 (in cm), positive is right
+
Mission specification consists of mission lines; each line consists of two (lower case) parts divided by ':'
  
* WHITE set to 1 if follow-line tape is white, else 0
+
drive parameter: continue condition
  
====Distance sensor====
+
continue conditions are OR'ed.
  
If IR distance sensors are installed, then these should work:
+
e.g.:  
  
* IRSENSOR is IR-sensor to use (1 is distance to a wall, and 2 is distance in front).
+
  vel=-0.2, acc=3.0 : dist=1, time=12
 
+
* IRDist is IR-distance to hold.
+
 
+
====Servos====
+
 
+
Control of servos, there is support for up to 3 servos (version 3 only).
+
There is 2 extra pins, one analog pin DAC (called servo 4) (real D/A converter) and one digital pin (24) called servo 5.
+
 
+
* SERVO=N PSERVO=XXX where N is servo number (1..5) and XXX is servo position, for servo 1,2 and 3 value is in range +/- 1000, where 0 is 1.5 ms, +500 is 2ms, + 1000 is 2.5ms, -500 is 1ms and -1000 is 0.5ms pulse with with at pulse frequency of 333 Hz. For servo 4 value is analog value -1000 is minimum and +1000 is maximum. for servo 5 (digital pin) XXX=0 is Low (0V) and XXX=1 is High (3.3V).
+
 
+
====Threads====
+
 
+
A command sequence may be divided into threads. The default thread has number 1.
+
 
+
* THREAD=3 means that this and all following lines are handled by one thread (with number 3). All threads are activated at time 0.
+
 
+
Example
+
  thread=0
+
    log=20: log=0
+
    event=0
+
thread=2
+
    label=1
+
    vel=0.4: time=1.0
+
    vel=0.2: time=1.0
+
    vel=0.0: time=1.0
+
    event=3 : event=7
+
    vel=0.2, tr=0.15:turn=90
+
    goto=1
+
thread=9
+
    bal=0:event=3
+
    bal=1: time=2
+
    label=12
+
    event=7:time=0.1
+
    goto=12
+
thread=10
+
    label=20,servo=1,pservo=-300:time=1
+
    servo=1,pservo=200:time=1
+
    goto=20
+
 
+
Thread 0: This thread controls the logging function with the condition 'log=0' that is true when the log is full,
+
then the mission is stopped. 'event=0' is a special event that stops the mission.
+
 
+
Thread 2: This thread controls velocity in three steps 0.4m/s, 0.2 m/s and 0m/s, then sends an event (event=3) and waits for event 7.
+
When event 7 arrives then the robot turns 90 degrees and starts over.
+
 
+
Thread 9: This thread controls the balance. Starts with no balance, until event 3 occurs, then goes into balance mode and waits 2 seconds (to stabalize in balance). Then it enters a loop that emits event 7 every 0.1 second, to keep thread 2 going.
+
 
+
Thread 10: this is a servo control thread, that moves servo 1 between 2 positions.
+
 
+
The mission is finished when all threads has ended, in this case when the log is full.
+
 
+
The thread number is pt. not used to determine the execution order of the threads (uses script order).
+
 
+
====Events====
+
 
+
Events can be generated if an event=X command is entered in the parameter side of the colon. The event is activated when the line is activated.
+
More than one event can be activated in the same line, e.g.:
+
 
+
vel=0.2,event=7,event=12:time=1
+
event=0
+
 
+
Here event 7 and 12 are activated at the same time as the velocity is set to 0.2.
+
 
+
Event 0 has a special meaning and will terminate mission NOW (all threads)!
+
 
+
Events are used in the example above.
+
 
+
===Continue conditions===
+
 
+
':' is separation of parameters and continue condition.
+
 
+
* DIST is driven distance in this mission line - positive meters
+
* TURN is angle turned in this mission line - degrees, positive is Left (CCW if forward speed)
+
* TIME is max time in this mission line - positive seconds
+
* COUNT is used with GOTO and GOTO will be ignored, if this line is executed more than this count
+
* XB,XW,LV is conditions relevant for the line sensor (if implemented) - see below
+
* IR1,IR2 is conditions relevant for IR distance sensors - se below
+
* TILT is tilt angle (especially useful if not in balance.
+
* EVENT is testing for events
+
* LOG is true when log is full (value is ignored, but must be set to a number (e.g. 0))
+
* HEAD is absolute heading test, head=175 is true if actual heading is within 3 degrees of this value. head>XXX and head<YYY compares with current value, but is difficult to use when crossing the +/- 180 deg border.
+
 
+
The equal (=) sign can for some values (dist, turn, xb, xw and tilt) be replaced by '<' or '>', for most values (except xb, xw and head) an equal sign means equal or greater. NB! '>=', '==', '<=' and '!=' are not valid.
+
 
+
Example: Drive 0.2m then turn 30 deg to the right (turn radius=0, but will be more with acceleration being only 1m/s2) then drive another 1 second at a higher speed (or maximum 0.4m).
+
 
+
vel=0.2,acc=1 : dist=0.2
+
tr=0 : turn = -30
+
vel=0.5 : dist=0.4,time=1
+
 
+
Example Zig-zag sideways: drive 0.2m backwards and then turn 45 deg left, 45 deg right and a bit forward, repeated 2 times more with a goto (to label=6).
+
 
+
vel=-0.2, acc=2.0: dist=0.2
+
label=6:
+
tr=0.15: turn=45.0
+
tr=0.15: turn=-45.0
+
vel=0.2:dist=0.18
+
vel=-0.2,goto=6: count=2
+
+
 
+
==== Line sensor ====
+
 
+
This section is valid if a line sensor is installed and calibrated. Use "Edge" tab for calibration (put edge sensor "ON" and on a dark background and press "Calibrate no reflection" and then on a bright background and press "Calibrate white reflection", then "save on robot").
+
 
+
* XB, XW is test for crossing black/white line, value is 0..20, 0 is true on no crossing, 1..20 is confidence in crossing (20 is highest)
+
* LV is test for valid line 0=true for no valid line, 1=true for valid line. NB! A wooden (or dirty) floor is likely to give a valid line at times.
+
 
+
Example: Drive until a crossing black line is found or 2.5m is driven, then continue until the crossing line is gone (reached other side of line) and stop
+
 
+
vel=0.2, log=5, acc=2: xb>16, dist=2.5
+
:xb < 4,dist=0.2
+
vel=0:time=0.1
+
 
+
Example find white line and follow edge: Drive until (white) line is found - as before - then turn to the right and follow line for 0.5 m.
+
 
+
vel=0.2, log=5, acc=2: xw>16, dist=2.5
+
:xw < 4,dist=0.2
+
vel=0:time=0.3
+
tr=0,vel=0.2:turn=-90
+
edgel=0, white=1: dist=0.5
+
 
+
NB! testing of crossing white or black is unsafe if in balance (requires good calibration in balance). And if the front is raised, then this feature do not work at all.
+
 
+
==== Distance sensor====
+
 
+
IR1, IR2 is test for distance measured by IR sensor.
+
 
+
@todo Distance sensor is not tested much, and is therefore assumed not to work properly.
+
 
+
==== Tilt balance angle ====
+
 
+
TILT is test for tilt angle (0 is balance point)
+
 
+
Example:
+
@todo
+
 
+
==== Events ====
+
 
+
An event can be a test condition in a mission line, and can be generated by a mission line.
+
Up to 32 events can be used, they are named "event=N", where N is a number in the range [0..31].
+
An event is valid for one sample period only (1ms).
+
 
+
Events can be created from the communication interface with the command like
+
<event=5>
+
 
+
An example could be like this (a not very functional example)
+
 
+
thread=2
+
  vel=0.2:time=1         # driving at speed 0.2 m/s for 1 second
+
  vel=0,event=7:event=5  # set speed to 0 and generate event 7, then wait for event 5
+
  vel=0.2:time=1          # speed back to 0.2 m/s in 1 second
+
  vel=0                  # stop this thread
+
thread=8
+
  label=1:time=5,event=7  # wait for event 7 (generated after 1 second by thread 2) or for maximum 5 seconds (should never happen)
+
  event=12:time=1        # generate event 12 (and wait for 1 second)
+
  event=13:time=1        # generate event 13 (and wait for 1 second before ending this thread
+
 
+
The mission will not end before the user has generated event 5 (by sending "<event=5>").
+
Every time an event is generated a message is send to the client line, for this mission the following messages will be generated:
+
 
+
# event 7
+
# event 12
+
# event 13
+
# event 5    (this in response to a user event)
+
 
+
Event 0 can't be tested, it will terminate the mission immediately.
+
 
+
===Examples===
+
 
+
Example drive-turn-drive-turn at 20cm/s:
+
 
+
vel=0.2, acc=1.5 : dist = 0.5, time=5
+
tr=0.15 : turn=90
+
: dist = 0.5
+
tr=0.15 : turn=90
+
vel=0 : time=1
+
 
+
Example wait 5 seconds:
+
 
+
vel=0 : time=5
+
 
+
Example balance and follow line: Go on balance and follow left edge of white line for 0.5m, then follow line for another 0.5m without balance.
+
 
+
vel=0.2,edgel=0,white=1,bal=1: dist>0.5
+
bal=0,edgel=0,white=1:dist=0.5
+
 
+
NB! Most examples - and especially balance - requires valid controller parameters and calibrated sensors (tilt offset for balance).
+
 
+
===Save ===
+
Transfer the mission to the robot RAM by pressing "Save" (top right), the mission will be lost by a reboot or power off, unless saved on robot!
+
  
Save the mission on the robot flash memory (EE-prom) by pressing "save on Robot" (left panel). NB! The space is limited (about 100 lines)!
+
Drive backwards at a speed of 0.2m/s, and accelerate with 3m/s2 to this speed until a distance of 1 meter is driven or 12 seconds have passed.
  
The mission can also be saved in a text-file using the bottom right save button
+
See [[Mission]] for more details.

Latest revision as of 09:09, 17 November 2023

Back to Regbot main page

Contents

[edit] Overview

Connection is either using USB or network if the robot has wifi.

On Windows USB is com3, com4 or any higher, see the device-list in the control panel.

On Linux USB is /dev/ttyACM0 or /dev/ttyACM1 if /dev/ttyACM0 is used for other devices.


The user interface can configure and run the robot, as well as inspect almost all values on the robot. Written in python using Qt GUI library.

The interface looks like on figures below.

In general:

  • Yellow fields are read-only (updates from the robot when connected).
  • White fields are editable
  • Editable fields require (in general) that an "edit" button be pressed first and a "save" button after the edit.
  • Many check-boxes get implemented as they are checked/unchecked, but not all.
  • Data is updated from the robot at a relatively low update rate; if data is to be used for documentation, then use the onboard log function.


Gui robot.png

Figure 1. The general settings for the robot. The left panel is the general connection status and space for some messages from the robot. The central tab is primarily for the configuration of the robot and some sensors and calculated values like pose and tilt. To the right is a fast graph of the last mission. NB! The data rate is low, so to get an overview, use the log function for more details.

[edit] Data logger

Gui rev0.png

Figure 2. The data logging options. A number of sensor values and interface points in the robot software can be logged. The text window shows loaded data from a mission. The log format is designed to be directly compatible with the 'load' function in MATLAB.

Use a script like this in MATLAB

clear
close all
% Liv (36)
%  1    time 2.005 sec
%  2  3  4  5   (mission 0), state 2, entered (thread 1, line 1), events 0x0 (bit-flags)
%  6  7 Motor voltage [V] left, right: 0.49 -2.11
%  8  9 Encoder left, right: 4294967021 25
% 10 11 Wheel velocity [m/s] left, right: -0.0885 0.0759
% 12 15 Chirp amplitude=0, frequency =0 rad/s, phase=0 rad, value=0
%%
data = load('log_position-liv36_b.txt');
%% plot motor voltage and velocity
figure(100)
hold off
plot(data(:,1), data(:,6), 'linewidth', 2)
hold on
plot(data(:,1), data(:,10), ':', 'linewidth', 2)
grid on
legend('left voltage [V]', 'left vel [m s^{-1}]', 'location','northwest');
xlabel('Time [sec]')

The top text lines of the log file are copied to the MATLAB script to ease the identification of data to plot.

[edit] ACC and gyro

Acceleration logs the acceleration values in m/s^2 on all 3 axes (x (forward if in balance),y (left), z (up if in balance))

Gyro is rotation velocity around the same 3-axis. Unit is degrees per second (after calibration offset).

[edit] Encoder

Encoder values for wheel rotation (left, right) 48 values per rotation, increases on forward.

[edit] Motor voltage

Is the motor voltage - before conversion to PWM, compensated for changes in battery voltage.

[edit] Motor current

Filtered current sensor values. zero current is calibrated just before the start of a mission - this calibration sometimes makes a mistake, resulting in a wrong offset of the logged current. Value is in Amps. The value is filtered to match the log interval if the interval is > 2ms.

[edit] Wheel velocity

Based on the time between encoder tics. If more tics are within 1 ms, then the interval time is averaged. When there is a long time between tics (>50ms), then the time since the last tick is used to calculate velocity, i.e. velocity goes towards zero with time if no encoder pulses arrive.

[edit] Turn rate

The turn rate is based on encoder tics (not the gyro), the unit is radian/sec

[edit] Robot pose

The robot pose is position since the start of the mission (odometry coordinates), x,y,h,t where h is heading in radians (positive counterclockwise), and t is a tilt in radians (zero is in balance, positive is forward).

[edit] Line sensor

All values related to the line sensor, including AD value from each sensor.

[edit] IR sensor

Is distance converted to meters for each sensor (default is sensor 1 to the right and sensor 2 is forward).

[edit] Battery

Battery voltage in Volts.

[edit] Extra

Debug feature for log of extra values.

[edit] Mission

State, Thread, Line, Event. Where State is mission state (should always be 2 or 8 when stopping), thread number and line number in that thread, for the latest line activated (if more than one is activated in the same log interval, then the latest is logged. An event is a 32-bit integer where each bit corresponds to an event number, and events are accumulated over the logging period.

[edit] Motor ref

Is the desired motor velocity (input to velocity controller) - in m/s

[edit] Control time

Is the time taken to handle sensor data, calculate control values and advance in mission lines - this should be finised within 1ms. Value is in microseconds, so it should be below 1000 to ensure valid control calculations.

[edit] Control details

Value order: r, m, m2, uf, r2, ep, up, ui, u1, u

The control details give details at data points connected to or inside the general PID controller design used for all control settings. These control data points are illustrated in the figure below.

[edit] Controller configuration

All controllers can be configured from the "control" tab. See the Control page for more control details.

Gui control.png

Figure 4b. All control values are set from this page; click on the relevant controller and enter the relevant values in the dialogue window shown below.

Gui control dialog.png

Figure 5. This dialogue configures the wheel velocity controller - shown as a PI-Lead-controller with feed-forward and an output limit at (+/-) 9V. All other options are disabled. The blue frame boxes indicate a traditional PID controller with lead in forward (and)/or in the feedback branch.

When "enable controller" is disabled, then the control is disabled.

To use feed-forward only (i.e. set output directly from ref), enable controller, but set Kp=0, and enable feed-forward with some value for Kf (when Kf = 1, then ref is used directly as output).

NB! As velocity measurements are rather noisy, the filter in the feedback path (Lead/Lag feedback) could be implemented as a low-pass filter with tau_zero = 0 and tau_pole = 0.005 (recommended).

[edit] IMU

The IMU page shows data from the IMU and is used for tilt measurement for the balance controller only.

Gui IMU.png

Figure 5.1 IMU data. The graph shows calibrated values, and the gyro is calibrated by keeping the robot stable and pressing the "calibrate" button. (remember to save the result in robot flash). The servos drift slightly, so repeat if needed.

A new feature has been added to set the orientation of the IMU board, but it is not shown in the image.

[edit] Menu

Regbot gui show menu.png

Figure 6. Other tab pages are available from the "show" menu.

[edit] Mission

Missions are entered through the mission tab:

Gui mission.png

Figure 7. Missions are entered in the left (white) area, and can be syntax tested with the button above. The result of the check is shown in the yellow area (right). The mission of the robot can be fetched to the right area. Missions (the left area) can be saved and loaded from text files with the buttons below.

If you copy-paste from another application, so make sure not to include any formatting; 7-bit ASCII characters are allowed only.

Missions are not saved to the robot before you press "save to robot".

The mission is lost for the robot after a power cycle unless you save the configuration to robot flash - using the "save to robot flash" in the left pane.

[edit] Mission lines

Mission specification consists of mission lines; each line consists of two (lower case) parts divided by ':'

drive parameter: continue condition 

continue conditions are OR'ed.

e.g.:

vel=-0.2, acc=3.0 : dist=1, time=12

Drive backwards at a speed of 0.2m/s, and accelerate with 3m/s2 to this speed until a distance of 1 meter is driven or 12 seconds have passed.

See Mission for more details.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox