WOLFRAM SYSTEM MODELER
LQControlModel of a LEGO Segway with an LQ controller keeping it upright. |
![]() |
SystemModel["EducationExamples.ElectricalEngineering.LEGOSegway.LQControl"]
This models a LEGO Segway kept upright by an LQ controller. The LQ controller is designed in Mathematica using the SystemModeler Link. For the model without a controller, open LEGOSegway.NoControl.
In order to get the full experience of this example, you need the following:
Parts of this example require the Wolfram Language. Open the accompanying notebook LEGOSegway.nb for those scenarios.
View the model diagram for this model.
To simulate the LEGO Segway and view a 3D animation of it, follow the steps below:
The result shows the LEGO Segway moving around, withstanding pushes applied at the top of the Segway.
As soon as the simulation is done, a stored plot will be displayed, showing the path of the Segway:
There is also a stored plot the angle of the Segway. To view that, click on Segway Angle in the Stored Plots widget.
This will show the following plot:
As you can see, the angle never deviates more than 0.08 rad, or 4.6°.
The model of this controlled Segway is built on custom components, modeling parts of the LEGO Mindstorms NXT 2.0 kit. For example, the model diagrams for the gyro, the motor, and one of the tires.
These pages show an overview of the example. For the full example, open the accompanying notebook LEGOSegway.nb.
uMax |
Value: 8.5 Type: Voltage (V) |
---|---|
fMax |
Value: 0.31 Type: Force (N) |
L |
Value: {{-0.317389999945665, -0.332770810105325, -189.012455398573, -19.1625910782731, 0.00986193616239615, 0.0175149167638231}, {-0.332770810116102, -0.317389999939135, -189.012455399932, -19.1625910784022, 0.0175149167639171, 0.00986193616242574}} Type: Real[2,6] |
![]() |
angle |
Type: RealOutput |
---|
![]() |
segway |
Type: LEGOSegwayModel |
---|---|---|
![]() |
force |
Type: WorldForce |
![]() |
pulsex |
Type: Pulse |
![]() |
pulsey |
Type: Pulse |
![]() |
pulsez |
Type: Pulse |
![]() |
LeftMotorVoltage |
Type: TimeTable |
![]() |
RightMotorVoltage |
Type: TimeTable |
![]() |
feedback1 |
Type: Feedback |
![]() |
feedback2 |
Type: Feedback |
![]() |
LQGain |
Type: MatrixGain |
![]() |
multiplex |
Type: Multiplex6 |
![]() |
world |
Type: World |
![]() |
gain1 |
Type: Gain |
![]() |
gain2 |
Type: Gain |