... | ... | @@ -75,7 +75,7 @@ int pid_val = (int)(kp * error + ki * int_error + kd * deriv_error) / scale; |
|
|
```
|
|
|
##### Code Snippet 3[8,9]
|
|
|
|
|
|
**Parameters:**
|
|
|
#### Parameters:
|
|
|
We have found our PID values without complex math as mentioned in [4], meaning that we have used trial and error until we found the best value for the different parameters. We have further looked at the tuning of these in relation to Table 1[10], that states the effects of increasing parameters independently. The best values we found was Kp=400, Ki=0, Kd=600 (remember we scale the values by 100), these gave the best balance although only for a few seconds as seen in Video 1[5]. We found it difficult to tune the Ki parameter, and every time we increased this by more than 1 the robot acceleration became too big and it overshot and crashed. The best value for Ki we found was 0.01 (1), and an example of this can be seen in Video 2[6] where we used Kp=400, Ki=1, Kd=600 as parameters.
|
|
|
|
|
|
We further tried to scale all the values to Kp=800, Ki=200, Kd=1600, but this resulted in a even worse result as seen in Video 3[7]. Lastly, we tried even more tuning, but eventually stopped when realising that is was almost impossible for the robot to be self-balancing by the use of the light sensor only.
|
... | ... | @@ -152,3 +152,102 @@ We used light for the angel experiment. Here the light source came from the phon |
|
|
### Conclusion
|
|
|
Our obtained results indicates that the color sensor worked better than the light sensor. The robot did not work at all when using the light sensor but worked very well with the color sensor. We cannot say exactly why, but discussed several options such as, there might be better technology in the color sensor, and could be faster when updating to the NXT. Another more plausible possibility is that the color sensor is less disturbed by light and shadows. We further saw that the robot could balance for about 10 second on a non-planar surface, and it wasn’t so sensitive to surface color and texture when it was non-planar. The best PID values we found for the color sensor was Kp=300, Ki=20, Kd=1000 with an overall scale of 100. which resulted in the robot staying in balance for at least 15 seconds.
|
|
|
|
|
|
## Self-balancing robots with gyro sensor
|
|
|
|
|
|
![RobotMedGyro](http://gitlab.au.dk/uploads/u4099/legolabtimadala/a6f8beec17/RobotMedGyro.png)
|
|
|
##### Picture 5: Robot setup with GYRO sensor attached. Design inspired by [3].
|
|
|
|
|
|
### Results
|
|
|
Below is shown a Video of our end result when experimenting with the self-balancing robot that uses a gyro sensor.
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/?????/0.jpg)](http://www.youtube.com/watch?v=??????)
|
|
|
##### Video 7: Self-balancing robot with gyro sensor
|
|
|
|
|
|
In the last experiment we got the robot to work and balance by itself (until the battery runs out), as seen in Video 7. It also worked even when we gave it a little push. After trying a lot of different parameters we finally found the ones that gave a good result. In the sections below you will comments on how we achieved the result.
|
|
|
|
|
|
[![image alt text](http://img.youtube.com/vi/ixAGPc9juyo/0.jpg)](http://www.youtube.com/watch?v=ixAGPc9juyo)
|
|
|
##### Video 6: Self-balancing robot with gyro sensor - Drifting
|
|
|
|
|
|
In most of the experiments with the gyro sensor we had a big problem with drifting. When executing the program it almost instantly started drifting and therefore we tried to change the code to use different parameters. This did not make the robot balance perfectly and we ended up not being able to find an solution to this problem. This was a problem for many other groups, so we did the best we could to make a self-balancing robot with the gyro sensor and even when we tried to use some of the same variables from the other groups it would still not work.
|
|
|
|
|
|
Another problem when running the program on the NXT was, as seen in video 6, that the offset kept changing by itself. This resulted in that the robot began to lean forward by itself and could not find a balancing offset afterwards. We tried to erase the offset from the code and place it on the table, but still, the offset kept moving forwards, ultimately causing the robot to fall.
|
|
|
|
|
|
#### Gyro tests:
|
|
|
We tested the gyro sensor and its capabilities to get a better understanding of how it works. Three tests were performed, respectively; stationary gyro sensor without motors running, movement of gyro sensor without motors running, stationary gyro sensor with motors running. The gyroscopic sensor was on placed on the robot as seen in Picture 5.
|
|
|
|
|
|
![NoMotorStationary](http://gitlab.au.dk/uploads/u4099/legolabtimadala/700f6bfd26/NoMotorStationary.png)
|
|
|
#####Graph 1: Stationary gyro sensor without motors running.
|
|
|
|
|
|
In the first test, the gyroscopic sensor was laying still with no running motors. We hoped that this would give us a more steady offset, because that the voltage for the NXT would not change.
|
|
|
|
|
|
Graph 1 shows us that the median for the gyro sensors data is about 603, and differs between +- 2. By looking at this you get a good idea about what the gyro’s offset state is, since it is laying flat with no other movement and no motors running. However, there are some factors that could be in in play here, eg. [16] states that the gyro has to be warm for proper readings. They further mentions that the power level of the battery also plays as a factor, as well as the voltage of the NXT when the motors are running.
|
|
|
|
|
|
In the next test no motors were running, and the gyroscope was moved was along with the robot in a forward, backward, backward and then forward movement pattern. We were trying mimic the behavior of the robot when correcting itself so it would balance again.
|
|
|
|
|
|
![NoMotorMovementPS copy](http://gitlab.au.dk/uploads/u4099/legolabtimadala/56c2b7b1e5/NoMotorMovementPS_copy.png)
|
|
|
#####Graph 2: Movement of gyro sensor without motors running.
|
|
|
|
|
|
As given in Graph 2, we see in general that the gyro values for the different movement patterns is the same. However, there er is a difference in how high the values peak. This could be due to the force and intensity of the movement. Hence, if you compare the first forward movement with second, and the first backward movement with the second as well. All this gives us a good understanding of what the gyro registres in the use of a self-balancing context.
|
|
|
|
|
|
The last test that we conducted with the gyro sensor, was performed with motors running and the gyro being stationary. We were hoping to see if the running motors would interfere with the voltage of the NXT and by that add noise to the readings of the gyro, as [16] also mentions could be a factor of noise.
|
|
|
|
|
|
![MotorStationary copy](http://gitlab.au.dk/uploads/u4099/legolabtimadala/c6f5d86f50/MotorStationary_copy.png)
|
|
|
#####Graph 3: Stationary gyro sensor with motors running.
|
|
|
|
|
|
Graph 3 shows us that when the motors are running there are more peaks in the readings from the gyro, which tells us that the motors have an impact on the voltage of the NXT. It is further seen that there are places in which the offset remains between the same values as in Graph 1 even though the motors are running.
|
|
|
|
|
|
#### Implemented code:
|
|
|
The code we have implemented is a translation to Java from the program given in [17] written in NXC. The program was tweaked to follow our needs, eg. one of the things we removed was ability to steer the robot remotely. The entire program can be found in [19]
|
|
|
|
|
|
#### Parameters:
|
|
|
In the program we have tried to use different parameters to make robot balance. Secondly we changed aGyro to 24 and KsGyro= 2.9, keeping the other values at aPos = 0.12 and aSpeed = 0.035. This eliminated most of the drift, although, instead the robot moved aggressively forwards and backwards until it lost its balance after a few seconds. We kept the EMAOFFSET at 0.0005 as in the NXC code. Lastly, we made the robot keep its balance by using the parameters:
|
|
|
|
|
|
```
|
|
|
private double aGyro = 22;
|
|
|
private double KsGyro = 3.4;
|
|
|
private double aPos = 0.12;
|
|
|
private double aSpeed = 0.15 ;
|
|
|
private static final double EMAOFFSET = 0.0005;
|
|
|
```
|
|
|
##### Code Snippet 5[19]
|
|
|
|
|
|
Using these parameters the robot was able to keeps its balance for at least 2.5 minutes. Although, pushing it backwards or forwards made the robot fall to the ground[18].
|
|
|
|
|
|
### Discussion
|
|
|
In the beginning of the experiment when using the gyro sensor, we placed the sensor on the right side of the robots “body”, as seen in picture 5. After a couple of tries we observed that due to the construction of the robot the gyro Rider on the top of the segway was shaking, while the robot was moving. Because the gyro is placed on the rider we needed to rebuild the robot to make the gyro sensor more steady during the experiments. This should prevent the shaking of the rider and give us more stable gyro sensor data.
|
|
|
|
|
|
The gyro placement was changed during the experiments to see if that would help. We placed the sensor right above the right wheel as seen in picture 6, because we thought that the new setup would make the movements and the gyros “observations” more alike in the experiments. Thus we did not see any huge improvements.
|
|
|
|
|
|
![RobotGyroNyPlacement](http://gitlab.au.dk/uploads/u4099/legolabtimadala/b837884279/RobotGyroNyPlacement.png)
|
|
|
##### Picture 6: The new placement of the Gyro sensors
|
|
|
|
|
|
For making a better balancing robot we could try to combine the gyro sensor with the color sensor. By doing so we could perhaps prevent that the gyro sensor making the robot drift and then use the values from the color sensor to “help” the robot get back to the right offset where it can balance by itself.
|
|
|
|
|
|
### Conclusion
|
|
|
Because the gyro sensor tends to drift we had a lot of problems with the experimentation. We were not able to make the robot balance much in the exercise. We both tried to change the setup of the robot and also optimize the code, but neither helped much. Finally we had the robot balancing by itself by changing the parameters and thereby finding the best working ones.
|
|
|
|
|
|
### Overall Conclusion
|
|
|
In this paper we have tried to have a structured plan so we could compare the different experiments. We have also tried to explain, very thorough, all the parameters, conditions and results to make sure that the reader understands what we have been through in the excises.
|
|
|
|
|
|
During the different experiments with the different sensors. Our results shows us that the light sensor self-balancing robot is the hardest to function properly when trying to get the robot to balance as explained in the section about it. When we used the color sensor we had a good result and got the robot to balance for a while. Of course we had to make sure that there was certain conditions when making the tests, eg. the room was made dark to eliminate shadows and also the surface of which the robot was balancing on was white.
|
|
|
|
|
|
### References
|
|
|
. 1 Philippe Hurbain, [NXTway.](http://www.google.com/url?q=http%3A%2F%2Fwww.philohome.com%2Fnxtway%2Fnxtway.htm&sa=D&sntz=1&usg=AFQjCNFJTCBJMi-0uqllJZ_vcCI00VTV-w)
|
|
|
. 2 Brian Bagnall, [Maximum Lego NXTBuilding Robots with Java Brains](http://www.google.com/url?q=http%3A%2F%2Fwww.variantpress.com%2Fbooks%2Fmaximum-lego-nxt&sa=D&sntz=1&usg=AFQjCNFAZO_NBE_YEi1geQO9Ktc-OqN73A), Chapter 11, 243-284.
|
|
|
. 3 nxtprograms, [NXT Segway with Rider.](http://www.google.com/url?q=http%3A%2F%2Fwww.nxtprograms.com%2FNXT2%2Fsegway%2Findex.html&sa=D&sntz=1&usg=AFQjCNGoOn36rQsiVlwov_ssvG2pjIojxw)
|
|
|
. 4 [J. Sluka.] (http://www.inpharmix.com/jps/PID_Controller_For_Lego_Mindstorms_Robots.html)
|
|
|
. 5 [Video 1: Self-balancing robot with Light Sensor. ](https://www.youtube.com/watch?v=UJJ_rJSJfTQ&feature=youtu.be)
|
|
|
. 6 [Video 2: LSblance2.](https://www.youtube.com/watch?v=sJct-8HLV2g&feature=youtu.be)
|
|
|
. 7 [Video 3: LSbalance3.](https://www.youtube.com/watch?v=JA-F6hmOjjY&feature=youtu.be)
|
|
|
. 8 [LSBalance.java](https://www.dropbox.com/s/i1y0ae72a8n74d7/LSBalancer.java?dl=0)
|
|
|
. 9 [LSGUI.java](https://www.dropbox.com/s/40r1dotu0929jjd/LSGUI.java?dl=0)
|
|
|
. 10 [Table 1.](http://www.google.com/url?q=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FPID_controller&sa=D&sntz=1&usg=AFQjCNESubyf2PSUhSbBdAWAaVW9CbbZ4Q)
|
|
|
. 11 [Video 4: Self-balancing robot with Color Sensor]( http://youtu.be/UTHTnAUIhdY)
|
|
|
. 12 [CSBalance.java](https://www.dropbox.com/s/r5ny71grn54krnb/CSBalancer.java?dl=0)
|
|
|
. 13 [CSGUI.java](https://www.dropbox.com/s/zifs6kr09fivice/CSGUI.java?dl=0)
|
|
|
. 14 [Video 5: Self-balancing robot with Color Sensor - Non planar surface](http://youtu.be/m8RDj60D8wI)
|
|
|
. 15 [Video 6: Self-balancing robot with Gyro Sensor - Drifting.](http://youtu.be/ixAGPc9juyo)
|
|
|
. 16 [Gyro offset and drift.](https://nxttime.wordpress.com/2010/11/03/gyro-offset-and-drift/)
|
|
|
. 17 [HITechnic, HTWay - A Segway type robot.](http://www.hitechnic.com/blog/gyro-sensor/htway/)
|
|
|
. 18 [Video 7: Self-balancing robot with Gyro Sensor](http://youtu.be/tMFfdA_jq-Q)
|
|
|
. 19[GyroBalancer.java](https://www.dropbox.com/s/czmhcogplijwrqi/GyroBalancer.java?dl=0) |