Can I build an adaptive controller by using an ODE solver and a 3D graphics engine? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash 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:



  1. Recursive identifier algorithm

  2. A description of the structure of the physical model

  3. An algorithm who computes the control law

  4. 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. :)







share|cite|improve this question











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
If this question can be reworded to fit the rules in the help center, please edit the question.












  • 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















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:



  1. Recursive identifier algorithm

  2. A description of the structure of the physical model

  3. An algorithm who computes the control law

  4. 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. :)







share|cite|improve this question











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
If this question can be reworded to fit the rules in the help center, please edit the question.












  • 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













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:



  1. Recursive identifier algorithm

  2. A description of the structure of the physical model

  3. An algorithm who computes the control law

  4. 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. :)







share|cite|improve this question











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:



  1. Recursive identifier algorithm

  2. A description of the structure of the physical model

  3. An algorithm who computes the control law

  4. 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. :)









share|cite|improve this question










share|cite|improve this question




share|cite|improve this question









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
If this question can be reworded to fit the rules in the help center, please edit the question.




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
If this question can be reworded to fit the rules in the help center, please edit the question.











  • 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










  • @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











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.






share|cite|improve this answer




























    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.






    share|cite|improve this answer

























      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.






      share|cite|improve this answer























        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.






        share|cite|improve this answer













        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.







        share|cite|improve this answer













        share|cite|improve this answer



        share|cite|improve this answer











        answered Aug 5 at 22:39









        Carser

        2,3963926




        2,3963926












            Comments

            Popular posts from this blog

            What is the equation of a 3D cone with generalised tilt?

            Color the edges and diagonals of a regular polygon

            Relationship between determinant of matrix and determinant of adjoint?