Friday, June 17, 2016

Twitch X - Servoless Linkage Drive

I've got a new bot.

*Twitch* 
I'm not ready to call it 100% finished yet, but, most importantly, it drives!


It can pull off the trickiest bit of linkage drive maneuvering, Translation While axis-swITCHing, which proves it is possible to control all four degrees of freedom at the same time with just the four motors. That's a much better ratio of actuators to degrees of freedom than Twitch, Jr, which relied on two giant servos to steer the linkages. To steal a term from another Twitch, it's a "holonom-ish" drivetrain: able to fully control all three of its planar degrees of freedom, sort-of, in some cases, with an extra degree of freedom just for fun (and for generating more pushing power in a particular direction when desired). In reality, it doesn't have a practical advantage over some other drivetrains, but I've driven lots of different types of robots and this is by far the most fun.

I've Missed Going Home with Aluminum Chips in My Hair

The build was relatively quick and easy.

It helps when most of your parts are topologically similar waterjet-cut plates.
There were a few minor issues...can you spot the one in this picture? (Not the small linkages. Those are just from Twitch, Jr. for comparison.)
 The main actual fabrication required was making a few turned parts on my tinyLathe.

Poor tinyLathe.
These were the posts and keyed hubs for the wheels. The posts hold the thrust and radial bearings on which the drive units swivel. They're straight from tinyKart's steering system, so they should be very overkill for this robot.


Other than that, there was a just a lot of finish-drilling and countersinking. Oh, and some sketchy sheet metal bending that came out surprisingly well (using 5052 aluminum instead of 6061, for better forming properties).


The dimensional accuracy of the build wasn't quite as good as I was hoping, mostly due to lazy machining on my part. The top and bottom plate don't quite drop on with a satisfying zero-force slip fit, but with the bearings it really doesn't matter much. The main mechanical problem I ran into was not leaving any clearance for the rounded-off linkage ends to the inside surface of the motor mounting blocks. This led to a bit of binding that I thought was due to frame alignment issues but in fact was easily solved with a belt sander.

By virtue of careful design and forethought complete luck, I actually mitigated one of the biggest deficiencies of Twitch X over Twitch, Jr., the relative difficulty of changing out wheels. As it turns out, because of the way wheel closeouts are shaped, it's just barely possible to put on and take off a wheel without removing the top and bottom plates. This is a huge win because the top and bottom plates have the most hardware, the trickiest alignment, and are attached to the two linkage position-sensing potentiometers (so, taking them off would usually require re-calibration).

You might also notice the magnetic hubs. More on these in a later post, I think.

It's also possible to access most of the linkage shoulder screws from the wheel wells by rotating the linkages to different positions, so if one comes loose it doesn't necessarily require taking the whole robot apart to fix it. The center of the robot is also relatively accessible (for adjusting a linkage pot or soldering a motor lead, for example) thanks to the lack of giant servos in the middle and the fact that the battery and controller are outside of the central section.

It's so...empty.
The Mystery of the Sin/Cos Link

Where the two servos would be are just two potentiometers, one attached to each diagonal linkage. In Twitch, Jr., the diagonal linkages are independent, but in order for servoless linkage drive to work, they need to be tied together (to reduce the total number of degrees of freedom to four). I was a bit naive in naming the link that ties them together the sin/cos link, thinking that it just caused one to sweep out asin(x) while the other swept out acos(1-x), or something like that. The actual trajectory is not that simple.

If you can figure out the function f, you will win a cookie.

In what might be a first for this blog, I actually don't have an analytical solution for it. I'm sure one exists, but I think it would be a messy bit of trig. Through some random guesswork and not wanting to rename the linkage, I found that the following parameterization is very nearly perfect:
x = [sin(θ1)]^K = 1 - [cos(θ2)]^K
The exponent K is determined by the geometry of the linkage and can be found by fitting to CAD-solved angles. For Twitch X, it's somewhere around 1.23456789. (I'm not joking.) You can have an extra cookie if you can explain this parameterization and how the exponent can be derived from the geometry. I actually haven't worked this out. (For the purpose of verification, L1 = 1.00in and L3 = 7.50in on Twitch X.)


The parameter x is actually extremely convenient for controlling the linkage degree of freedom. It's easy to measure θ1 and θ2 using the pots, but it would be awkward to control one or the other. As the linkage sweeps through its range of motion, the sensitivity of the two angles to wheel rotation changes. Near the ends of travel, one angle is barely changing. By converting both angles to x and taking a weighted average based on the sensitivity, which is itself a function of x, a much better control variable is made available, one that ranges from 0.0 to 1.0 as the linkage degree of freedom sweeps from full forward to full sideways.

One other really nice thing about the parameter x is that at 0.5, the wheels are perpendicular. This is true for any exponent K. This gives a simple target for the linkage controller to get into the traditional diamond-layout omnidirectional drive configuration. Because of the weird geometry, the wheels are not at 45º angles to the chassis in this mode the way they were on Twitch, Jr. But, they are perpendicular to each other, which is the necessary condition for properly-constrained driving with four omniwheels. The driving coordinate system is actually rotated about 10º from the chassis at this point.

At x = 0.5, any exponent will give a linkage angle sum of 90º...very convenient.

I was mistaken in my last post when I said that it was possible to write a continuous mixer for all the in-between states that aren't linkage angle sums of {0º, 90º, 180º}, corresponding to the {forward, omni, sideways} driving. As it turns out these are all over-constrained and don't have a roll-without-slipping solution for wheel rotational velocity. (And I'm not talking about sideways slipping, I mean true tangential slipping.) So, I used a three-state mixer similar to Twitch, Jr. to handle the three driving modes. The pot-derived x parameter determines which state it's in. 

Twitch Drive

The quad H-bridge board I designed for Twitch came in and went together pretty easily.



I don't know yet if it's worthy of being it's own separate thing, but I really do like the layout and the modularity of the design. Besides the four H-bridges, there's some power conversion, an STM32F3 microcontroller, an MPU-6050 IMU, and headers for an XBee. The optocoupled gate drive works the same way it always does: without any drama.

Mmmmm, free deadtime.
The main issues I had were with relatively low-quality boards causing some soldering mishaps requiring blue wire micro-surgery. I've already ordered some spares from my absolute favorite board place, OSHPark, so if this one eventually dies I have some really nice ones to replace it. The board doesn't quite fit the way I wanted it to in the front wedge. It was supposed to mount vertically, but the capacitors and wiring take up too much space. I spent several hours trying to figure out how to modify the chassis to fit it either vertically or horizontally before I realized that I don't have to do either...

Yes, I felt stupid.
Since I'm only using the vertical gyro anyway, it doesn't matter which way the board is oriented. The extra trig just goes into the rotation controller's gain scaling anyway. Also, this mounting allows me to put some padding around the board to protect against impacts and vibration a bit more. The batteries will still go in the opposite wedge, and all the wiring runs in a tidy channel down the middle of the bottom plate.

Control and Controllers

As I mentioned, Twitch X has four degrees of freedom, all of which can be controlled independently by the four actuators. The "mixer" handles assigning wheel velocities based on the outputs of four degree of freedom controllers. In general, all four wheels are involved in each degree of freedom:

Driving forward and turning are the obvious ones and are the same as any other 4WD "tank steer" or "skid steer" robot. Driving sideways requires that the linkage be moved to the sideways position and then it's the same as driving forward (although two of the wheels have reversed their "forward" direction). Omnidirectional drive in the x = 0.5 "diamond" state also has a well-known mixer. The last degree of freedom is moving the linkage itself. This is accomplished by driving pairs of wheels against each other. (Which pairs depends on which way you want the linkage to move.)

Might help picture it...

Forward and sideways translation are easy enough to control manually, so the mixer just forwards commands for these directly to the correct wheels, depending on the linkage position. The other two degrees of freedom are much better handled by a closed-loop controller. For rotation, the vertical gyro is used in a feedback loop to control an exact rate of rotation, commanded by the driver. This helps keep the bot straight even if the wheels slip a little, and is crucial to this type of drivetrain. Likewise, the linkage degree of freedom is feedback-controlled off of the x parameter, as measured by the two potentiometers.

Everyone asks what the operator interface is like - I use a Playstation 4 controller with the following layout:


I don't know why I chose this layout originally, but I've been training on it since Twitch, Jr. and have the maneuvers all in muscle memory. The coolest tricks are ones involving all four degrees of freedom at the same time, like Translation While axis swITCHing, where the bot travels in a straight line but rotates and changes linkage orientations on the fly.

There are still some improvements to be made - I haven't gotten around to finishing the magnetic wheel hubs yet or really tying down all the loose parts and getting it ready to take abuse. But I also enjoy driving robots even more so than I do building them, so I couldn't resist doing some test drives of the new servoless system as soon as it was functional.

4 comments:

  1. Hi, really like the look of the Twitch Drive (and all your other motor controllers) I was wondering if you would publish the design files like you have before.

    Currently all the google drive links are down and have been for a while. I'd love to download some of them.

    Thanks and keep up the good work!

    ReplyDelete
    Replies
    1. Yep, Google Drive disabled hosting. I've moved stuff over to Amazon S3. Here's a temporary listing: https://scolton-www.s3.amazonaws.com/list.html. And here's the Twitch Drive files specifically: https://s3.amazonaws.com/scolton-www/motordrive/BT_V1_0.zip. It's been working well, but it is a v1.0 so it's not quite as well-tested as some of my other drives.

      Delete
  2. Just found your site and I'm both fascinated and impressed! I found you while looking into the Complimentary Filter and IMUs. I'd love to read your papers, but as Steven Richardson mentions, the google drive links are 404s! Hopefully, you'll fix them soon.

    ReplyDelete
    Replies
    1. Yes unfortunately Google Drive disabled hosting and killed all my links. :( I've moved stuff over to Amazon S3. Haven't sorted it all out and updated links on this site yet but here's a temporary listing: https://scolton-www.s3.amazonaws.com/list.html.

      Delete