User Tools

Site Tools


marvin:ecp3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
marvin:ecp3 [2009/01/28 21:30] devamarvin:ecp3 [2009/01/28 23:16] deva
Line 11: Line 11:
 =====Project Goal===== =====Project Goal=====
 Make robot able to drive a predefined pattern. Make robot able to drive a predefined pattern.
 + 
 =====Plan===== =====Plan=====
   * Create a Motor Control class that can append extra power to the motors individually to control how the robot is behaving.   * Create a Motor Control class that can append extra power to the motors individually to control how the robot is behaving.
  
-====The Motor in Theory====+=====The Motor in Theory=====
 === DC Motor Drives === === DC Motor Drives ===
 {{ :marvin:motor.png |The NXT DC Motor}} {{ :marvin:motor.png |The NXT DC Motor}}
Line 27: Line 27:
  
 === Power Electronic Converter === === Power Electronic Converter ===
-We see that the four quadrant refers to the four combinations of voltage and current directions. As mentioned the motor is actually transferring energy back to the supply when breaking and this requires special attention when designing a motor controller. In order to control the DC motor a Power Electric Converter (PEC) that satisfies the following conditions is needed. ((Power Electronics, Mohan, Undeland and Robbins, Wiley, ISBN 0-471-22693-9))+We see that the four quadrants refers to the four combinations of voltage and current directions. As mentioned the motor is actually transferring energy back to the supply when breaking and this requires special attention when designing a motor controller. In order to control the DC motor a Power Electric Converter (PEC) that satisfies the following conditions is needed. ((Power Electronics, Mohan, Undeland and Robbins, Wiley, ISBN 0-471-22693-9))
   * The converter must allow both output voltage and current to reverse in order to yield a four-quadrant operation.    * The converter must allow both output voltage and current to reverse in order to yield a four-quadrant operation. 
   * For accurate control of position, the average voltage output of the converter should vary linearly with its control input, independent of the load on the motor.   * For accurate control of position, the average voltage output of the converter should vary linearly with its control input, independent of the load on the motor.
Line 44: Line 44:
  
 === Motor Encoder/Tacho Counter === === Motor Encoder/Tacho Counter ===
-When designing the motors, wheels and drive train, it will almost always be important to have some sort of encoder feedback. In the Lejos framework there are methods to get readings from the tacho counters and these sensor readings have proven to be very useful when designing a balancing robot cf. the research literature in the [[marvin:ecp0|introduction]]. In order to illustrate the concept of an encoder we use this simple set-up, which is explained in the excellent SRS Encoder article by David Anderson((http://www.seattlerobotics.org/encoder/200109/dpa.html)). Imagine a DC motor without an encoder which is illustrated in the top of the figure. If we mount a circular image with a pattern determining our resolution, we can use a simple IR transceiver to get readings back to our micro controller or signal processing unit. In the Lego Mindstorm kit(([[http://mindstorms.lego.com/overview/]])) each motor has a built-in Rotation Sensor. This allows us to control the robot’s movements quite accurate. The Rotation Sensor measures motor rotations in degrees or full rotations [accuracy of +/- one degree]. One rotation is equal to 360 degrees, so if we set a motor to turn 180 degrees, its output shaft will make half a turn. This allows us to evaluate both the body angle and angle velocity of the balancing robot by means of simple differentiation, which is explained in one of the following sections. +When designing the motors, wheels and drive train, it will almost always be important to have some sort of encoder feedback. In the LeJOS framework there are methods to get readings from the tacho counters and these sensor readings have proven to be very useful when designing a balancing robot cf. the research literature in the [[http://wiki.aasimon.org/doku.php?id=marvin:ecp0|introduction]]. In order to illustrate the concept of an encoder we use this simple set-up, which is explained in the excellent SRS Encoder article by David Anderson((http://www.seattlerobotics.org/encoder/200109/dpa.html)). Imagine a DC motor without an encoder which is illustrated in the top of the figure. If we mount a circular image with a pattern determining our resolution, we can use a simple IR transceiver to get readings back to our micro controller or signal processing unit. In the LEGO Mindstorm kit(([[http://mindstorms.lego.com/overview/]])) each motor has a built-in Rotation Sensor. This allows us to control the robot’s movements quite accurate. The Rotation Sensor measures motor rotations in degrees or full rotations [accuracy of +/- one degree]. One rotation is equal to 360 degrees, so if we set a motor to turn 180 degrees, its output shaft will make half a turn. This allows us to evaluate both the body angle and angle velocity of the balancing robot by means of simple differentiation, which is explained in one of the following sections. 
  
 {{ :marvin:ecoder.jpg?300 |Principle of TACHO Encoder}} {{ :marvin:ecoder.jpg?300 |Principle of TACHO Encoder}}
Line 50: Line 50:
 =====Driving the Robot===== =====Driving the Robot=====
 ====Right/Left Steering==== ====Right/Left Steering====
- +Now that the robot is balancing it ought to be simple to make it drive around. We expect the controller to maintain its balance even though we apply the necessary offset to the PWM in order to make it move. At first we added a small offset to one wheel and subtracted from the other, which caused the robot to drive in a circle. The robot actually seemed to be more robust when turning and we were able to reach a high speeds when pivoting "on the spot".  Maybe this has to do with the angular momentum that is being build up when turning on the spot - similar to the ice skater doing a pirouette. Also we reduce the slip in the motor by keeping the robot rotating. This can be seen on the following video\\
-Now that the robot is balancing it ought to be simple to make it drive around. We expect the controller to maintain its balance even though we apply the necessary offset to the PWM in order to make it move. At first we added a small offset to one wheel and subtracted from the other, which caused the robot to drive in a circle. The robot actually seemed to be more robust when turning and we were able to reach a high speed when doing a circle “on the spot.  Maybe this has to do with the angular momentum that is being build up when turning on the spot - similar to the ice skater doing a pirouette. Also we reduce the slip in the motor by keeping the robot rotating. This can be seen on the following video\\+
  
 [[http://www.youtube.com/watch?v=g85cqFHozUQ|{{:marvin:p_lab3_spn.jpg?255x210}}]] [[http://www.youtube.com/watch?v=g85cqFHozUQ|{{:marvin:p_lab3_spn.jpg?255x210}}]]
 {{youtube>g85cqFHozUQ?small}} {{youtube>g85cqFHozUQ?small}}
  
-As you may have noticed on the video we did also change the tires. The tires in the original model had a course pattern and this caused it to get stuck on the carpet and so the robot did not behave equally on both carpets and slippery surfaces. By changing to a very flat tire we experienced more similar behaviours on different surfaces and this made the tuning of the parameters in the control loop a bit easier. +As you may have noticed on the video we did also change the tires. The tires in the original model had a course pattern and this caused it to get stuck on the carpet and so the robot did not behave equally on both carpets and hard surfaces. By changing to a very flat and smooth tire we experienced more similar behaviours on different surfaces and this made the tuning of the parameters in the control loop a bit easier. 
  
 ====Forward/Backward Motion==== ====Forward/Backward Motion====
Line 62: Line 61:
 {{ :marvin:p_lab2_pid2.png?400 |The Closed Loop including PID Controller}} {{ :marvin:p_lab2_pid2.png?400 |The Closed Loop including PID Controller}}
  
-If we apply an offset to both wheels we are removing control from the controller and disturbing the calculated error. Either the control loop will overcome this disturbance by some minor oscillations or it will become unstable as we are really adding to the overshoot. This does not happen when we add a small offset to one wheel and subtract from the other since this does not affect the overall error signal. The natural place to control a closed loop control is of course the reference values, which are applied for each state. The reason that we did not use this approach immediately is probably that the reference values have been left unused as we want all the states to be zero in order for the robot to remain in equilibrium. If a small offset is added to the tilt angle (psi) the robot must remain in motion to stay balanced. Although the robot is capable of moving forward and backward it showed an undesired tendency to oscillate between forward and backward commands. As the contra steering used to turn the robot did seem to stabilize the robot, it seemed important to make the robot occupied in between commands by adding a small amount of contra steering. This will keep the motors busy and reduce the slip when the motors are changing from forward to backward motion simultaneously. We used a sine function to add a small offset to one wheel and subtract from the other as the sine function overall should make the robot remain in the same position - also we can quite easily alter the amount of offset. The real benefit from this is due to high amount of slip in the motors in the instant where they are not active. Beforethis slip would point in the same direction, but with the small contra steering it actually points in separate directions, hence stabilizing the robot.    +If we apply an offset to both wheels we are removing control from the controller and disturbing the calculated error. Either the control loop will overcome this disturbance by some minor oscillations or it will become unstable as we are really adding to the overshoot. This does not happen when we add a small offset to one wheel and subtract from the other since this does not affect the overall error signal. The natural place to control a closed loop control is of course the reference values, which are applied for each state. The reason that we did not use this approach immediately is probably that the reference values have been left unused as we want all the states to be zero in order for the robot to remain in equilibrium. If a small offset is added to the tilt angle (<latex>\Psi</latex><texit>$\Psi$</texit>) the robot must remain in motion to stay balanced. Although the robot is capable of moving forward and backward it showed an undesired tendency to oscillate between forward and backward commands. As the contra steering used to turn the robot did seem to stabilize the robot, it seemed important to make the robot occupied in between commands by adding a small amount of contra steering. This will keep the motors busy and reduce the slip when the motors are changing from forward to backward motion simultaneously. We used a sine function to add a small offset to one wheel and subtract from the other as the sine function overall should make the robot remain in the same position. The real benefit from this can be found in the high amount of slip in the motors in the instant where they are not active. Without the sine offsetthe slip would point in the same direction, but with the small contra steering it actually points in separate directions, hence stabilizing the robot.\\ 
-Using this approach we are now able to control the robot as expected, thus we are able to make the robot drive a predefined pattern. It is important to mention that the robot still has a tendency to oscillate, which often requires the control loop to "interrupt" the desired motion causing the robot to move unexpected. Therefore the the robot is not able to drive according to the navigation class, but it is satisfactory in order to implement a behaviour control model. The goal of this lab session was to make Marvin capable of driving a predefined pattern, but we did not specify anything about the accuracy of its position or which type of pattern. We are currently satisfied with the progress and we find the result satisfactory with respect to the next lab session in which we shall implement the behaviour based control model.   +Using this approach we are now able to control the robot as expected, thus we are able to make the robot drive a predefined pattern. It is important to mention that the robot still has a tendency to oscillate, which often requires the control loop to "interrupt" the desired motion causing the robot to move unexpected. Therefore the the robot is not able to drive according to the navigation class, but it is satisfactory in order to implement a behaviour control model.\\ 
 +The goal of this lab session was to make Marvin capable of driving a predefined pattern, but we did not specify anything about the accuracy of its position or which type of pattern. We are currently satisfied with the progress and we find the result satisfactory with respect to the next lab session in which we shall implement the behaviour based control model.  
  
 ====Gyroscope Offset Drift Problem==== ====Gyroscope Offset Drift Problem====
-Easy as it seems, we did not arrive at the goal easily. We had a very annoying problem, with the gyroscope offset drifting when the robot was not standing still balancing.\\ +Easy as it seems, we did not arrive at the goal without bumps. We had a very annoying problem, where the gyroscope offset was drifting whenever the robot was not standing still in equilibrium (i.e. driving somewhere).\\ 
-The offset seemed to drift in the direction of the angle, and the larger the angle, the faster the drift.\\ +The offset seemed to drift in the direction of the angle (and thereby driving direction), and the larger the angle, the faster the drifting.\\ 
-We tried several solutions to the problem, in the following they will be drafted, together with the reason that they did not work:\\ +We tried several solutions to the problem, in the following they will be outlined, together with the reasons for why they did not work (apart from the last one which in fact worked):\\ 
-  * The first approach was based on the fact that when the robot was in perfect balance (the angle velocities were below a threshold for some amount of time) we could determine the angle to be zero, thus reset it. This however would make the robot reset its zero angle at a position //not// zero (it would lean forward but stay in that angle for duration of its forward movement)+  * The first approach was based on the fact that when the robot was in perfect balance (the angle velocities were below a threshold for some amount of time) we could redefine the angle as zero, thus reset the gyroscope angle. This however would make the robot reset its angle at a position //not// vertical whenever driving forwardfor some period of time long enough to exceed the threshold buffer length
-  * When the angle offset had reached a certain level, the robot continuously tried to straighten up, resulting in the wheels spinning up to maximum in the opposite direction. Based on this observation, we tried to detect when the wheels were driving above a threshold, and thereafter adjust the offset angle towards the thought actual zero. This did not seem to fix the problem at all, since the time we detected the large offset, was way too late.+  * Second we used the fact that when the angle offset had reached a certain level, the robot continuously tried to straighten up, resulting in the wheels spinning up to maximum in the opposite direction. Based on this observation, we tried to detect when the wheels were driving above a threshold, and thereafter adjust the offset angle towards the thought actual zero. This did not seem to fix the problem at all, since the time we detected the large offset, was way too late.
   * Next we tried to calculate the drift size by multiplying the angle with some constant. We tried to adjust this constant for a long time, with a lot of measurements, but all in vein. If the drift size could be calculated as a function of the angle, it was certainly not a linear function.   * Next we tried to calculate the drift size by multiplying the angle with some constant. We tried to adjust this constant for a long time, with a lot of measurements, but all in vein. If the drift size could be calculated as a function of the angle, it was certainly not a linear function.
   * We had read somewhere that there might be a problem with the ADC based on its reference voltage, due to drop in battery level. This lead to an attempt to calculate the drift size based on the current battery level measured against the initial battery level. This however did not seem to be the way to things either, since the battery level dropped faster than the drift size would grow.   * We had read somewhere that there might be a problem with the ADC based on its reference voltage, due to drop in battery level. This lead to an attempt to calculate the drift size based on the current battery level measured against the initial battery level. This however did not seem to be the way to things either, since the battery level dropped faster than the drift size would grow.
marvin/ecp3.txt · Last modified: 2009/01/29 11:01 by rieper