chip updates: getting on with CMA and some terrain stuff [updates]
So now that we're kinda all setup down here in the basement with our new robolab, we can start working more on CMA since we actually have a place to work. But first, some cool photos of our new setup.
Before we get into actually doing CMA stuff, I do want to do a quick "code review" just to make sure the CMA algorithm is doing what we WANT it to do. Also, we realized last time that when we're lifting rear legs, we want CMA to shift the legs back even if we're stepping forward so we need to go change that.
So let's look over the code, see if we can see any glaring issues, and then try this out again!
Yea... we're just going to go for it. Here's the sequence of buttons:
(1) LB (stand)
(2) Y (change mode to test)
(3) LB (run test script)
IF IT GOES WRONG: hit RB quickly so we can go back to the standing position. OK here we go:
As we can see, this is what we call, not ideal. So I want to try this again with re-zeroing, I don't think we did a great job zeroing last time. What gave that away was the standing that was kinda strange.
Okay maybe one more time re-zeroing is going to be fine. This time it was too far back.
So here's the thing. I think what's happening is it just might be the different terrains we zero on. So the terrain offset for the garage/outdoors is 0 because that's what it's programmed for. The terrain offset for the basement is a little more. Let's program that in here.
This way we can calibrate different TERRAIN_OFFSETS for different terrains and then the platform this solves any calibration issues we might have with the platform.
So we need to do a little more work on this because depending on how we "zero" the leg this could happen.
So we need to ADD a NEGATIVE terrain offset if we pushed down too hard on the shoulder and add a POSITIVE to the knee. Which means what we're really trying to do is counter what is happening if we zero. If we push too hard the shoulder is more positive than we intended so we must add a negative offset. If we don't push hard enough we must add a positive offset.
Now let's relate this to the platform falling too far forward or backward so we can more intuitively set the terrain offset. If we push down too hard, the shoulder is farther than we meant it and the knee not enough so the platform will fall BACKWARD.
If the platform is falling too far forward: THE TERRAIN OFFSET IS POSITIVE If the platform is falling too far back: THE TERRAIN OFFSET IS NEGATIVE
Let's try it! We're going to start with a terrain offset of 0.0 for the current setup. And then we'll adjust.
And... somehow right now the zeroing is perfect and it's standing wonderfully. But we're going to try the terrain offsets to see if they work.
Let's start with a negative offsets which means it was too far back and it should fall more forward we'll do -1.0!
Forgot we need to add the offset to publish_cmds as well as the POS feedback so trajectory works. Let's try it now. This test will tell us how to set the above if forward is the offset +/- remember we're using -1.0!
OKAY SO with THIS CODE, using a -1.0 terrain offset MADE THE PLATFORM FALL BACKWARD. So what this means is if the platform is falling forward the TERRAIN OFFSET IS NEGATIVE.
If the platform is falling too far forward: THE TERRAIN OFFSET IS NEGATIVE If the platform is falling too far back: THE TERRAIN OFFSET IS POSITIVE
Here's the video proof:
Okay we set the terrain offset back to zero, which means we likely won't be having trouble with the platform for the next little while at least, and now we're ready to run our first few CMA tests when zeroing is OK.
So as you can see, the foot lifted off the ground just fine, but I do want it to not lean so much, so to counter that lean, we want to make the opposite leg retract a little more, and we're going to do that by increasing that reverse lean to 0.03. Here's what we mean:
We're also going to use CMA to go back to the home position so there's not really an ABORT here. Which might be risky but I think we can always switch to stand-sit mode worst-case.
So I think we're actually going to increase the opposite-foot-drop height to 0.05 and we're going to NOT use CMA when traveling back to center. Just GO back to CMA_CENTER like before. Let's try that.
Now as we can see the platform picked its foot up and put it down! We need to run this test on all four of the feet really quickly before we can determine CMA is ready to be used. The thing is, any discrepancies we're seeing can be solved by changing up the way we move the feet like we were saying earlier, move the shoulder then the knee when placing the foot down and the opposite when picking it up or something. But let's see if all four feet can lift first.
FL - CHECK | FR - CHECK | BL - NOPE | BR - NOT EVEN TRYING IT YET
So the back leg didn't lift up as planned. So what we're going to do is get rid of that - infant of the dX for the back, because I think that's taken care of in the math. Let's try it.
BL - NOPE | BR - NOT EVEN TRYING IT YET
That was even worse!!!! yay. So we need to try something else. Maybe we keep the negative and add a small offset for the rear because I know this platform is slightly back-heavy, especially in this zero position.
So let's try this. But even with that added - in the dX the feet are moving in the wrong direction. So let's get rid of the - again?
hmm so if we make dX + or -, the feet seem to move forward on this CoG thing?
So now what we're going to do is try this, where if we were lifting a front leg and then a rear one, what we're going to do is first TRANSFER the weight to the back of the robot or the FRONT of the robot then apply CMA. Otherwise we just use CMA. Who knows if it will work but let's try it!
Okay so this isn't working... Let's try something else, but yes, the issue is the weight transfer at least we've isolated that. I think we need to have a weight shift that actually determines if a weight shift is needed and then actually shifts the weight by moving the knee joints a few rotations in either direction from center. But let's make a quick test to see if this will even solve the problem.
Okay so that hasn't worked at all...
We have to think this through a little more. This ff thing is working for the front legs but it isn't working for the rear legs so we might need to come up with a new control strategy here.