by DerekZahn » Sat Feb 10, 2007 5:25 pm
by DerekZahn
Sat Feb 10, 2007 5:25 pm
I decided to keep posting progress reports because some of you might find this phase of development to be interesting.
Enough of the software is working so that I can start to do some things with the robot. I have "calibrated" the servos so that I can work with joint angles inside the software, and this allowed me to define a hardcoded standing "neutral pose". On powerup, the joint positions are approximated from the feedback voltages (the wires I soldered to the potentiometers on all the servos), and over the course of one second, Bing transitions to the neutral pose so it will remain standing.
bigger:
http://happyrobots.com/bing3w2.jpg
Notice the wires coming out of the shoulder. For the first few months of its life, Bing will operate on this tether, which contains an external power source so I don't have to charge the battery all the time and for a fast reliable serial data connection. The wire bundle goes up to the end of a long piece of flexible steel springy wire (like a coat hanger wire) which allows the cables to go straight up no matter whether Bing is standing or lying down, without being under much tension at all.
For the power connector, I took an idea from Combat "robots". I use a four prong receptacle, which lets me plug different things in for different functions:
With nothing plugged in, Bing is dormant because nothing is attached to the power. The top scenario is a plug that is an internal power switch like would be used at a competition or for an untethered run about the house. The middle scenario is the tethered operation with an external power supply. And the bottom plug would be used to recharge the internal battery.
124 days to go until RoboGames (competitions and the deadlines they bring with them add a little excitement and motivation to hobbies I think). I have some time to just play around with things... in particular, I want to start playing around with the sensors.
Here's an experiment I'm working on right now... To start thinking about balance, I poke Bing in the chest while it's standing still, causing it to rock backwards about 5 degrees. Here's a graph of some sensor data:
To me, this stuff is really interesting and I'm having great fun looking at graphs like these. The total time of the data graph is about 10 seconds.
The blue line labeled "FB" adds up the sensor readings from all four of the pressure sensors at the front of both feet, then subtracts the readings from the backs of the feet, so it will have a positive value when the robot is leaning forward, and a negative value when the robot leans backward.
The green line labeled "Accel" is the accelerometer that is sensitive to tilts and accelerations forward/backward.
The Red line labeled "Gyro" is the gyro sensitive to rotations in the forward/backward direction.
Although the accelerometer is sometimes called a "tilt" sensor because tilting it will change its reading, it is not good at measuring tilt in a dynamic situation. Looking at the green line in the graph, you can see that the acceleration caused by me poking Bing's chest overwhelms the initial movement backwards and the graph value actually goes up. Then when the robot rocks back forward again, the accelerometer reports this new acceleration. Those accelerations are very interesting but they do not help estimate tilt angle and in a situation like this, the accelerometer is pretty much useless for determining tilt, but when the bot is still it is a very accurate tilt measurement.
The red Gyro line best shows the oscillations that the robot goes through as it rocks backwards, then forwards, then backwards again, settling down pretty quickly to standing straight up again.
The black line is the beginning of a (rather standard) approach to computing the actual tilt. The idea is to "integrate" the gyro reading to estimate the tilt angle. That sounds mathematically fancy but it's actually pretty simple. I measured a "steady" reading of 248 from the gyro while it's standing still. All I have to do is measure the difference between the current gyro reading and 248 to get the current rotation rate. Then just keep a running total of those numbers. As you can see from the black line in the graph, it gives a pretty nice tilt response. However, if you look closely you can tell that the whole black line is slowly drifting upwards over time. There are several factors that cause this. First, this integration assumes that the rotation rate is the same for the entire period between readings (about 13 milliseconds in this case). That is actually not quite true, though it's pretty close to being true. Second, the steady value of 248 is not completely accurate. Suppose that the actual real world value is 247.5. Then each sample, an error of 0.5 would be added to the sum and over time those errors add up. That's the major cause of the long term drift. Also, noise in the sensor and my electronic circuits plus some lowpass filtering that I do in my electronics all cause errors to creep in.
The solution to this that people usually use is to move the tilt reading toward the accelerometer's estimate of the tilt by just a little bit each cycle. In the short term, the fluctuations caused by accelerations won't cause much damage to the estimate because it's only a small variation. In the long term, as long as the "little bit" of correction is larger than the long-term drift, in the long run the tilt estimate will be pretty close to accurate. I think I'll play with that next, which requires a bunch more calibration to get right. When that's done, I'll have a "tilt angle" measurement that I can use in the software.
Fun stuff. Kind of a lot of text to read but hopefully interesting to somebody. None of this is original to me, I think this method of using a gyro and an accelerometer together is a pretty normal simple-minded approach for coding an IMU.
I decided to keep posting progress reports because some of you might find this phase of development to be interesting.
Enough of the software is working so that I can start to do some things with the robot. I have "calibrated" the servos so that I can work with joint angles inside the software, and this allowed me to define a hardcoded standing "neutral pose". On powerup, the joint positions are approximated from the feedback voltages (the wires I soldered to the potentiometers on all the servos), and over the course of one second, Bing transitions to the neutral pose so it will remain standing.
bigger:
http://happyrobots.com/bing3w2.jpg
Notice the wires coming out of the shoulder. For the first few months of its life, Bing will operate on this tether, which contains an external power source so I don't have to charge the battery all the time and for a fast reliable serial data connection. The wire bundle goes up to the end of a long piece of flexible steel springy wire (like a coat hanger wire) which allows the cables to go straight up no matter whether Bing is standing or lying down, without being under much tension at all.
For the power connector, I took an idea from Combat "robots". I use a four prong receptacle, which lets me plug different things in for different functions:
With nothing plugged in, Bing is dormant because nothing is attached to the power. The top scenario is a plug that is an internal power switch like would be used at a competition or for an untethered run about the house. The middle scenario is the tethered operation with an external power supply. And the bottom plug would be used to recharge the internal battery.
124 days to go until RoboGames (competitions and the deadlines they bring with them add a little excitement and motivation to hobbies I think). I have some time to just play around with things... in particular, I want to start playing around with the sensors.
Here's an experiment I'm working on right now... To start thinking about balance, I poke Bing in the chest while it's standing still, causing it to rock backwards about 5 degrees. Here's a graph of some sensor data:
To me, this stuff is really interesting and I'm having great fun looking at graphs like these. The total time of the data graph is about 10 seconds.
The blue line labeled "FB" adds up the sensor readings from all four of the pressure sensors at the front of both feet, then subtracts the readings from the backs of the feet, so it will have a positive value when the robot is leaning forward, and a negative value when the robot leans backward.
The green line labeled "Accel" is the accelerometer that is sensitive to tilts and accelerations forward/backward.
The Red line labeled "Gyro" is the gyro sensitive to rotations in the forward/backward direction.
Although the accelerometer is sometimes called a "tilt" sensor because tilting it will change its reading, it is not good at measuring tilt in a dynamic situation. Looking at the green line in the graph, you can see that the acceleration caused by me poking Bing's chest overwhelms the initial movement backwards and the graph value actually goes up. Then when the robot rocks back forward again, the accelerometer reports this new acceleration. Those accelerations are very interesting but they do not help estimate tilt angle and in a situation like this, the accelerometer is pretty much useless for determining tilt, but when the bot is still it is a very accurate tilt measurement.
The red Gyro line best shows the oscillations that the robot goes through as it rocks backwards, then forwards, then backwards again, settling down pretty quickly to standing straight up again.
The black line is the beginning of a (rather standard) approach to computing the actual tilt. The idea is to "integrate" the gyro reading to estimate the tilt angle. That sounds mathematically fancy but it's actually pretty simple. I measured a "steady" reading of 248 from the gyro while it's standing still. All I have to do is measure the difference between the current gyro reading and 248 to get the current rotation rate. Then just keep a running total of those numbers. As you can see from the black line in the graph, it gives a pretty nice tilt response. However, if you look closely you can tell that the whole black line is slowly drifting upwards over time. There are several factors that cause this. First, this integration assumes that the rotation rate is the same for the entire period between readings (about 13 milliseconds in this case). That is actually not quite true, though it's pretty close to being true. Second, the steady value of 248 is not completely accurate. Suppose that the actual real world value is 247.5. Then each sample, an error of 0.5 would be added to the sum and over time those errors add up. That's the major cause of the long term drift. Also, noise in the sensor and my electronic circuits plus some lowpass filtering that I do in my electronics all cause errors to creep in.
The solution to this that people usually use is to move the tilt reading toward the accelerometer's estimate of the tilt by just a little bit each cycle. In the short term, the fluctuations caused by accelerations won't cause much damage to the estimate because it's only a small variation. In the long term, as long as the "little bit" of correction is larger than the long-term drift, in the long run the tilt estimate will be pretty close to accurate. I think I'll play with that next, which requires a bunch more calibration to get right. When that's done, I'll have a "tilt angle" measurement that I can use in the software.
Fun stuff. Kind of a lot of text to read but hopefully interesting to somebody. None of this is original to me, I think this method of using a gyro and an accelerometer together is a pretty normal simple-minded approach for coding an IMU.