Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller parameters tuner based on differentiable controller #186

Open
xiangfuli opened this issue Mar 1, 2023 · 2 comments
Open

Controller parameters tuner based on differentiable controller #186

xiangfuli opened this issue Mar 1, 2023 · 2 comments
Labels
new feature New feature or request

Comments

@xiangfuli
Copy link

🚀 The feature, motivation and pitch

Given differential and feasible PID controller, after tuning the pid parameters using gradient descent, dynamic systems would be able to follow the desired state. The method is proposed in paper. This method shows that the system can do the tuning work online.

Alternatives

No response

Additional context

To implement the PID tuner and provide examples, serval modules are needed.

  • dynamic system examples:
    • DubinCar
    • Quadrotor - pose described using quaternion
  • Trajectory generator to provide trajectory as ref_state of systems
    • desired poses are described using rotation matrix
  • PID controller interface
@xiangfuli xiangfuli added the new feature New feature or request label Mar 1, 2023
@xiangfuli xiangfuli assigned xiangfuli and unassigned xiangfuli Mar 1, 2023
@xiangfuli
Copy link
Author

xiangfuli commented Mar 5, 2023

Interfaces needed in PyPose

  1. Dynamic System (DubinCar, Multicopter)
  2. Trajectory Generator(Minimum Jerk Trajectory, Right now the trajectory generation code is not included in pypose lib, instead they are located in examples folders.
    • from examples.module.controller_parameters_tuner.trajectory_gen import PolynomialTrajectoryGenerator)
  3. controller
class Controller(nn.Module):
    r"""
    This class is the basic class for all controller implementations.
    """
    def __init__(self):
        pass

    def get_control(self, parameters, state, ref_state, feed_forward_quantity):
        r"""
        Args:
            parameters: controller parameters, e.g. kp, ki, kd in PID controllers.
            state:  current system state of dynamic systems.
            ref_state:  the reference state of systems to reach.
            feed_forward_quantity: system plant input generated by other feed forward
                controllers.
        """
        pass

    def reset(self):
        r"""
        This method is used to reset the internal state.
        For example, integrated error in PID controller
        """
        pass
  1. Controller Parameters Tuner
class ControllerParametersTuner():
    def __init__(self, learning_rate):
        self.learning_rate = learning_rate
   
    r"""
    Args:
            dynamic_system (pypose.module.dynamics):
            initial_state (Tensor):
            ref_states ():
            controller (pypose.module.controller): Linear or nonlinear controller to control
            the dynamic system
            parameters (Tensor): Controller parameters
            parameters_tuning_set (Tensor): This set gives the minimum and the maximum
                value the parameters can reach
            tau: time interval in system
            states_to_tune (Tensor): choose which state needs to be considered in the
                loss function, usually only position is chosen.
            func_get_state_error (function): function has two inputs: system state and
                ref state. The function needs to be provided by users considering system
                state and ref state are not always in the same formation.
    """
    def tune(self, dynamic_system, initial_state, ref_states, 
              controller, parameters, parameters_tuning_set, tau, states_to_tune, func_get_state_error):
        ...

@xiangfuli xiangfuli changed the title PID parameters tuner based on differentiable PID controller Controller parameters tuner based on differentiable controller Mar 27, 2023
@xiangfuli
Copy link
Author

xiangfuli commented Apr 10, 2023

In the function ControllerParametersTuner.tune, due to the potential inconsistent formation of system state and ref state, func_get_state_error is provided to help the user define the state error.

Also, parameter states_to_tune enables user to tune the system based on specific system state error, e.g. only care about the position error among the system state error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant