Difference between revisions of "Wifi fast.py"
m |
m |
||
Line 48: | Line 48: | ||
===user_ui.m=== | ===user_ui.m=== | ||
− | === | + | This file contains settings that should be user or machine specific. |
+ | * The PLOT_ORDER list specifies what data fields to be plot, and in what order. | ||
+ | *PLOT_NUM_X and PLOT_NUM_Y specify the initial number of subplots to use. | ||
+ | * A full example: | ||
+ | PLOT_ORDER = 1:8 | ||
+ | PLOT_NUM_X = 4; | ||
+ | PLOT_NUM_Y = 2; | ||
+ | if ~exist('matlab_listen_port') | ||
+ | matlab_listen_port = 9999; | ||
+ | else | ||
+ | disp( sprintf('Listen port %d', matlab_listen_port)); | ||
+ | end | ||
+ | SAMPLE_RATE = 500; % sample rate of system feeding the python bridge | ||
+ | PLOT_UPDATE_INTERVAL = 1.0; % time interval between updates of the plot window | ||
+ | DATA_WINDOW_TIME = 10.0; | ||
+ | PLOT_WINDOW_TIME = 10.0; | ||
+ | PLOT_SUBSAMPLE = 1; | ||
+ | data_type = 'float'; | ||
+ | SAMPLES_PER_UDP_PACKET = 10; | ||
+ | |||
+ | |||
+ | ===auto_ui_9999.txt=== | ||
+ | |||
+ | The auto_ui_nnnn.txt file is AUTO generated by wifi_fast.py. The nnnn is substituted with the UDP port number. It contains a matlab parse-able version of the .vlist file. | ||
+ | |||
+ | For example: | ||
+ | sc_state_trans, 0, 1.0 | ||
+ | state, 0, 1.0 | ||
+ | raw_hall_sensor, 0, 1.0 | ||
+ | |||
==reading SWIFI data files with matlab== | ==reading SWIFI data files with matlab== |
Revision as of 17:52, 22 September 2010
- BiomechDocs BL Knee PFresearchE
- Biomech Documentation links:
- AKCPU2z BLMD6c BLFT6c PSER1c Imu_2010 Emg_2009 Ric Upd_pcb
wifi_fast.py is the primary utility for receiving real-time telemetry from the target. It makes connection to the target via either a standard RS-232 serial port, or via a TCP connection. Once connected it reads telemetry, can log the data to a file, and can send the data via UDP for real-time plotting. It also sends keyboard characters to the target which can then be read via the C function 'getchar'.
basic command line options
- get help with wifi_fast.py -h
The typical command contains 3 or 4 options as show below. wifi_fast.py -f log_file_name -V dataport3d -F -i IP_ADDRESS
- -V option specifies a "Vlist" or variable list that describes the binary format of the telemetry packet. These vlist files live in "support_scripts\vlist". Some times matching the vlist to the firmware can be a challenge - as the two need to be precisely the same length; and the variable types must also match.
- -f option specifies the base name of the log file.
- As data is received, it converted as specified by the #vlist, and stored in a self documenting .txt file that has a time stamp suffix. Several times an hour a new file will be started and the previous one added to a zip file.
- The zip file often contains a file called "wifiload.m" that can be used with matlab to read the file and create a data structure with named fields. However, there are now easier to use matlab functions for this purpose.
- The "-f xx" file option is a special case that means no-logging.
- -F : this command line option causes wifi_fast to send a command to the SWIFI for it to flush its FIFO. When there is not connection, this FIFO will fill w/data and may take ~1min to be depleted when full.
- -i, -p : one of these options is required as it specifies how to connect to the target. The -i option specifies an IP address (or resolvable machine name), while the -p option specifies a serial port.
making a connection to the robot
via a wired connection
A wired ASYNC serial connection with the target requires a minimum of 3 wires : GND, Tx, Rx. The signals are 3.3V logical level. Several USB serial port devices called "PSER" have been made for this purpose. When connected to the PC, they will be assigned a "COMM PORT" number. Under windows you can use the "Device manager" to list the serial ports. You can run the command directly with the command "devmgmt"
via a wireless connection
The robot uses a "SWIFI" to make a connection to a 2.4Ghz "G" access point. The SWIFI needs to be pre-programmed to know what access point to connect to.
- In lab the access point is : bmech4.media.mit.edu
- You can also test connectivity with ping bmech4.media.mit.edu
From the support scripts folder run :
matlab support
A number of helpful matlab scripts and functions live in "support_scripts" and "support_scripts\matlab_support". It is help to add these directories to your matlab path. Setting the path can be done from the "File -> Set Path" dialog from the main matlab window.
plot_float : real_time plotting
The command "plot_float.m" is used to listen to a UDP port, and plot the data received on that port. When started, plot_float prompts for a port number (typically 9999) to listen on. Afterward, it runs the script "user_ui.m" and reads the file "auto_ui_9999.txt" for configuration.
user_ui.m
This file contains settings that should be user or machine specific.
- The PLOT_ORDER list specifies what data fields to be plot, and in what order.
- PLOT_NUM_X and PLOT_NUM_Y specify the initial number of subplots to use.
- A full example:
PLOT_ORDER = 1:8 PLOT_NUM_X = 4; PLOT_NUM_Y = 2; if ~exist('matlab_listen_port') matlab_listen_port = 9999; else disp( sprintf('Listen port %d', matlab_listen_port)); end SAMPLE_RATE = 500; % sample rate of system feeding the python bridge PLOT_UPDATE_INTERVAL = 1.0; % time interval between updates of the plot window DATA_WINDOW_TIME = 10.0; PLOT_WINDOW_TIME = 10.0; PLOT_SUBSAMPLE = 1; data_type = 'float'; SAMPLES_PER_UDP_PACKET = 10;
auto_ui_9999.txt
The auto_ui_nnnn.txt file is AUTO generated by wifi_fast.py. The nnnn is substituted with the UDP port number. It contains a matlab parse-able version of the .vlist file.
For example:
sc_state_trans, 0, 1.0 state, 0, 1.0 raw_hall_sensor, 0, 1.0
reading SWIFI data files with matlab
- wifiload.m
- data = wild(file_name_pattern)
- obj = wild_cvt_dirlist(directory_pattern)
off line plotting data and objects
- pit.m
- gpit.m
- spit.m
vlist
dataport
- in the SC file "dataport.c" there is the statement : switch(sc_dp.dataport_select)
- for each case, there are a number of assignment of robot variables to variables of the form "pf[n]".
- the special command "157" is used to set the value of the variable "sc_dp.dataport_select"
- thus the command "do_command.py -i IP_ADDRESS -s 157 1" sets dataport select to 1.