274 add some automated model predictive current control to gem control#282
Conversation
…b" and created new file for finite current control
XyDrKRulof
left a comment
There was a problem hiding this comment.
Already very nice work. For improvements, see my comments.
…ented comments on pmsm_fcs_mpc_dq_current_control.ipynb file
|
I have implemented the following changes plz. review.
Pending point,
|
There was a problem hiding this comment.
Hey Manjeet,
thanks for your good work - the FCS - MPC algorithm with prediction horizon > 1 is already looking really good :) Here are some further comments that we discussed:
- Replace the "max_depth" variable in the simulate_sequence function with self.ph_ (which, for readability, you could also rename to self.prediction_horizon)
- The self.voltage_vectors variable seems to be a mix out of abc and alphabeta coordinates - please change this table to the one you get directly out of the environment:
self.subactions = -np.power(-1,env.get_wrapper_attr('physical_system')._converter._subactions) - Instead of saving the abc voltage sequence of the lowest cost prediction, save (and return) the indices of them as provided in 2. (e.g., if the best voltage vector is (-1,1,-1) and it is in position 3 return 3)
- Update epsilon_el for the future predictions and average it for the abc -> dq conversion:
v_dq = self._forward_transformation(np.array([v_a, v_b, v_c]), epsilon_el + 0.5*omega*tau)
epsilon_next = epsilon + omega*tau
If you have any questions regarding any of these points feel free to contact us! :)
…utilities and improve prediction logic - Replaced manual abc → αβ → dq voltage transformations with environment's native method: - Updated voltage vector table to use finite set directly from the environment via: - Now storing and returning subaction **indices** instead of full abc voltage vectors for better integration and comparison - Updated epsilon handling in prediction loop: - Epsilon is now incremented as - dq-transformation uses averaged value: - Replaced hardcoded max_depth with (renamed from for clarity) Previously, I was doing manual calculations: converting abc voltages to αβ and then dq using custom logic. Now all transformations use the environment's own coordinate conversion function and finite action space, making the controller more accurate and modular. Thanks again for the helpful feedback!
|
Refactored FCS-MPC implementation to align with environment-provided utilities and improve prediction logic
Previously, I was doing manual calculations: converting abc voltages to αβ and then dq using custom logic. Thanks again for the helpful feedback! |
…of u_abc from subaction state
|
I have revised the description for FCS-MPC, now its ready to get merge. |
…rap around GymElectricMotorAdapter class. 2)updated the MPC controller file to process directly from environment,PMSM works.
|
Now, the MPC controller calculates the motor-specific state vector and electrical jacobian once in the control method, then uses these for prediction in _simulate_sequence. This makes the controller compatible with different motor types and avoids redundant calculations during the prediction loop. Unsupported motor types will raise a clear error. |
…troller.make - Added w_d and w_q parameters to MPCCurrentController - Updated cost function to use weighted errors - Modified GemController.make to forward extra kwargs into MPC
…b" and created new file for finite current control
…ented comments on pmsm_fcs_mpc_dq_current_control.ipynb file
…utilities and improve prediction logic - Replaced manual abc → αβ → dq voltage transformations with environment's native method: - Updated voltage vector table to use finite set directly from the environment via: - Now storing and returning subaction **indices** instead of full abc voltage vectors for better integration and comparison - Updated epsilon handling in prediction loop: - Epsilon is now incremented as - dq-transformation uses averaged value: - Replaced hardcoded max_depth with (renamed from for clarity) Previously, I was doing manual calculations: converting abc voltages to αβ and then dq using custom logic. Now all transformations use the environment's own coordinate conversion function and finite action space, making the controller more accurate and modular. Thanks again for the helpful feedback!
…of u_abc from subaction state
…rap around GymElectricMotorAdapter class. 2)updated the MPC controller file to process directly from environment,PMSM works.
…troller.make - Added w_d and w_q parameters to MPCCurrentController - Updated cost function to use weighted errors - Modified GemController.make to forward extra kwargs into MPC
af50dc7 to
17373c6
Compare
…ated-model-predictive-current-control-to-gem-control # Conflicts: # examples/model_predictive_controllers/pmsm_mpc_dq_current_control.ipynb
…rge of the changes in this branch.
bhk11
left a comment
There was a problem hiding this comment.
Works fine for me in the mentioned limits in the changelog
I have renamed the curred mpc example file to "pmsm_ccs_mpc_dq_current_control.ipynb" and created a new file for finite control set as "pmsm_fcs_mpc_dq_current_control.ipynb".