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

Updated axis limit computation and added other common trajectories. #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

juanmed
Copy link
Collaborator

@juanmed juanmed commented Jan 17, 2019

Hi. These are not big changes:

  • Sometimes the desired trajectory is outside the drawing limits. So I updated the set_limit calls to draw plot with appropriate limits.
  • Added polynomial and leminiscata (figure 8)trajectories since are common when analyzing performance of control algorithms. These trajectories are k-differentiable so they are useful for computing reference positions, velocities and accelerations in a trajectory (because are 3-differentiable).

@juanmed
Copy link
Collaborator Author

juanmed commented Jan 17, 2019

I just added an LQR Controller. Its design was based on a linearization of the system dynamics. Right now it is tuned for output performance rather than input energy performance, so it is a bit crazy.

@hbd730
Copy link
Owner

hbd730 commented Jan 18, 2019

Hi, looks like you have done a lot of work, well done! I have a quick run locally and realize the drone flies off track in a second, is that what you seen on your side? I will need to have a closer look later on when I get time.

@juanmed
Copy link
Collaborator Author

juanmed commented Jan 18, 2019

Hi, thank you for creating this simulator. The behaviour you describe is what I see. However this behaviour is dependent on both the trajectory and the control_frequency variable. Also it is not limited to my LQR controller but also to the PID controller already present in the repository shows this behaviour.

I would like to mention that I have not yet fully analyzed your code. Since this behaviour is dependent on the trajectory and control_frequency, I would like to first understand how your code works and then try to identify this behaviour as related to the simulator or the controller.

@hbd730
Copy link
Owner

hbd730 commented Jan 18, 2019 via email

@juanmed
Copy link
Collaborator Author

juanmed commented Jan 18, 2019

Yes, for sure. It would be nice your implementation of the thread. I found your small simulator flexible enough to make superficial and deep changes with ease, it has a nice graphical interface and the code easy to understand.. I would like to keep collaborating on it while keeping this characteristics.

@hbd730
Copy link
Owner

hbd730 commented Jan 18, 2019

Hi Juan,

I have push my threading change to master, and created a branch for you dev/lqr-controller, do you want to adapt your changes on that branch. Do you want me to add you as a contributor? Let me know your email.

@@ -0,0 +1,6 @@
*.pyc
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this now, I already add .gitignore

des_x_dot, des_y_dot, des_z_dot = des_state.vel
des_x_ddot, des_y_ddot, des_z_ddot = des_state.acc
des_psi = des_state.yaw
des_psi_dot = des_state.yawdot
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not look like these are used, please review the input parameters, and only takes the one that is used.

return F, M

def run_LQR(quad, des_state):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can, could you refactor this controller.py file a bit so it only includes control algoriuthm, and seperate out calibration parameters.

  • pid() - move pid specific parameters into a seperate file.
  • lqr() - could you refactor a bit so lqr specific matrix constant goes into a seperate file similar to model.params

we should create a folder called "control" and only includes controller.py and params for now.

#
# In general u = Nu*r - K(x -Nx*r) = -K*x + (Nu + K*Nx)*r
# where K are the LQR gains, Nu and Nx are reference input matrices.
# See more at p.493 "Feedback Control of Dynamic Systems, Franklink G,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good summery, could you write some simple description on how you tune and design lqr matrix, and their effect on the control in general?

@@ -24,26 +24,34 @@ def render(quad):

def attitudeControl(quad, time, waypoints, coeff_x, coeff_y, coeff_z):
desired_state = trajGen3D.generate_trajectory(time[0], 1.2, waypoints, coeff_x, coeff_y, coeff_z)
F, M = controller.run(quad, desired_state)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename original run to run_pid() as mentioned above

@@ -15,15 +15,18 @@
history = np.zeros((500,3))
count = 0

def plot_quad_3d(waypoints, args=()):
def plot_quad_3d(waypoints, init_pos, args=()):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see if you can adapt your change to my thread-less part, I will review this part later on. I suggest you seperate this review into two, one is general clean up and quadPlot related change, the other is lqr controller. You can do this in your branch now and submit incremental change, which it is easy for me to review.


return np.stack((x, y, z), axis=-1)

def get_poly_waypoints(t,n):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since your get_leminiscata_waypoints does not seem to be used yet, I think we should create a folder call trajectories, and move all trajectories generation files into it and create a new one for your work and submit that change as a review.
Make sure you write some unit test in the test folder :)

Copy link
Owner

@hbd730 hbd730 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work so far and hope you can see my comment and continue your work as suggested.

@hbd730
Copy link
Owner

hbd730 commented Jan 22, 2019 via email

@juanmed
Copy link
Collaborator Author

juanmed commented Jan 22, 2019

Hey! Yes of course. I have been busy with other stuff so I have not been able to update the branch. Actually I have been working on a differential flatness based controller. As time allows I will update both the LQR controller and try to merge the differential flatness based controller.

By the way, I was wondering if it is possible for you to add some comments in your code. For example, adding the euler convention used and other details. I think it might make your code easier to undertand.

Thanks for updating the repository!

@hbd730
Copy link
Owner

hbd730 commented Aug 9, 2019 via email

@juanmed
Copy link
Collaborator Author

juanmed commented Aug 15, 2019

Hey Peter,

Thanks for your message. You can find my changes regarding heading here on the trajGen3D.py file. But I cannot guarantee that these changes will not make the drone to fly away since I did not directly tried to solve that. However I should mention that this fix plus update you pushed from bitbucked helped. I did not see the drone fly away anymore (of course, if the control inputs are correct).

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

Successfully merging this pull request may close these issues.

2 participants