PatrickYang-5 / MPC_drones

MIT License
6 stars 1 forks source link

Nice Addition with MPC - Thank you #1

Open abdul-mannan-khan opened 1 month ago

abdul-mannan-khan commented 1 month ago

Hello Patrick Yang, This is not an issue. Just raised an issue to appreciate your work. Thank you so much for the nice addition of MPC in gym-pybullet-drones. I was exactly looking for this after a long discussion with @Jacob. I would like to run your sample MPC. Could you please just provide a simple MPC which could be incorporated in BaserRLAviary.py to calculate action type "rpm" for the given error in desired position and target position. .

Just added a little function in your main LMPCHover.py.

def thrust_to_rpm(u): # conver thrust into rpm
        # Coefficients for the quadratic equation
        a = 1.0942e-7
        b = -2.1059e-4
        c = 0.15417 - u

        # Calculate the discriminant
        discriminant = b**2 - 4 * a * c

        if discriminant < 0:
            raise ValueError("The thrust value provided is not feasible for this model.")

        # Calculate both possible RPM values
        rpm1 = (-b + np.sqrt(discriminant)) / (2 * a)
        rpm2 = (-b - np.sqrt(discriminant)) / (2 * a)

        # Return the positive, realistic RPM value
        return max(rpm1, rpm2)

Looking forward to your kind response. Thank you so much for your response

PatrickYang-5 commented 1 month ago

Dear Abdul,

Thank you so much for your kind words and for your interest in this project!

I appreciate your enthusiasm and am glad to hear that the addition of MPC can help you. Regarding your request to incorporate a simple MPC in BaserRLAviary.py for calculating "rpm" based on the desired and target positions, I'll take a closer look at how we can implement it. And also I’m planning to do a preliminary reorganization of the project this coming Sunday. If everything goes well, I'll update it by August 12.

Please note that this project was initially part of course assignments at TU Delft and has officially concluded, so the updates or improvements will only be available during non-working days. Sorry for any inconvenience that might occur.

Thanks again for recognizing this program!

Best regards,

Peiyu Yang (Patrick Yang)

Message ID: @.***>