{"action":"opened","number":37,"pull_request":{"url":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/37","id":76879291,"html_url":"https://github.com/ros-simulation/stage_ros/pull/37","diff_url":"https://github.com/ros-simulation/stage_ros/pull/37.diff","patch_url":"https://github.com/ros-simulation/stage_ros/pull/37.patch","issue_url":"https://api.github.com/repos/ros-simulation/stage_ros/issues/37","number":37,"state":"open","locked":false,"title":"Configure .world file when starting","user":{"login":"pschillinger","id":12489987,"avatar_url":"https://avatars.githubusercontent.com/u/12489987?v=3","gravatar_id":"","url":"https://api.github.com/users/pschillinger","html_url":"https://github.com/pschillinger","followers_url":"https://api.github.com/users/pschillinger/followers","following_url":"https://api.github.com/users/pschillinger/following{/other_user}","gists_url":"https://api.github.com/users/pschillinger/gists{/gist_id}","starred_url":"https://api.github.com/users/pschillinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pschillinger/subscriptions","organizations_url":"https://api.github.com/users/pschillinger/orgs","repos_url":"https://api.github.com/users/pschillinger/repos","events_url":"https://api.github.com/users/pschillinger/events{/privacy}","received_events_url":"https://api.github.com/users/pschillinger/received_events","type":"User","site_admin":false},"body":"This might be of interest for others as well. It would be nicer if we could just pass a .world string instead of a file to stage, but I wanted to touch as little as possible.\r\n\r\nI needed a way to dynamically configure a .world file when starting stage from a .launch file, e.g., spawn a parametrizable number of robots (in principle, idea similar to xacro for urdf). Since I didn't find a way, I added the following new option:\r\n\r\n`-c <script> [args] <worldfile>`\r\n`<script>` is a custom script to configure the .world file (see below)\r\n`[args]` are optional arguments to the script (all args following -c will be passed, so -u or -g need to preceed -c)\r\n`<worldfile>` as usual, the used .world file stays the last argument and will be as well passed to the script as target\r\n\r\nAn arbitrary custom script can be used for configuration as long as it writes its result to `<worldfile>`. For convenience and reference, I added the script `rosparam_instantiate.py` to this PR:\r\n```\r\nUsage: rosparam_instantiate.py worldfile_in rosparam_ns worldfile_out\r\n - worldfile_in:  Path to initial .world file.\r\n - rosparam_ns:   Namespace which contains the objects to be instantiated.\r\n - worldfile_out: Path to resulting .world file (loaded by stage).\r\n```\r\nIt accepts a rosparam namespace and instantiates all objects into the world `worldfile_in`. It can be used in a launchfile like the following example:\r\n\r\n```\r\n<arg name=\"test_color\" value=\"red\" />\r\n<rosparam ns=\"/stage_objs\" subst_value=\"True\">\r\ntest:\r\n    model_type: block\r\n    pose: [0,1,0,0]\r\n    color: $(arg test_color)\r\n</rosparam>\r\n\r\n<node pkg=\"stage_ros\" name=\"stageros\" type=\"stageros\" args=\"-c $(find stage_ros)/scripts/rosparam_instantiate.py $(find stage_ros)/world/intense.world /stage_objs $(find stage_ros)/world/tmp.world\"/>\r\n```\r\nwhich will spawn the following object:\r\n```\r\nblock\r\n(\r\n    name \"test\"\r\n    color \"red\"\r\n    pose [ 0 1 0 0 ]\r\n)\r\n```\r\nNote the following two aspects:\r\n- As shown above, it is possible to use roslaunch's substitution args to dynamically set values.\r\n- Since a namespace is expected instead of a param of type list, multiple different launchfiles can spawn objects into the same namespace. Just make sure the object names are unique, otherwise one will overwrite the other. If required, $(anon name) can help to keep names unique.","created_at":"2016-07-10T17:49:08Z","updated_at":"2016-07-10T17:49:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/37/commits","review_comments_url":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/37/comments","review_comment_url":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ros-simulation/stage_ros/issues/37/comments","statuses_url":"https://api.github.com/repos/ros-simulation/stage_ros/statuses/501275a3d58f5534d16a22f9c7adb09ef207d23e","head":{"label":"pschillinger:master","ref":"master","sha":"501275a3d58f5534d16a22f9c7adb09ef207d23e","user":{"login":"pschillinger","id":12489987,"avatar_url":"https://avatars.githubusercontent.com/u/12489987?v=3","gravatar_id":"","url":"https://api.github.com/users/pschillinger","html_url":"https://github.com/pschillinger","followers_url":"https://api.github.com/users/pschillinger/followers","following_url":"https://api.github.com/users/pschillinger/following{/other_user}","gists_url":"https://api.github.com/users/pschillinger/gists{/gist_id}","starred_url":"https://api.github.com/users/pschillinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pschillinger/subscriptions","organizations_url":"https://api.github.com/users/pschillinger/orgs","repos_url":"https://api.github.com/users/pschillinger/repos","events_url":"https://api.github.com/users/pschillinger/events{/privacy}","received_events_url":"https://api.github.com/users/pschillinger/received_events","type":"User","site_admin":false},"repo":{"id":63001956,"name":"stage_ros","full_name":"pschillinger/stage_ros","owner":{"login":"pschillinger","id":12489987,"avatar_url":"https://avatars.githubusercontent.com/u/12489987?v=3","gravatar_id":"","url":"https://api.github.com/users/pschillinger","html_url":"https://github.com/pschillinger","followers_url":"https://api.github.com/users/pschillinger/followers","following_url":"https://api.github.com/users/pschillinger/following{/other_user}","gists_url":"https://api.github.com/users/pschillinger/gists{/gist_id}","starred_url":"https://api.github.com/users/pschillinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pschillinger/subscriptions","organizations_url":"https://api.github.com/users/pschillinger/orgs","repos_url":"https://api.github.com/users/pschillinger/repos","events_url":"https://api.github.com/users/pschillinger/events{/privacy}","received_events_url":"https://api.github.com/users/pschillinger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pschillinger/stage_ros","description":"Package which contains ROS specific hooks and tools for the Stage simulator.","fork":true,"url":"https://api.github.com/repos/pschillinger/stage_ros","forks_url":"https://api.github.com/repos/pschillinger/stage_ros/forks","keys_url":"https://api.github.com/repos/pschillinger/stage_ros/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pschillinger/stage_ros/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pschillinger/stage_ros/teams","hooks_url":"https://api.github.com/repos/pschillinger/stage_ros/hooks","issue_events_url":"https://api.github.com/repos/pschillinger/stage_ros/issues/events{/number}","events_url":"https://api.github.com/repos/pschillinger/stage_ros/events","assignees_url":"https://api.github.com/repos/pschillinger/stage_ros/assignees{/user}","branches_url":"https://api.github.com/repos/pschillinger/stage_ros/branches{/branch}","tags_url":"https://api.github.com/repos/pschillinger/stage_ros/tags","blobs_url":"https://api.github.com/repos/pschillinger/stage_ros/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pschillinger/stage_ros/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pschillinger/stage_ros/git/refs{/sha}","trees_url":"https://api.github.com/repos/pschillinger/stage_ros/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pschillinger/stage_ros/statuses/{sha}","languages_url":"https://api.github.com/repos/pschillinger/stage_ros/languages","stargazers_url":"https://api.github.com/repos/pschillinger/stage_ros/stargazers","contributors_url":"https://api.github.com/repos/pschillinger/stage_ros/contributors","subscribers_url":"https://api.github.com/repos/pschillinger/stage_ros/subscribers","subscription_url":"https://api.github.com/repos/pschillinger/stage_ros/subscription","commits_url":"https://api.github.com/repos/pschillinger/stage_ros/commits{/sha}","git_commits_url":"https://api.github.com/repos/pschillinger/stage_ros/git/commits{/sha}","comments_url":"https://api.github.com/repos/pschillinger/stage_ros/comments{/number}","issue_comment_url":"https://api.github.com/repos/pschillinger/stage_ros/issues/comments{/number}","contents_url":"https://api.github.com/repos/pschillinger/stage_ros/contents/{+path}","compare_url":"https://api.github.com/repos/pschillinger/stage_ros/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pschillinger/stage_ros/merges","archive_url":"https://api.github.com/repos/pschillinger/stage_ros/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pschillinger/stage_ros/downloads","issues_url":"https://api.github.com/repos/pschillinger/stage_ros/issues{/number}","pulls_url":"https://api.github.com/repos/pschillinger/stage_ros/pulls{/number}","milestones_url":"https://api.github.com/repos/pschillinger/stage_ros/milestones{/number}","notifications_url":"https://api.github.com/repos/pschillinger/stage_ros/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pschillinger/stage_ros/labels{/name}","releases_url":"https://api.github.com/repos/pschillinger/stage_ros/releases{/id}","deployments_url":"https://api.github.com/repos/pschillinger/stage_ros/deployments","created_at":"2016-07-10T14:15:49Z","updated_at":"2016-07-10T14:15:50Z","pushed_at":"2016-07-10T17:33:01Z","git_url":"git://github.com/pschillinger/stage_ros.git","ssh_url":"git@github.com:pschillinger/stage_ros.git","clone_url":"https://github.com/pschillinger/stage_ros.git","svn_url":"https://github.com/pschillinger/stage_ros","homepage":null,"size":141,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ros-simulation:master","ref":"master","sha":"ffed6ca3e2508dada1e045435d1b8185ba6a7198","user":{"login":"ros-simulation","id":2349888,"avatar_url":"https://avatars.githubusercontent.com/u/2349888?v=3","gravatar_id":"","url":"https://api.github.com/users/ros-simulation","html_url":"https://github.com/ros-simulation","followers_url":"https://api.github.com/users/ros-simulation/followers","following_url":"https://api.github.com/users/ros-simulation/following{/other_user}","gists_url":"https://api.github.com/users/ros-simulation/gists{/gist_id}","starred_url":"https://api.github.com/users/ros-simulation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros-simulation/subscriptions","organizations_url":"https://api.github.com/users/ros-simulation/orgs","repos_url":"https://api.github.com/users/ros-simulation/repos","events_url":"https://api.github.com/users/ros-simulation/events{/privacy}","received_events_url":"https://api.github.com/users/ros-simulation/received_events","type":"Organization","site_admin":false},"repo":{"id":11009867,"name":"stage_ros","full_name":"ros-simulation/stage_ros","owner":{"login":"ros-simulation","id":2349888,"avatar_url":"https://avatars.githubusercontent.com/u/2349888?v=3","gravatar_id":"","url":"https://api.github.com/users/ros-simulation","html_url":"https://github.com/ros-simulation","followers_url":"https://api.github.com/users/ros-simulation/followers","following_url":"https://api.github.com/users/ros-simulation/following{/other_user}","gists_url":"https://api.github.com/users/ros-simulation/gists{/gist_id}","starred_url":"https://api.github.com/users/ros-simulation/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ros-simulation/subscriptions","organizations_url":"https://api.github.com/users/ros-simulation/orgs","repos_url":"https://api.github.com/users/ros-simulation/repos","events_url":"https://api.github.com/users/ros-simulation/events{/privacy}","received_events_url":"https://api.github.com/users/ros-simulation/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ros-simulation/stage_ros","description":"Package which contains ROS specific hooks and tools for the Stage simulator.","fork":false,"url":"https://api.github.com/repos/ros-simulation/stage_ros","forks_url":"https://api.github.com/repos/ros-simulation/stage_ros/forks","keys_url":"https://api.github.com/repos/ros-simulation/stage_ros/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ros-simulation/stage_ros/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ros-simulation/stage_ros/teams","hooks_url":"https://api.github.com/repos/ros-simulation/stage_ros/hooks","issue_events_url":"https://api.github.com/repos/ros-simulation/stage_ros/issues/events{/number}","events_url":"https://api.github.com/repos/ros-simulation/stage_ros/events","assignees_url":"https://api.github.com/repos/ros-simulation/stage_ros/assignees{/user}","branches_url":"https://api.github.com/repos/ros-simulation/stage_ros/branches{/branch}","tags_url":"https://api.github.com/repos/ros-simulation/stage_ros/tags","blobs_url":"https://api.github.com/repos/ros-simulation/stage_ros/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ros-simulation/stage_ros/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ros-simulation/stage_ros/git/refs{/sha}","trees_url":"https://api.github.com/repos/ros-simulation/stage_ros/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ros-simulation/stage_ros/statuses/{sha}","languages_url":"https://api.github.com/repos/ros-simulation/stage_ros/languages","stargazers_url":"https://api.github.com/repos/ros-simulation/stage_ros/stargazers","contributors_url":"https://api.github.com/repos/ros-simulation/stage_ros/contributors","subscribers_url":"https://api.github.com/repos/ros-simulation/stage_ros/subscribers","subscription_url":"https://api.github.com/repos/ros-simulation/stage_ros/subscription","commits_url":"https://api.github.com/repos/ros-simulation/stage_ros/commits{/sha}","git_commits_url":"https://api.github.com/repos/ros-simulation/stage_ros/git/commits{/sha}","comments_url":"https://api.github.com/repos/ros-simulation/stage_ros/comments{/number}","issue_comment_url":"https://api.github.com/repos/ros-simulation/stage_ros/issues/comments{/number}","contents_url":"https://api.github.com/repos/ros-simulation/stage_ros/contents/{+path}","compare_url":"https://api.github.com/repos/ros-simulation/stage_ros/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ros-simulation/stage_ros/merges","archive_url":"https://api.github.com/repos/ros-simulation/stage_ros/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ros-simulation/stage_ros/downloads","issues_url":"https://api.github.com/repos/ros-simulation/stage_ros/issues{/number}","pulls_url":"https://api.github.com/repos/ros-simulation/stage_ros/pulls{/number}","milestones_url":"https://api.github.com/repos/ros-simulation/stage_ros/milestones{/number}","notifications_url":"https://api.github.com/repos/ros-simulation/stage_ros/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ros-simulation/stage_ros/labels{/name}","releases_url":"https://api.github.com/repos/ros-simulation/stage_ros/releases{/id}","deployments_url":"https://api.github.com/repos/ros-simulation/stage_ros/deployments","created_at":"2013-06-27T22:48:11Z","updated_at":"2016-04-07T23:31:46Z","pushed_at":"2016-07-10T17:49:08Z","git_url":"git://github.com/ros-simulation/stage_ros.git","ssh_url":"git@github.com:ros-simulation/stage_ros.git","clone_url":"https://github.com/ros-simulation/stage_ros.git","svn_url":"https://github.com/ros-simulation/stage_ros","homepage":null,"size":141,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":31,"mirror_url":null,"open_issues_count":7,"forks":31,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/37"},"html":{"href":"https://github.com/ros-simulation/stage_ros/pull/37"},"issue":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/issues/37"},"comments":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/ros-simulation/stage_ros/statuses/501275a3d58f5534d16a22f9c7adb09ef207d23e"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":103,"deletions":4,"changed_files":3}}
{"actor":{"display_login":"pschillinger"}}