Can I build an adaptive controller by using an ODE solver and a 3D graphics engine? [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Let's assume that you're using a 3D graphics engine with built in physics. You create a inverted pendelum in a 3D designing software, e.g Blender, and then import the model into your 3D grapics engine and you set the mass etc.
A 3D grapics engine such as OpenGL, jMonkey, Unity etc. uses C, C++, C# or Java, Java for jMonkey.
As I know, to build an adaptive controller, I need to have the following:
- Recursive identifier algorithm
- A description of the structure of the physical model
- An algorithm who computes the control law
- An ODE solver who simulate the physical model
My idea is to set up a recursive algorithm, quite simple. Then a dscription of the structure of the physical model. In this case it must be a 2x2 LTV state space model. It will be done by a library for control theory.
Now to my question:
Assume that I run my simulation with a constant step interval. Assume it's a programming language I'm using. Is it possible tell the ODE solver the past step, time and other types of parameters such as states?
I have planned to use the Apache Commons library for control engineering.
http://commons.apache.org/proper/commons-math/userguide/ode.html
Where a simulation example looks like this:
private static class CircleODE implements FirstOrderDifferentialEquations
// Parameters for the class
private double c;
private double omega;
// Class constructor
public CircleODE(double c, double omega)
this.c = c;
this.omega = omega;
// Not required
public int getDimension()
return 2;
// This is the ODE solver and its arguments
public void computeDerivatives(double t, double y, double yDot)
yDot[0] = omega * (c[1] - y[1]);
yDot[1] = omega * (y[0] - c[0]);
And to start the simulation
// Choose the solver method
FirstOrderIntegrator dp853 = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
// Create the object
FirstOrderDifferentialEquations ode = new CircleODE(new double 1.0, 1.0 , 0.1);
// initial state vector
double y = new double 0.0, 1.0 ;
// Now simulate from 0 to 16 seconds.
dp853.integrate(ode, 0.0, y, 16.0, y); // now y contains final state at time t=16.0
Is it possible to use generate a new object for every iteration and simulate the object when the past time and past state? For every iteration, a recursive identifier should compute better parameters for the future objects of the class CircleODE.
Notice that Java has a garbage collector, so I don't need to destroy the past objects by my self. :)
optimization control-theory optimal-control linear-control
closed as off-topic by achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy Aug 6 at 11:15
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy
add a comment |Â
up vote
0
down vote
favorite
Let's assume that you're using a 3D graphics engine with built in physics. You create a inverted pendelum in a 3D designing software, e.g Blender, and then import the model into your 3D grapics engine and you set the mass etc.
A 3D grapics engine such as OpenGL, jMonkey, Unity etc. uses C, C++, C# or Java, Java for jMonkey.
As I know, to build an adaptive controller, I need to have the following:
- Recursive identifier algorithm
- A description of the structure of the physical model
- An algorithm who computes the control law
- An ODE solver who simulate the physical model
My idea is to set up a recursive algorithm, quite simple. Then a dscription of the structure of the physical model. In this case it must be a 2x2 LTV state space model. It will be done by a library for control theory.
Now to my question:
Assume that I run my simulation with a constant step interval. Assume it's a programming language I'm using. Is it possible tell the ODE solver the past step, time and other types of parameters such as states?
I have planned to use the Apache Commons library for control engineering.
http://commons.apache.org/proper/commons-math/userguide/ode.html
Where a simulation example looks like this:
private static class CircleODE implements FirstOrderDifferentialEquations
// Parameters for the class
private double c;
private double omega;
// Class constructor
public CircleODE(double c, double omega)
this.c = c;
this.omega = omega;
// Not required
public int getDimension()
return 2;
// This is the ODE solver and its arguments
public void computeDerivatives(double t, double y, double yDot)
yDot[0] = omega * (c[1] - y[1]);
yDot[1] = omega * (y[0] - c[0]);
And to start the simulation
// Choose the solver method
FirstOrderIntegrator dp853 = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
// Create the object
FirstOrderDifferentialEquations ode = new CircleODE(new double 1.0, 1.0 , 0.1);
// initial state vector
double y = new double 0.0, 1.0 ;
// Now simulate from 0 to 16 seconds.
dp853.integrate(ode, 0.0, y, 16.0, y); // now y contains final state at time t=16.0
Is it possible to use generate a new object for every iteration and simulate the object when the past time and past state? For every iteration, a recursive identifier should compute better parameters for the future objects of the class CircleODE.
Notice that Java has a garbage collector, so I don't need to destroy the past objects by my self. :)
optimization control-theory optimal-control linear-control
closed as off-topic by achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy Aug 6 at 11:15
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy
I view the solver as separate from the dynamics, including control. You can formulate the dynamics however you'd like, the solver is going to solve whatever you give it. So really what you want is a controller that applies forces (or impulses) to the mass. This is typically how PID controllers and others work, modularly separate from the integrator or solver. All that said, you certainly CAN combine everything, it would just be less generalizable to other dynamics problems.
â Carser
Aug 5 at 22:19
@Carser Ok. Thank you. All I need to do is to insert the past time and past state into the solver again? For every iteration, I compute the new parameters for the new model. You you feel that you have the correct answer, feel free to press the answer button :)
â Daniel MÃ¥rtensson
Aug 5 at 22:21
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Let's assume that you're using a 3D graphics engine with built in physics. You create a inverted pendelum in a 3D designing software, e.g Blender, and then import the model into your 3D grapics engine and you set the mass etc.
A 3D grapics engine such as OpenGL, jMonkey, Unity etc. uses C, C++, C# or Java, Java for jMonkey.
As I know, to build an adaptive controller, I need to have the following:
- Recursive identifier algorithm
- A description of the structure of the physical model
- An algorithm who computes the control law
- An ODE solver who simulate the physical model
My idea is to set up a recursive algorithm, quite simple. Then a dscription of the structure of the physical model. In this case it must be a 2x2 LTV state space model. It will be done by a library for control theory.
Now to my question:
Assume that I run my simulation with a constant step interval. Assume it's a programming language I'm using. Is it possible tell the ODE solver the past step, time and other types of parameters such as states?
I have planned to use the Apache Commons library for control engineering.
http://commons.apache.org/proper/commons-math/userguide/ode.html
Where a simulation example looks like this:
private static class CircleODE implements FirstOrderDifferentialEquations
// Parameters for the class
private double c;
private double omega;
// Class constructor
public CircleODE(double c, double omega)
this.c = c;
this.omega = omega;
// Not required
public int getDimension()
return 2;
// This is the ODE solver and its arguments
public void computeDerivatives(double t, double y, double yDot)
yDot[0] = omega * (c[1] - y[1]);
yDot[1] = omega * (y[0] - c[0]);
And to start the simulation
// Choose the solver method
FirstOrderIntegrator dp853 = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
// Create the object
FirstOrderDifferentialEquations ode = new CircleODE(new double 1.0, 1.0 , 0.1);
// initial state vector
double y = new double 0.0, 1.0 ;
// Now simulate from 0 to 16 seconds.
dp853.integrate(ode, 0.0, y, 16.0, y); // now y contains final state at time t=16.0
Is it possible to use generate a new object for every iteration and simulate the object when the past time and past state? For every iteration, a recursive identifier should compute better parameters for the future objects of the class CircleODE.
Notice that Java has a garbage collector, so I don't need to destroy the past objects by my self. :)
optimization control-theory optimal-control linear-control
Let's assume that you're using a 3D graphics engine with built in physics. You create a inverted pendelum in a 3D designing software, e.g Blender, and then import the model into your 3D grapics engine and you set the mass etc.
A 3D grapics engine such as OpenGL, jMonkey, Unity etc. uses C, C++, C# or Java, Java for jMonkey.
As I know, to build an adaptive controller, I need to have the following:
- Recursive identifier algorithm
- A description of the structure of the physical model
- An algorithm who computes the control law
- An ODE solver who simulate the physical model
My idea is to set up a recursive algorithm, quite simple. Then a dscription of the structure of the physical model. In this case it must be a 2x2 LTV state space model. It will be done by a library for control theory.
Now to my question:
Assume that I run my simulation with a constant step interval. Assume it's a programming language I'm using. Is it possible tell the ODE solver the past step, time and other types of parameters such as states?
I have planned to use the Apache Commons library for control engineering.
http://commons.apache.org/proper/commons-math/userguide/ode.html
Where a simulation example looks like this:
private static class CircleODE implements FirstOrderDifferentialEquations
// Parameters for the class
private double c;
private double omega;
// Class constructor
public CircleODE(double c, double omega)
this.c = c;
this.omega = omega;
// Not required
public int getDimension()
return 2;
// This is the ODE solver and its arguments
public void computeDerivatives(double t, double y, double yDot)
yDot[0] = omega * (c[1] - y[1]);
yDot[1] = omega * (y[0] - c[0]);
And to start the simulation
// Choose the solver method
FirstOrderIntegrator dp853 = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
// Create the object
FirstOrderDifferentialEquations ode = new CircleODE(new double 1.0, 1.0 , 0.1);
// initial state vector
double y = new double 0.0, 1.0 ;
// Now simulate from 0 to 16 seconds.
dp853.integrate(ode, 0.0, y, 16.0, y); // now y contains final state at time t=16.0
Is it possible to use generate a new object for every iteration and simulate the object when the past time and past state? For every iteration, a recursive identifier should compute better parameters for the future objects of the class CircleODE.
Notice that Java has a garbage collector, so I don't need to destroy the past objects by my self. :)
optimization control-theory optimal-control linear-control
asked Aug 5 at 21:58
Daniel MÃ¥rtensson
886313
886313
closed as off-topic by achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy Aug 6 at 11:15
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy
closed as off-topic by achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy Aug 6 at 11:15
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is not about mathematics, within the scope defined in the help center." â achille hui, Xander Henderson, max_zorn, Taroccoesbrocco, amWhy
I view the solver as separate from the dynamics, including control. You can formulate the dynamics however you'd like, the solver is going to solve whatever you give it. So really what you want is a controller that applies forces (or impulses) to the mass. This is typically how PID controllers and others work, modularly separate from the integrator or solver. All that said, you certainly CAN combine everything, it would just be less generalizable to other dynamics problems.
â Carser
Aug 5 at 22:19
@Carser Ok. Thank you. All I need to do is to insert the past time and past state into the solver again? For every iteration, I compute the new parameters for the new model. You you feel that you have the correct answer, feel free to press the answer button :)
â Daniel MÃ¥rtensson
Aug 5 at 22:21
add a comment |Â
I view the solver as separate from the dynamics, including control. You can formulate the dynamics however you'd like, the solver is going to solve whatever you give it. So really what you want is a controller that applies forces (or impulses) to the mass. This is typically how PID controllers and others work, modularly separate from the integrator or solver. All that said, you certainly CAN combine everything, it would just be less generalizable to other dynamics problems.
â Carser
Aug 5 at 22:19
@Carser Ok. Thank you. All I need to do is to insert the past time and past state into the solver again? For every iteration, I compute the new parameters for the new model. You you feel that you have the correct answer, feel free to press the answer button :)
â Daniel MÃ¥rtensson
Aug 5 at 22:21
I view the solver as separate from the dynamics, including control. You can formulate the dynamics however you'd like, the solver is going to solve whatever you give it. So really what you want is a controller that applies forces (or impulses) to the mass. This is typically how PID controllers and others work, modularly separate from the integrator or solver. All that said, you certainly CAN combine everything, it would just be less generalizable to other dynamics problems.
â Carser
Aug 5 at 22:19
I view the solver as separate from the dynamics, including control. You can formulate the dynamics however you'd like, the solver is going to solve whatever you give it. So really what you want is a controller that applies forces (or impulses) to the mass. This is typically how PID controllers and others work, modularly separate from the integrator or solver. All that said, you certainly CAN combine everything, it would just be less generalizable to other dynamics problems.
â Carser
Aug 5 at 22:19
@Carser Ok. Thank you. All I need to do is to insert the past time and past state into the solver again? For every iteration, I compute the new parameters for the new model. You you feel that you have the correct answer, feel free to press the answer button :)
â Daniel MÃ¥rtensson
Aug 5 at 22:21
@Carser Ok. Thank you. All I need to do is to insert the past time and past state into the solver again? For every iteration, I compute the new parameters for the new model. You you feel that you have the correct answer, feel free to press the answer button :)
â Daniel MÃ¥rtensson
Aug 5 at 22:21
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
The ODE solver has no sense of "time," it will just try to solve whatever you give it.
You want to store state information outside of the solver. Maybe a list of previous positions or velocities (depending on what type of controller you are creating). For example, if you are creating a position based PID controller, you will need access to the current position and target position to calculate
$$ P = P_target - P_current $$
you'll need the previous position as well to calculate the derivative term
$$ fracP_current-P_previoustimestep $$
and you'll need a variable for accumulating the integral error $I$.
So the steps in your simulation are
$$textUse controller to determine what forces to apply$$
$$downarrow$$
$$textFormulate the dynamics, including controller forces$$
$$downarrow$$
$$textPass the dynamics problem to the solver$$
$$downarrow$$
$$textUse solver results to update body positions and velocities$$
$$$$
Since you can just store state information in a variable and retrieve it whenever you want, you can use that state information in the first step when the controller is calculating what forces to apply.
Also, it would probably be noticeably inefficient to create a new object for every iteration, just like creating and destroying variables over and over. You would probably want to have objects with attributes that you can overwrite, for example an object that represents bodies in the simulation where you can update their attributes like position, velocity, etc.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
The ODE solver has no sense of "time," it will just try to solve whatever you give it.
You want to store state information outside of the solver. Maybe a list of previous positions or velocities (depending on what type of controller you are creating). For example, if you are creating a position based PID controller, you will need access to the current position and target position to calculate
$$ P = P_target - P_current $$
you'll need the previous position as well to calculate the derivative term
$$ fracP_current-P_previoustimestep $$
and you'll need a variable for accumulating the integral error $I$.
So the steps in your simulation are
$$textUse controller to determine what forces to apply$$
$$downarrow$$
$$textFormulate the dynamics, including controller forces$$
$$downarrow$$
$$textPass the dynamics problem to the solver$$
$$downarrow$$
$$textUse solver results to update body positions and velocities$$
$$$$
Since you can just store state information in a variable and retrieve it whenever you want, you can use that state information in the first step when the controller is calculating what forces to apply.
Also, it would probably be noticeably inefficient to create a new object for every iteration, just like creating and destroying variables over and over. You would probably want to have objects with attributes that you can overwrite, for example an object that represents bodies in the simulation where you can update their attributes like position, velocity, etc.
add a comment |Â
up vote
1
down vote
The ODE solver has no sense of "time," it will just try to solve whatever you give it.
You want to store state information outside of the solver. Maybe a list of previous positions or velocities (depending on what type of controller you are creating). For example, if you are creating a position based PID controller, you will need access to the current position and target position to calculate
$$ P = P_target - P_current $$
you'll need the previous position as well to calculate the derivative term
$$ fracP_current-P_previoustimestep $$
and you'll need a variable for accumulating the integral error $I$.
So the steps in your simulation are
$$textUse controller to determine what forces to apply$$
$$downarrow$$
$$textFormulate the dynamics, including controller forces$$
$$downarrow$$
$$textPass the dynamics problem to the solver$$
$$downarrow$$
$$textUse solver results to update body positions and velocities$$
$$$$
Since you can just store state information in a variable and retrieve it whenever you want, you can use that state information in the first step when the controller is calculating what forces to apply.
Also, it would probably be noticeably inefficient to create a new object for every iteration, just like creating and destroying variables over and over. You would probably want to have objects with attributes that you can overwrite, for example an object that represents bodies in the simulation where you can update their attributes like position, velocity, etc.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
The ODE solver has no sense of "time," it will just try to solve whatever you give it.
You want to store state information outside of the solver. Maybe a list of previous positions or velocities (depending on what type of controller you are creating). For example, if you are creating a position based PID controller, you will need access to the current position and target position to calculate
$$ P = P_target - P_current $$
you'll need the previous position as well to calculate the derivative term
$$ fracP_current-P_previoustimestep $$
and you'll need a variable for accumulating the integral error $I$.
So the steps in your simulation are
$$textUse controller to determine what forces to apply$$
$$downarrow$$
$$textFormulate the dynamics, including controller forces$$
$$downarrow$$
$$textPass the dynamics problem to the solver$$
$$downarrow$$
$$textUse solver results to update body positions and velocities$$
$$$$
Since you can just store state information in a variable and retrieve it whenever you want, you can use that state information in the first step when the controller is calculating what forces to apply.
Also, it would probably be noticeably inefficient to create a new object for every iteration, just like creating and destroying variables over and over. You would probably want to have objects with attributes that you can overwrite, for example an object that represents bodies in the simulation where you can update their attributes like position, velocity, etc.
The ODE solver has no sense of "time," it will just try to solve whatever you give it.
You want to store state information outside of the solver. Maybe a list of previous positions or velocities (depending on what type of controller you are creating). For example, if you are creating a position based PID controller, you will need access to the current position and target position to calculate
$$ P = P_target - P_current $$
you'll need the previous position as well to calculate the derivative term
$$ fracP_current-P_previoustimestep $$
and you'll need a variable for accumulating the integral error $I$.
So the steps in your simulation are
$$textUse controller to determine what forces to apply$$
$$downarrow$$
$$textFormulate the dynamics, including controller forces$$
$$downarrow$$
$$textPass the dynamics problem to the solver$$
$$downarrow$$
$$textUse solver results to update body positions and velocities$$
$$$$
Since you can just store state information in a variable and retrieve it whenever you want, you can use that state information in the first step when the controller is calculating what forces to apply.
Also, it would probably be noticeably inefficient to create a new object for every iteration, just like creating and destroying variables over and over. You would probably want to have objects with attributes that you can overwrite, for example an object that represents bodies in the simulation where you can update their attributes like position, velocity, etc.
answered Aug 5 at 22:39
Carser
2,3963926
2,3963926
add a comment |Â
add a comment |Â
I view the solver as separate from the dynamics, including control. You can formulate the dynamics however you'd like, the solver is going to solve whatever you give it. So really what you want is a controller that applies forces (or impulses) to the mass. This is typically how PID controllers and others work, modularly separate from the integrator or solver. All that said, you certainly CAN combine everything, it would just be less generalizable to other dynamics problems.
â Carser
Aug 5 at 22:19
@Carser Ok. Thank you. All I need to do is to insert the past time and past state into the solver again? For every iteration, I compute the new parameters for the new model. You you feel that you have the correct answer, feel free to press the answer button :)
â Daniel MÃ¥rtensson
Aug 5 at 22:21