{"action":"created","issue":{"url":"https://api.github.com/repos/RobotLocomotion/drake/issues/4352","repository_url":"https://api.github.com/repos/RobotLocomotion/drake","labels_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/4352/labels{/name}","comments_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/4352/comments","events_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/4352/events","html_url":"https://github.com/RobotLocomotion/drake/issues/4352","id":193289505,"number":4352,"title":"refactor CreateDefaultContext","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":[{"id":366762542,"url":"https://api.github.com/repos/RobotLocomotion/drake/labels/priority:%20medium","name":"priority: medium","color":"e99695","default":false},{"id":366761608,"url":"https://api.github.com/repos/RobotLocomotion/drake/labels/team:%20software%20core","name":"team: software core","color":"0052cc","default":false},{"id":355436350,"url":"https://api.github.com/repos/RobotLocomotion/drake/labels/type:%20design","name":"type: design","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":{"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},"assignees":[{"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}],"milestone":null,"comments":5,"created_at":"2016-12-03T14:25:52Z","updated_at":"2016-12-03T23:18:52Z","closed_at":null,"body":"Currently `System<T>::CreateDefaultContext()` does a few things:\r\n- Allocates memory (which also defines the derived types of the context elements, e.g. AcrobotState)\r\n- Sets the state to the default values.\r\n- Sets the parameters to the default values.  \r\n\r\nFor many applications, I think we need to be able to call these individually.  For instance, I need to be able to get the default state values without reallocating memory.  I propose changing the API to three methods:  `System<T>::AllocateContext()`, `System<T>::SetDefaultState(Context*)`, `System<T>::SetDefaultParameters(Context*)`.  I'm ok leaving `CreateDefaultContext()` as a convenience method, but do not want it to be virtual.  Derived classes must implement the individual methods, or use the base class defaults (e.g. states all zero).\r\n\r\nWould love any feedback (@david-german-tri , @sherm1 , @jwnimmer-tri, et al ).  Otherwise I will PR this next time I have a few minutes to code.  \r\n"},"comment":{"url":"https://api.github.com/repos/RobotLocomotion/drake/issues/comments/264672341","html_url":"https://github.com/RobotLocomotion/drake/issues/4352#issuecomment-264672341","issue_url":"https://api.github.com/repos/RobotLocomotion/drake/issues/4352","id":264672341,"user":{"login":"sherm1","id":4088016,"avatar_url":"https://avatars.githubusercontent.com/u/4088016?v=3","gravatar_id":"","url":"https://api.github.com/users/sherm1","html_url":"https://github.com/sherm1","followers_url":"https://api.github.com/users/sherm1/followers","following_url":"https://api.github.com/users/sherm1/following{/other_user}","gists_url":"https://api.github.com/users/sherm1/gists{/gist_id}","starred_url":"https://api.github.com/users/sherm1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sherm1/subscriptions","organizations_url":"https://api.github.com/users/sherm1/orgs","repos_url":"https://api.github.com/users/sherm1/repos","events_url":"https://api.github.com/users/sherm1/events{/privacy}","received_events_url":"https://api.github.com/users/sherm1/received_events","type":"User","site_admin":false},"created_at":"2016-12-03T23:18:52Z","updated_at":"2016-12-03T23:18:52Z","body":"> I think having the default values typed in twice is incorrect. \r\n\r\nMe too. I wasn't proposing that. After allocation there will be numbers occupying the allocated memory. I don't think they should be garbage but they could be NaNs or zeroes. I was suggesting that since you propose a method for computing the default values, the allocation methods could call that method when they are finished (automatically, not at user discretion). \r\n\r\n> And because the default values need to be obtainable without allocation ...\r\n\r\nThat doesn't appear to match your proposed `SetDefaultState(Context*)` since I assume it would need memory already allocated in Context in which to write the states. It is also likely that I am misunderstanding your proposal altogether. I'll stop speculating and wait for a PR to look at.\r\n"}}
{"actor":{"display_login":"sherm1"}}