{"action":"created","issue":{"url":"https://api.github.com/repos/d-ronin/dRonin/issues/1700","repository_url":"https://api.github.com/repos/d-ronin/dRonin","labels_url":"https://api.github.com/repos/d-ronin/dRonin/issues/1700/labels{/name}","comments_url":"https://api.github.com/repos/d-ronin/dRonin/issues/1700/comments","events_url":"https://api.github.com/repos/d-ronin/dRonin/issues/1700/events","html_url":"https://github.com/d-ronin/dRonin/issues/1700","id":220004548,"number":1700,"title":"Design discussion: linear algebra, actuators","user":{"login":"mlyle","id":90903,"avatar_url":"https://avatars1.githubusercontent.com/u/90903?v=3","gravatar_id":"","url":"https://api.github.com/users/mlyle","html_url":"https://github.com/mlyle","followers_url":"https://api.github.com/users/mlyle/followers","following_url":"https://api.github.com/users/mlyle/following{/other_user}","gists_url":"https://api.github.com/users/mlyle/gists{/gist_id}","starred_url":"https://api.github.com/users/mlyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlyle/subscriptions","organizations_url":"https://api.github.com/users/mlyle/orgs","repos_url":"https://api.github.com/users/mlyle/repos","events_url":"https://api.github.com/users/mlyle/events{/privacy}","received_events_url":"https://api.github.com/users/mlyle/received_events","type":"User","site_admin":false},"labels":[{"id":268484573,"url":"https://api.github.com/repos/d-ronin/dRonin/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":292625675,"url":"https://api.github.com/repos/d-ronin/dRonin/labels/status/request-for-comments","name":"status/request-for-comments","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/d-ronin/dRonin/milestones/6","html_url":"https://github.com/d-ronin/dRonin/milestone/6","labels_url":"https://api.github.com/repos/d-ronin/dRonin/milestones/6/labels","id":1899290,"number":6,"title":"Neat","description":"","creator":{"login":"mlyle","id":90903,"avatar_url":"https://avatars1.githubusercontent.com/u/90903?v=3","gravatar_id":"","url":"https://api.github.com/users/mlyle","html_url":"https://github.com/mlyle","followers_url":"https://api.github.com/users/mlyle/followers","following_url":"https://api.github.com/users/mlyle/following{/other_user}","gists_url":"https://api.github.com/users/mlyle/gists{/gist_id}","starred_url":"https://api.github.com/users/mlyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlyle/subscriptions","organizations_url":"https://api.github.com/users/mlyle/orgs","repos_url":"https://api.github.com/users/mlyle/repos","events_url":"https://api.github.com/users/mlyle/events{/privacy}","received_events_url":"https://api.github.com/users/mlyle/received_events","type":"User","site_admin":false},"open_issues":117,"closed_issues":130,"state":"open","created_at":"2016-07-22T17:05:19Z","updated_at":"2017-04-07T18:11:55Z","due_on":"2017-06-05T07:00:00Z","closed_at":null},"comments":6,"created_at":"2017-04-06T19:20:33Z","updated_at":"2017-04-07T20:34:38Z","closed_at":null,"body":"Will close this issue in a couple days after any discussion.\r\n\r\nI want to make actuators do fancier things.  There's basically 3 considerations:\r\n\r\n1. Right now the limited mixer matrices don't cover all control axes (e.g. accessorydesired) and it would be nice to be able to do more.\r\n2. There's things we know about actuators that it'd be nice to react to before the delay of the delay loop.  We know if we've clipped on output; we know likely delays and time constants.  A simple smith predictor down in actuator makes a lot of sense.  There's a simple version of this I'll discuss below and likely the desire of vehicle-type specific code (e.g. tricopter).\r\n3. Some actuators even give explicit feedback and it would be nice to use this.\r\n\r\nMy general design is this:\r\n\r\n* Move the mixer matrix to be a real nxm matrix and handle forward mixing by multiplying the axis command vector by the mixer matrix.\r\n* Handle special cases (clipping, power-add limiting).  Send this stuff to the motors.\r\n* Simulate each of the actuators based on what we sent it.  [Or read the actual attained effort back and combine it with simulation]\r\n* From the simulated actuator effort, calculate the actual effort on each of the axes.  This is handled with a multiply by an inverse mixer matrix (and possible vehicle-specific fixup before/after, e.g. tricopter corrections).\r\n* Apply a fixed linear correction to the \"next command\" based on any control effort error (P control)\r\n\r\n~~This second-to-last step is where I get stuck.  Our mixer matrices are not square and even if they were are very likely to be over-or-underdetermined-- especially if we include things like accessory commands (also cases like hexcopters, etc).  There is a well-defined pseudoinverse operation that can handle this (Moore-Penrose).  However, calculating it requires running big numerical algebra codes (SVD or QR factorization) which are generally A) not easy to build for microcontrollers, B) built to work on **huge** problems rather than relatively small matrices. and C) expensive.~~\r\n\r\n~~There's basically 3 approaches I can think of:~~\r\n\r\n1. ~~Grit our teeth and bring a linear algebra system into the codebase.~~\r\n2. ~~Calculate the inverse mixer matrix in the ground system.  This will create future issues with using this kind of infrastructure with tiltrotors, etc.~~\r\n3. **Come up with some clever way of trimming matrices or iteratively solving this problem to a \"good enough\" state.**\r\n\r\nDoes anyone have any feedback or suggestions?"},"comment":{"url":"https://api.github.com/repos/d-ronin/dRonin/issues/comments/292644814","html_url":"https://github.com/d-ronin/dRonin/issues/1700#issuecomment-292644814","issue_url":"https://api.github.com/repos/d-ronin/dRonin/issues/1700","id":292644814,"user":{"login":"mlyle","id":90903,"avatar_url":"https://avatars1.githubusercontent.com/u/90903?v=3","gravatar_id":"","url":"https://api.github.com/users/mlyle","html_url":"https://github.com/mlyle","followers_url":"https://api.github.com/users/mlyle/followers","following_url":"https://api.github.com/users/mlyle/following{/other_user}","gists_url":"https://api.github.com/users/mlyle/gists{/gist_id}","starred_url":"https://api.github.com/users/mlyle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlyle/subscriptions","organizations_url":"https://api.github.com/users/mlyle/orgs","repos_url":"https://api.github.com/users/mlyle/repos","events_url":"https://api.github.com/users/mlyle/events{/privacy}","received_events_url":"https://api.github.com/users/mlyle/received_events","type":"User","site_admin":false},"created_at":"2017-04-07T20:34:38Z","updated_at":"2017-04-07T20:34:38Z","body":"Initial actuator model for multirotor would be a 3 control-cycle delay (filter delays are on this order) + a lowpass filter with a time constant of like, 4ms or so.  All in all, better to be optimistic and under-correct down here than to over-correct."}}
{"actor":{"display_login":"mlyle"}}