Some human operator control software and to hell with Matlab's plotting functions
The software for the human operator control has been completed and is available for others to use. Also, a bit of ranting about Matlab.
I spent the last two weeks working on automating Ron's manual control model for the bicycle/rider system and made really good progress. The overall idea would be that you can select a bicycle, rider, path, and speed for which the software then simulates the tracking task and also computes the task independent handling qualities of the bicycle rider system. We are still working on the automation of gain selection, but that is pretty close to complete. Keep checking the Github repo for updates. This has some pretty cool implications. Ron's theory for an analytical metric for task independent handling qualities is an attempt to bridge the gap between connecting the bicycle and rider's physical parameters to the handling. This is probably the first work that has made this attempt. More info can be found on the page about the topic. Here are a few potential ideas of what can be done with it:
- It can be used to adjust bicycle and rider physical parameters to have favorable handling qualities (as we have defined them).
- An optimization routine could be wrapped around the current code such that it will choose the optimal parameter set for a desired handling quality.
- It can generate simulation results for tracking any path.
We made the Simulink model and Matlab code for the paper available if you are eager to see it in action before the paper is published. [Download the software]
I love Matlab
I also spent the most time ever tweaking Matlab to produce 20+ publication quality figures for the second review of our paper. This was the first time I tried to completely control the details of Matlab's plot outputs for exact sizes, font control, line details, etc and it was a pain in the ass. The code for the plots is something like 1200 lines, but I'm sure much of it has to be there as you have to call commands for lots of details for each plot. I'm sure it would be shorter in other languages (cough..python). After I've been working with python and finally understand what the hell object oriented programming is, I've realized that Matlab's handle graphics shit is super dumb and obviously just hacked on to the Matlab language. Here are some things I found particularly annoying:
- The function bodeplot seems to always cut off the frequency xlabel and you have to manually push it up into the figure space.
- Simulink’s linmod function has no way to work nested inside another function. It always looks for variables in the base workspace. How stupid! I had to use Matlab's suggested hack of pushing all the necessary variables into the base workspace. This is certainly prone to error. Also, most of simulink seems to work this way but some functions have an option to tell it what space to get the variables from. The default should be that it gets variables from the current space, just like every other function in Matlab.
- It is difficult to find the object you want to modify inside a complicated figure. You need to be able to search for specific objects based on variable name or tags, but you have very little option to identify objects on creation (especially nested objects) and the default plot commands don't make any default labels that make sense besides a fixed point number. Searching with ‘findobj’ and guessing what item you want out of an anonymous list is stupid. Get and set are pretty bad too. This is especially annoying for plot command like bode and nyquist.
- Making a figure print to the exact size you want it to. I need my journal graphs to be an exact size with correct fonts and sizes. I can’t figure out how to do this to save my life. EPS figures seem to print at sizes other than what you tell it. I finally found out that the -loose option must be used for certain file types (i.e. eps) so that they actually print the size you command them to be, otherwise it prints smaller.
- There are two functions for making a bode plot: ‘bode’ and ‘bodeplot’. One has two axes with one line in each and the other has two axes with two lines in each. I can’t figure out what the extra lines are for in bodeplot, and they cause headaches when you want to plot multiple bode plots on the same axes.
- Simulink allows you to use TeX in label names, but doesn't allow for LaTeX which is rather unfortunate.
- Simulink is a pain to debug, I will probably forgo the graphic programming that Simulink offers in the future and stick to writing real code and doing block diagram algebra by hand. I will admit that I don' t know how to use Simulink's debugging tools, so maybe I need to give that a chance first.