{"action":"created","issue":{"url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1273","labels_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1273/labels{/name}","comments_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1273/comments","events_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1273/events","html_url":"https://github.com/RobotLocomotion/drake/issues/1273","id":102284057,"number":1273,"title":"what's the best way to template our dynamical system class hierarchy methods?","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},"labels":[{"url":"https://api.github.com/repos/RobotLocomotion/drake/labels/type:%20question","name":"type: question","color":"207de5"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":59,"created_at":"2015-08-21T02:53:48Z","updated_at":"2015-12-15T09:04:12Z","closed_at":"2015-12-15T09:04:12Z","body":"I'm working on an initial C++ version of our systems class hierarchy.  We have a lot of templates flying around, and this is a complicated use case.  I'd like to discuss here to make the right decision.\r\n\r\nConsider this example, which works fine:\r\n```\r\nclass DrakeSystem {\r\npublic:\r\n  virtual VectorXd dynamics(double t, const VectorXd& x, const VectorXd& u)\r\n};\r\n\r\nclass Pendulum : public DrakeSystem {\r\npublic:\r\n  virtual VectorXd dynamics(double t, const VectorXd& x, const VectorXd& u)\r\n};\r\n```\r\n\r\nNow I want to template it, so that it can \r\n- accept a `TrigPoly` and/or `AutoDiffScalar` type (eg, something like `Matrix<Scalar,Dynamic,1>`)\r\n- bonus: take in an `Map<VectorXd>` instead of the `VectorXd`\r\n\r\nI'm not 100% sure I understand the best solution even in the base case, but the fact that these are (at least conceptually) virtual methods complicates everything.  \r\n\r\nI've played a little with templating the class instead of the methods -- that might work for us and could even be relatively clean.\r\n\r\nIs there an obviously correct solution for this?"},"comment":{"url":"https://api.github.com/repos/RobotLocomotion/drake/issues/comments/164692417","html_url":"https://github.com/RobotLocomotion/drake/issues/1273#issuecomment-164692417","issue_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/1273","id":164692417,"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-12-15T09:04:12Z","updated_at":"2015-12-15T09:04:12Z","body":"while there is more work to be done, we've agreed to move forward with #1512 "}}