Friday, April 24, 2009

Google code actually becomes useful! Supports a DVCS! MERCURIAL!

Google Code Blog: Mercurial support for Project Hosting on Google Code
We are happy to announce that Project Hosting on Google Code now supports the Mercurial version control system in addition to Subversion. This is being initially rolled out as a preview release to a few invited users on a per-project basis, so that we can iron out the kinks before making this available to the general public.


While there were several DVCSs that we could support, our decision to support Mercurial was based on two key reasons. The primary reason was to support our large base of existing Subversion users that want to use a distributed version control system. For these users we felt that Mercurial had the lowest barrier to adoption because of its similar command set, great documentation (including a great online book), and excellent tools such as Tortoise Hg. Second, given that Google Code's infrastructure is built for HTTP-based services, we found that Mercurial had the best protocol and performance characteristics for HTTP support. For more information, see our analysis.

Thursday, April 23, 2009

Warning: Quanser flexible joint uses different angle convention than motor

Quanser Academic makes a line of products, which you can see demo'd at their YouTube channel, that are sold to university laboratories as teaching aids for control theory. Today I noticed a funny undocumented quirk about one of those products. I have notified Quanser of this, and there is some indication that they will update their documentation to reflect this quirk. However, because their documentation is not on-line, it's hard to see how that update will ever reach people who have already bought these products.

I TA a graduate control lab, and today's lab had the students design and implement an LQR controller that made use of a full-state observer to control Quanser's flexible joint. The motor angle is measured by a shaft encoder (which is the output we use to drive our observer), and the arm angle is measured by another encoder. We don't need the measured arm angle because we're using a full-state observer, but we still capture it for comparison to our estimated arm angle.

The students build a controller that stabilizes the plant to a moving equilibrium that tracks a square wave. At every transition, the observer trajectories had some peaky transients, as is expected, but it appeared like they were always in the wrong direction for the arm angle and its speed. I dismissed this as peaking, but one group wanted to investigate further, and so I had them track a sine wave instead. What did we find? The arm angle and speed estimates were always EXACTLY 180 degrees out of phase with the measurements.

I was shocked, and so I looked into it. Visually, I could tell that the FLEXIBLE JOINT's ANGLE ENCODER is mounted UPSIDE DOWN with respect to the motor's angle encoder. That means that rotating the motor to the "right" produces a positive angle even though rotating the JOINT to the right produces a NEGATIVE angle! The observer had it right; it was the MEASUREMENTS that were incorrect! (I built a minimal example to test my hypothesis, and what I say matched what I observed; the opposing rotations lead to equal signs)

Nowhere is this documented. Because this angle is not directly driven (it's coupled to the assembly via springs) and the arm+spring system is naturally stable and fast, this POSITIVE FEEDBACK doesn't lead to destabilize the system unless you have extremely high gain. So I'm guessing no one ever noticed. Multiplying the measurement by -1 restored intuition. I drilled down into some Quanser demo code, and I found that they do the same thing in their controllers. I have no idea why they would not document this in their rotary joint docs. Do they expect everyone to go through all of their MATLAB and Simulink code?

I could understand this error if the flexible joint was a generic component made by a different company, but the joint is solely for the purpose of connecting to the motor, and so it would make sense that its encoder orientation would match the motor encoder orientation! At the moment, we need different gains for both.

Friday, April 10, 2009

Copying lyrics from Pandora to your clipboard

You may have noticed that Pandora gives you (everyone? just subscribers?) the ability to view the lyrics of songs. For example, when I view "Not Going Anywhere" by Keren Ann, it gives me the full lyrics for the song (note: not every song has its lyrics in the Pandora database).

Pandora has been clever about how they display the lyrics. They actually don't come down with the page. The page uses AJAX to download the lyrics after you download the page. It then populates the correct place on the page with the lyrics. It also changes the mouseover properties so that you cannot use your browser to highlight those lyrics. Because the lyrics are populated dynamically, saving the page doesn't work either.

Well, I thought that was lousy. If the lyrics are displayed in plaintext on my browser, I should be able to at least highlight them. If they really wanted to prevent me from doing that, they'd build a GIF/JPG/PNG on their end and send me the lyrics in that, right?

So I figured out that I could use Firebug, the Firefox add-on, to do what Pandora didn't want me to do.
  1. Start Firebug.
  2. Start the "Console."
  3. Use the pull-down menu on the "Console" tab to "enable" the Console.
  4. Issue the JavaScript command
    alert(fullLyrics.innerHTML)
    on the console.
  5. A dialog box should pop up with the lyrics. Use your mouse to copy them to your clipboard.
  6. You can then disable the Firebug console using that same pull-down menu.
That worked for me. It should work until they change the names within the JavaScript.

Saturday, March 21, 2009

rspublic.cls fixed to get rid of nasty Incomplete \if errors

Depending on how updated your LaTeX distribution is, if you try to use the Royal Society's rspublic.cls to build your compuscript, you may get nasty incomprehensible errors like:
! Incomplete \if; all text was ignored after line 7.

\fi
I didn't get these errors on my home system (which has TeX Live 2007 installed), but I got them on Manuscript Central for Proc. R. Soc. B, and that's a major problem.

After two days of binary searching through possible sources of the problem, I found it. Jonathan Wainwright (the author of the document class) used a \phantom in both the \@oddhead and \@evenhead without preceding it by a \protect. The \phantom macro is fragile, which means that it can cause major problems when put in contexts that move around (like headers). So it needs to be protected.

I added \protect in front of each of the two \phantom calls, and all was well in the world.

I've posted a fixed version of the document class at:Give it a shot. That version also allows for 11pt and 12pt fonts, and it defines \@ptsize, which setspace needs to exist in order to work (i.e., for double spacing).

Friday, March 20, 2009

natbib-compatible BST file for Royal Socety journals

I just whipped up rspublicnat.bst, which is a natbib-compatible BibTeX style file (BST) for the Royal Society journals (e.g., Proceedings of the Royal Society A and B and others).

FYI, the BST can be regenerated by applying LaTeX (i.e., docstrip) to rspublicnat.dbj and then applying rspublicnatbst.patch (with patch) to the resulting BST file. The patched result should closely match the Royal Society's bibliographic conventions for both in-line and listed references.

Thursday, March 19, 2009

Removing hyperref's space inside \autoref

Many journals (e.g., any of the Royal Society journals) prefer sections to be identified with the section symbol (§) rather than the word "section" followed by a space. If you use \auotref, one of the wonderful macros provided by the hyperref package, then you'll want to do something like...
\renewcommand*\sectionautorefname{\S}
Unfortunately, \autoref will still insert a space between the section symbol (\S, which renders as §) and the section number. So, as discussed in a comp.text.tex posting, you'll need to be more clever and do something like (the ~ character is the "tilde", which is on the upper-left of most keyboards; it's a LaTeX "tie"—a non-breaking space)...
\def\Snospace~{\S{}}
\renewcommand*\sectionautorefname{\Snospace}
instead. That will eat the space that \autoref inserts after the section. Voila!

Tuesday, March 17, 2009

Perl script that generates CSV and BerkeleyDB versions of LTWA list

UPDATE: If you're wondering why I just didn't save the LTWA database and search it every time I needed to abbreviate a journal, it's because I wanted to optimize for speed downstream. That is, I did all the possible processing now to speed things up later. I've also augmented the script to do the opposite (and save the results in other smaller files) so that I can tell the downstream process to take longer (and possibly have better results with less spurious entries in the hash table). I've also updated the downstream script to save any successful lookups locally to speed up successive runs. Again, contact me if you want more details.
I'm sick of looking up ISO 4 standard journal abbreviations from the List of Title Word Abbreviations (LTWA) hosted at ISSN's LTWA online. The most annoying thing about LTWA online is that you can't get one big list unless you have them mail you a paper copy (for a price). So you have to resort to clicking each letter and waiting for the list for that letter to come up.

So I wrote a Perl script that automatically cURLs each LTWA online page down, processes it, and generates both CSV and BerkeleyDB (BDB) hash files containing a list of words and their associated official LTWA abbreviation. I use the BDB file in another script to automatically generate BibTeX database files for each of my journal papers (that script first checks a list of known-good journal abbreviations before trying to generate the abbreviation itself).

There were several challenges to such a task, and the list isn't perfect. I focused on one-word entries. For more complicated abbreviations, I figured I'd lean on my list of known-good journal abbreviations. That still left LTWA entries like "psycholog-" and "bulletin-" which use "-" to imply "and any other character." So I used a typical /usr/share/dict/words list to generate a list of English words that matched each pattern. Because such lists don't usually include plurals, I used Lingua::EN::Inflect to generate plurals and then took all of the plurals that included the singular (i.e., that would also match the LTWA pattern).

So that works well for me. Someday I might put the script and/or the files it produces on-line. For the moment, if you want any of these, contact me and let me know. I'll share.

Wednesday, March 11, 2009

"Interference" seems like an appropriate name

I got a request from a marketer that I link to his product from this blog:From him:
Inference is a Microsoft Office add-in that has a point-and-click interface for adding MATLAB code, .m files, and structured data to Word and Excel documents. If you use Microsoft Office, Inference is an alternative to EX Builder and Notebook for generating reports, reproducible research, and Office applications. And regardless of whether you use Office, Inference has an integrated development environment (Inference Studio) with an intelligent editor that features breakpoints and edit-and-continue.
I have no idea why you would possibly need such a thing. I view software like this as predatory—it preys on people who think they're helpless. They end up overlooking existing easy solutions (like using the debugging features of MATLAB's own editor) and get distracted from finding truly good solutions.

Perhaps I'm being a little too harsh. Interference's own website gives a better description of its features:
Inference for MATLAB allows you to:
  • Execute MATLAB code directly inside of Microsoft Word to create formatted reports that contain explanatory text and graphical/code output.
  • Execute MATLAB code directly inside of Microsoft Excel to create dynamic spreadsheets that leverage existing Excel functionality.
  • Store all of your MATLAB code, data, and M-Files inside a single Microsoft Word and Excel document.
If you have use for such a thing... Give it a whirl, but don't come to me for help.

(by the way, my LaTeX build environment does the equivalent of "Interference for MATLAB" for LaTeX users. Among other things, if you \includegraphics{image_name} and the build environment finds an image_name.m file, it will automatically generate an image_name.eps (or image_name.pdf) whenever the MATLAB script gets updated)

Vatican: Washing machine liberated women

I first heard this on NPR this morning:
The Vatican has figured out women's liberation. The Vatican newspaper says the washing machine did more to liberate women in the 20th century than the pill or the right to work. The article is entitled: "The Washing Machine and the Liberation of Women - Put in the Detergent, Close the Lid and Relax."
Some related links from Google news:Pretty funny. Sounds like something that should have originated on The Onion, but it's real. Go Catholics!

Wednesday, February 25, 2009

My Flowering Green Tea

Do I take it out after 3 minutes? I dunno. It seems a little strong... and strange.
It started out as a ball that looked a bit like an owl pellet.