... | @@ -26,15 +26,15 @@ Self-balancing robot with light sensor |
... | @@ -26,15 +26,15 @@ Self-balancing robot with light sensor |
|
|
|
|
|
##### Physical setup
|
|
##### Physical setup
|
|
|
|
|
|
For this exercise we used a LEGO model build according to the description in [2]. The robot includes two motors which is connected to port A and C due to port B/C being connected to the same H-bridge. A lightsensor is mounted on the lower part of the robot in a height of approximately 1.5 cm above the surface. In general it is a simple construction with a relatively high center of gravity which might affect the control mechanism. Our final model is shown in the following image.
|
|
For this exercise we used a LEGO model build according to the description in [2]. The robot includes two motors which are connected to port A and C due to port B/C being connected to the same H-bridge. A lightsensor is mounted on the lower part of the robot in a height of approximately 1.5 cm above the surface. In general it is a simple construction with a relatively high center of gravity which will likely pose a challenge for the control mechanism. Our final model is shown in the following image.
|
|
|
|
|
|
![NXTWay robot with light sensor mounted](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Images/LightSensorRobot.JPG)
|
|
![NXTWay robot with light sensor mounted](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Images/LightSensorRobot.JPG)
|
|
|
|
|
|
We know that the surface which the robot is placed on affects the control mechanism and therefore three different materials are tested. These are a blank white table, a wooden table and a carpet floor which is shown in the following image.
|
|
We know that the surface which the robot is placed on affects the control mechanism and therefore three different materials are tested. These are a blank white table, a wooden table and a carpet floor which are shown in the following image.
|
|
|
|
|
|
![Surfaces which the self-balancing NXTWay robot is tested on](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Images/LightSensorSurfaces.jpg)
|
|
![Surfaces which the self-balancing NXTWay robot is tested on](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Images/LightSensorSurfaces.jpg)
|
|
|
|
|
|
By inspecting the robots control mechanism we concluded that the best of the three surfaces was the blank white surface and therefore the following tuning and analysis of the PID parameters are performed on this surface.
|
|
By inspecting the performance we concluded that the best of the three surfaces was the blank white surface and therefore the following tuning and analysis of the PID parameters are performed on this surface.
|
|
|
|
|
|
We also know that the surrounding light can be a key factor when using a light sensor in a PID control context. Two cases of surrounding light was analyzed; natural light and artificial light. Despite our expectations the surrounding light did not seem to affect the light sensor control mechanism significantly.
|
|
We also know that the surrounding light can be a key factor when using a light sensor in a PID control context. Two cases of surrounding light was analyzed; natural light and artificial light. Despite our expectations the surrounding light did not seem to affect the light sensor control mechanism significantly.
|
|
|
|
|
... | @@ -48,7 +48,7 @@ The architecture consists of a generic PID controller with abstract methods to c |
... | @@ -48,7 +48,7 @@ The architecture consists of a generic PID controller with abstract methods to c |
|
|
|
|
|
![PC GUI that offsers modification of the control parameters on the NXT](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Images/GUI.PNG)
|
|
![PC GUI that offsers modification of the control parameters on the NXT](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Images/GUI.PNG)
|
|
|
|
|
|
The “Segway” class is the main class which controls the flow of the program by first letting the user choose a balancing point which then is defined as an offset making the set point of the PID controller 0. Afterwards the control algorithm is applied while the parameters are shown on the LCD. The core control algorithm is located in the GenericPIDController class and is shown in the following.
|
|
The `Segway` class is the main class which controls the flow of the program by first letting the user choose a balancing point which then is defined as an offset making the set point of the PID controller 0. Afterwards the control algorithm is applied while the parameters are shown on the LCD. The core control algorithm is located in the `GenericPIDController` class and is shown in the following.
|
|
|
|
|
|
```java
|
|
```java
|
|
// Calculate parameters
|
|
// Calculate parameters
|
... | @@ -67,7 +67,7 @@ controlSignal(controlledValue); |
... | @@ -67,7 +67,7 @@ controlSignal(controlledValue); |
|
lastError = error;
|
|
lastError = error;
|
|
```
|
|
```
|
|
|
|
|
|
were the functions `calculateError()` and `controlSignal()` is overriden by the specific PID controller, in this case the `LightPIDController`. The functions are shown in the following.
|
|
where the functions `calculateError()` and `controlSignal()` are overridden by the specific PID controller, in this case the `LightPIDController`. The functions are shown in the following.
|
|
|
|
|
|
```java
|
|
```java
|
|
@Override
|
|
@Override
|
... | @@ -105,7 +105,7 @@ The entire code can be seen in [4]. |
... | @@ -105,7 +105,7 @@ The entire code can be seen in [4]. |
|
|
|
|
|
### Results
|
|
### Results
|
|
|
|
|
|
By repeatedly tuning the parameters through the PC GUI we ended up with the best possible setting of the control parameters as:
|
|
By repeatedly tuning the parameters through the PC GUI we ended up with the following estimate of the best possible setting of the control parameters:
|
|
|
|
|
|
| Parameter | Value |
|
|
| Parameter | Value |
|
|
| ------------- |:------:|
|
|
| ------------- |:------:|
|
... | @@ -121,7 +121,7 @@ In order to investigate this behavior the data logger is used to collect the lig |
... | @@ -121,7 +121,7 @@ In order to investigate this behavior the data logger is used to collect the lig |
|
![Output of the light sensor when performing self-balancing](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Measurement/LightMeasurements.png)
|
|
![Output of the light sensor when performing self-balancing](https://gitlab.au.dk/rene2014/lego/raw/master/Lesson5/Measurement/LightMeasurements.png)
|
|
|
|
|
|
This plot shows the PID controllers offset as the red line and the output of the light sensor as the blue graph.
|
|
This plot shows the PID controllers offset as the red line and the output of the light sensor as the blue graph.
|
|
When the LEGO robot is tilting forward the light sensor will get closer to the surface which yields less light coming in and therefore the output value of the sensor will decrease. Otherwise when the LEGO robot is tilting backwards more light is coming in and the output value will increase. In order for the LEGO robot to keep balance it must constantly try to keep an upright position by applying motor force in the tilting direction (forward or backward). Due to the LEGO robots high center of gravity it is difficult to maintain an upright position resulting in the toggling back and forth between the offset until it is no longer able to adjust for the tilting.
|
|
When the LEGO robot is tilting forward the light sensor will get closer to the surface which yields less light coming in and therefore the output value of the sensor will decrease. On the other hand when the LEGO robot is tilting backwards more light is coming in and the output value will increase. In order for the LEGO robot to keep balance it must constantly try to keep an upright position by applying motor force in the tilting direction (forward or backward). Due to the LEGO robots high center of gravity it is difficult to maintain an upright position resulting in the toggling back and forth between the offset until it is no longer able to adjust for the tilting.
|
|
|
|
|
|
|
|
|
|
## Exercise 2
|
|
## Exercise 2
|
... | @@ -129,7 +129,7 @@ When the LEGO robot is tilting forward the light sensor will get closer to the s |
... | @@ -129,7 +129,7 @@ When the LEGO robot is tilting forward the light sensor will get closer to the s |
|
Self-balancing robots with color sensor
|
|
Self-balancing robots with color sensor
|
|
|
|
|
|
### Setup
|
|
### Setup
|
|
For this exercise we used a LEGO model build according to the description in [3] with some minor modifications. Since the upright motor is not used in the case of a segway. An image of the robot is seen in the following image.
|
|
For this exercise we used a LEGO model build according to the description in [3] with some minor modifications. Since the upright motor is not used in the case of a segway, the movement of the upper body of the rider has been fixed. Furthermore the motors that are driving the wheels are connected to motor port A and C instead of A and B, in order to utilize both H-bridges. An image of the robot is seen in the following image.
|
|
|
|
|
|
This robot is tested
|
|
This robot is tested
|
|
|
|
|
... | | ... | |