{"action":"created","issue":{"url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1122","labels_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1122/labels{/name}","comments_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1122/comments","events_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1122/events","html_url":"https://github.com/RobotLocomotion/drake/issues/1122","id":89572114,"number":1122,"title":"About the interconnection of system objects","user":{"login":"KeyDamo","id":7942338,"avatar_url":"https://avatars.githubusercontent.com/u/7942338?v=3","gravatar_id":"","url":"https://api.github.com/users/KeyDamo","html_url":"https://github.com/KeyDamo","followers_url":"https://api.github.com/users/KeyDamo/followers","following_url":"https://api.github.com/users/KeyDamo/following{/other_user}","gists_url":"https://api.github.com/users/KeyDamo/gists{/gist_id}","starred_url":"https://api.github.com/users/KeyDamo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KeyDamo/subscriptions","organizations_url":"https://api.github.com/users/KeyDamo/orgs","repos_url":"https://api.github.com/users/KeyDamo/repos","events_url":"https://api.github.com/users/KeyDamo/events{/privacy}","received_events_url":"https://api.github.com/users/KeyDamo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-19T14:00:51Z","updated_at":"2015-06-19T21:50:44Z","closed_at":null,"body":"This issue arises from an attempt to use a controller designed for plant 1 on plant 2.  Plant 1 is simplified representation of the real plant which is used to make control synthesis easy, whereas plant 2 is an accurate representation of the real plant which is used to perform accurate simulations.  So this is a typical control design workflow.\r\nThe specific problem is, I'm failing to make a **\"correct connection\"** between the controller (designed for plant 1) and plant 2.\r\nI arrived to this diagnosis as I tried this problem in a case where plant 1 and plant 2 were exactly equal objects (but not the same object, of course), yet I couldn't make controller for plant 1 work for plant 2.\r\nConsider the following script, which is a derivative of `/drake/examples/Glider/runLQR.m` (and is meant to run in the same directory).\r\n**Questions:** Why is this not working? What change should I apply to this script to obtain the expected result?\r\n**Comment:** When it comes to interconnecting systems, at least in this case, the user (sure enough not only me) would prefer that it was all down to making sure that the number or inputs of one matches the number of outputs of the other one.  One should not even care about whether they are row or column vectors.\r\nThanks for your attention.\r\n```matlab\r\np1 = GliderPlant;\r\np2 = GliderPlant;\r\n\r\n  trajs=load('glider_trajs.mat');\r\n  xtraj=trajs.xtraj;\r\n  utraj=trajs.utraj;\r\n\r\n  utraj = setOutputFrame(utraj,p1.getInputFrame);\r\n  xtraj = setOutputFrame(xtraj,p1.getStateFrame);\r\n\r\np1 = p1.setInputLimits(-inf,inf);\r\np2 = p2.setInputLimits(-inf,inf);\r\n\r\nc = GliderLQR(p1,xtraj,utraj);\r\nsys1=feedback(p1,c); \r\n\r\nc = setInputFrame (c ,p2.getOutputFrame); % Added\r\nc = setOutputFrame(c ,p2.getInputFrame ); % Added\r\np2= setInputFrame (p2, c.getOutputFrame); % Added\r\np2= setOutputFrame(p2, c.getInputFrame ); % Added\r\nsys2=feedback(p2,c);\r\n\r\n[yAcc1,xAcc1,lcmlog1] = simulate(sys1,xtraj.tspan,[-3.5; 0.2; 0; 0; 7+0.2*randn(1,1); 0;0]);\r\n[yAcc2,xAcc2,lcmlog2] = simulate(sys2,xtraj.tspan,[-3.5; 0.2; 0; 0; 7+0.2*randn(1,1); 0;0]);\r\ny1 = ppval(yAcc1.pp,yAcc1.pp.breaks);\r\ny2 = ppval(yAcc2.pp,yAcc2.pp.breaks);\r\n\r\nfigure;\r\nplot(y1(1,:),y1(2,:)); hold on; plot(y2(1,:),y2(2,:),'--'); % Should coincide!\r\nlegend('p1','p2')\r\n```"},"comment":{"url":"https://api.github.com/repos/RobotLocomotion/drake/issues/comments/113653479","html_url":"https://github.com/RobotLocomotion/drake/issues/1122#issuecomment-113653479","issue_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1122","id":113653479,"user":{"login":"RussTedrake","id":6442292,"avatar_url":"https://avatars.githubusercontent.com/u/6442292?v=3","gravatar_id":"","url":"https://api.github.com/users/RussTedrake","html_url":"https://github.com/RussTedrake","followers_url":"https://api.github.com/users/RussTedrake/followers","following_url":"https://api.github.com/users/RussTedrake/following{/other_user}","gists_url":"https://api.github.com/users/RussTedrake/gists{/gist_id}","starred_url":"https://api.github.com/users/RussTedrake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RussTedrake/subscriptions","organizations_url":"https://api.github.com/users/RussTedrake/orgs","repos_url":"https://api.github.com/users/RussTedrake/repos","events_url":"https://api.github.com/users/RussTedrake/events{/privacy}","received_events_url":"https://api.github.com/users/RussTedrake/received_events","type":"User","site_admin":false},"created_at":"2015-06-19T21:50:44Z","updated_at":"2015-06-19T21:50:44Z","body":"In fact, it could be precisely the coordinate system issue that i described.  The lqr controller is written in one coordinate system, and your plane in another.  Your added lines are potentially removing a necessary change of coordinates.  \n\nIf you instead set the input/output of p2 to match the input/output of p1 (not the output/input of c) that might work.\n\n(Can't test it myself now; reading from my phone)\n\n\n\n> On Jun 19, 2015, at 5:45 PM, Russ Tedrake <russt@csail.mit.edu> wrote:\n> \n> I saw the same (i believe) when i ran it earlier.  In that case, this is probably not a wiring interconnections issue but something more subtle about your resulting dynamical system.\n> \n> Bug reports are appreciated; if you can be specific about the error(s) that you see and what you expected then we can help debug more efficiently.\n> \n> \n> \n>> On Jun 19, 2015, at 2:44 PM, KeyDamo <notifications@github.com> wrote:\n>> \n>> This code runs, I know... but did you check the resulting plot?\n>> \n>> The two lines should coincide. Can you please confirm whether they coincide or not in your machine?\n>> Later, I have some specific instances to report about this thing of the I/O reference frames.\n>> \n>> —\n>> Reply to this email directly or view it on GitHub.\n>> \n"}}