Giter Site home page Giter Site logo

quadcopter_simulator's People

Contributors

abhijitmajumdar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

quadcopter_simulator's Issues

I think state space is wrong

Hi, I noticed the implementation of the state space is not correct, in particular you take the time derivative of angular velocity vector to be equal to the second derivative of the euler angles which I do not believe is correct. To fix it you need to change your state space so that it consists of euler angles and the angular velocity vector NOT the derivative of the euler angles. You can then associate the time derivative of the euler angles and the angular velocity vector using the formula given in the guys blog: https://andrew.gibiansky.com/blog/physics/quadcopter-dynamics/

poor z control?

Hi there,

Just a quick note that if you give the controller a fixed goal and let it run for a while you get pretty good x-y control, but very poor z control. (See attached image.) I'm not sure why this doesn't show up in the GUI... maybe because the setpoint is updated periodically? I know the controller isn't the focus of the project, but just a heads up to anyone poking at it.

image

In case there's something about my usage of it that is generating this behavior, sample code I'm using (I removed the threads for this test and am playing with it in a notebook). Maybe my dt of 0.1 seconds is bad, for example.

Cell that sets up simulation:

# Set goals to go to
GOALS = [(1,1,2),(1,-1,4),(-1,-1,2),(-1,1,4)]
YAWS = [0,3.14,-1.54,1.54]
# Define the quadcopters
QUADCOPTER={'q1':{'position':[1,0,4],'orientation':[0,0,0],'L':0.3,'r':0.1,'prop_size':[10,4.5],'weight':1.2}}
# Controller parameters
CONTROLLER_PARAMETERS = {'Motor_limits':[4000,9000],
                    'Tilt_limits':[-10,10],
                    'Yaw_Control_Limits':[-900,900],
                    'Z_XY_offset':500,
                    'Linear_PID':{'P':[300,300,7000],'I':[0.04,0.04,4.5],'D':[450,450,5000]},
                    'Linear_To_Angular_Scaler':[1,1,0],
                    'Yaw_Rate_Scaler':0.18,
                    'Angular_PID':{'P':[22000,22000,1500],'I':[0,0,1.2],'D':[12000,12000,0]},
                    }

# Make objects for quadcopter, gui and controller
quad = Quadcopter(QUADCOPTER)
ctrl = Controller_PID_Point2Point(quad.get_state,quad.get_time,quad.set_motor_speeds,params=CONTROLLER_PARAMETERS,quad_identifier='q1')


goal,y = list( zip(GOALS,YAWS) )[0]

hist = [ quad.get_position('q1' ) ];

if True:
    ctrl.update_target(goal)
    ctrl.update_yaw_target(y)


    for i in range(10):
        ctrl.update()
        quad.update( dt=.1 )

        hist.append( quad.get_position('q1') )

Cell I run repeatedly that advances the sim 10 seconds at a time and generates the attached plot:

for tick in range(10):
    for i in range(10):
        ctrl.update()
        quad.update( dt=.1 )

        hist.append( quad.get_position('q1') )
        
import matplotlib.pyplot as plt

plt.figure( figsize=[10,10] )
ax = plt.axes(projection='3d')


ax.plot( *np.array( hist ).T )   

Cheers!
J.

A question about the math model of the quadcopter

In the file "quadcopter.py",line 73:
x_dotdot = np.array([0,0,-self.quads[key]['weight']*self.g]) + np.dot(self.rotation_matrix(self.quads[key]['state'][6:9]),np.array([0,0,(self.quads[key]['m1'].thrust + self.quads[key]['m2'].thrust + self.quads[key]['m3'].thrust + self.quads[key]['m4'].thrust)]))/self.quads[key]['weight']
I think it should be :
x_dotdot = np.array([0,0,-self.g]) + np.dot(self.rotation_matrix(self.quads[key]['state'][6:9]),np.array([0,0,(self.quads[key]['m1'].thrust + self.quads[key]['m2'].thrust + self.quads[key]['m3'].thrust + self.quads[key]['m4'].thrust)]))/self.quads[key]['weight']

I couldn't run the code as in ReadMe

I couldn't run the code as you described in ReadMe and terminal in Pycharm gives errors like in the screenshot below. Do you know what might be the problem? (I just pressed Ctrl+C to terminate it quickly as it just froze)

Screen Shot 2022-08-18 at 17 26 54

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.