{"action":"created","comment":{"url":"https://api.github.com/repos/personalrobotics/prpy/pulls/comments/57521429","id":57521429,"diff_hunk":"@@ -0,0 +1,139 @@\n+import logging\n+from base import PerceptionModule, PerceptionMethod\n+\n+logger = logging.getLogger(__name__)\n+logger.setLevel(logging.INFO)\n+\n+class ChiselModule(PerceptionModule):\n+    \n+    def __init__(self, env, mesh_client=None, service_namespace=None,\n+               detection_frame=None, destination_frame=None, reference_link=None):\n+        \"\"\"\n+        @param env The OpenRAVE environment\n+        @param mesh_client An instance of the Chisel sensor system (if None, one is created)\n+        @param service_namespace The namespace to use for Chisel service calls (default: Chisel)\n+        @param destination_frame The tf frame the detected chisel kinbody should be transformed to\n+        (default map)\n+        @param reference_link A link on an OpenRAVE kinbody that corresponds to the tf frame\n+        specified by the destination_frame parameter. If not provided it is assumed that the \n+        transform from the destination_frame tf frame to the OpenRAVE environment is the identity\n+        \"\"\"\n+        import rospy\n+\n+        try:\n+            rospy.init_node('chisel_detector',anonymous=True)\n+        except rospy.exceptions.ROSException:\n+            pass\n+\n+        if service_namespace is None:\n+            service_namespace = 'Chisel'\n+\n+        if mesh_client is None:\n+            import openravepy\n+            mesh_client = openravepy.RaveCreateSensorSystem(env, 'mesh_marker')\n+\n+        self.mesh_client = mesh_client\n+        self.serv_ns = service_namespace\n+\n+        # Create a ROS camera used to generate a synthetic point cloud\n+        #  to mask known kinbodies from the chisel mesh\n+        from offscreen_render import ros_camera_sim\n+        self.camera = ros_camera_sim.RosCameraSim(env)\n+        self.camera.start('/head/kinect2/qhd')\n+        self.camera_bodies = []\n+\n+        self.reset_detection_srv = None\n+        \n+        if detection_frame is None:\n+            # By default, the Chisel kinbody is put in map frame\n+            #  not camera frame\n+            detection_frame='/map' \n+        self.detection_frame = detection_frame\n+\n+        if destination_frame is None:\n+            destination_frame = '/map'\n+        self.destination_frame = destination_frame\n+        self.reference_link = reference_link\n+\n+    @PerceptionMethod\n+    def DetectObject(self, robot, ignored_bodies=None, **kw_args):\n+        \"\"\"\n+        @param robot Required by the PerceptionMethod interface\n+        @param ignored_bodies A list of known kinbodies to be masked out\n+        of the chisel mesh\n+        \"\"\"\n+        env = robot.GetEnv()\n+        \n+        if ignored_bodies is None:\n+            ignored_bodies = []\n+\n+        # Dictionary mapping ignored bodies to start transform\n+        orig_bodies = {}\n+\n+        #Check if chisel kinbody in env\n+        already_in_env = False\n+        for body in env.GetBodies():\n+            if body.GetName() == 'Chisel/full_mesh':\n+                already_in_env = True\n+                break\n+\n+        #Remove chisel kinbody if present\n+        if already_in_env:\n+            chisel_kb = env.GetKinBody('Chisel/full_mesh')\n+            env.Remove(chisel_kb)\n+\n+        try:\n+            from kinbody_helper import transform_from_or\n+\n+            # Add any ignored bodies to the camera\n+            # We need to transform all these bodies from their pose\n+            #   in OpenRAVE to the equivalent pose in TF so that\n+            #   chisel can perform the appropriate masking\n+            #   Then we will transform them all back after the server\n+            #   performs the detection\n+            for b in ignored_bodies:\n+                if b not in self.camera_bodies:\n+                    with env:\n+                        orig_bodies[b] = b.GetTransform()\n+                    transform_from_or(kinbody=b, \n+                                      detection_frame=self.detection_frame,\n+                                      destination_frame=self.destination_frame,\n+                                      reference_link=self.reference_link)\n+                    self.camera.add_body(b)\n+                    self.camera_bodies.append(b)\n+\n+            #Reset Chisel\n+            if self.reset_detection_srv is None:\n+                import rospy, chisel_msgs.srv","path":"src/prpy/perception/chisel.py","position":107,"original_position":107,"commit_id":"1b4af44caa58e208dbdf5311fa4098eb2f9f2fde","original_commit_id":"1b4af44caa58e208dbdf5311fa4098eb2f9f2fde","user":{"login":"mkoval","id":142251,"avatar_url":"https://avatars.githubusercontent.com/u/142251?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoval","html_url":"https://github.com/mkoval","followers_url":"https://api.github.com/users/mkoval/followers","following_url":"https://api.github.com/users/mkoval/following{/other_user}","gists_url":"https://api.github.com/users/mkoval/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoval/subscriptions","organizations_url":"https://api.github.com/users/mkoval/orgs","repos_url":"https://api.github.com/users/mkoval/repos","events_url":"https://api.github.com/users/mkoval/events{/privacy}","received_events_url":"https://api.github.com/users/mkoval/received_events","type":"User","site_admin":false},"body":"Add `chisel_msgs` as a `package.xml` file.","created_at":"2016-03-27T00:33:07Z","updated_at":"2016-03-27T00:33:07Z","html_url":"https://github.com/personalrobotics/prpy/pull/281#discussion_r57521429","pull_request_url":"https://api.github.com/repos/personalrobotics/prpy/pulls/281","_links":{"self":{"href":"https://api.github.com/repos/personalrobotics/prpy/pulls/comments/57521429"},"html":{"href":"https://github.com/personalrobotics/prpy/pull/281#discussion_r57521429"},"pull_request":{"href":"https://api.github.com/repos/personalrobotics/prpy/pulls/281"}}},"pull_request":{"url":"https://api.github.com/repos/personalrobotics/prpy/pulls/281","id":64238691,"html_url":"https://github.com/personalrobotics/prpy/pull/281","diff_url":"https://github.com/personalrobotics/prpy/pull/281.diff","patch_url":"https://github.com/personalrobotics/prpy/pull/281.patch","issue_url":"https://api.github.com/repos/personalrobotics/prpy/issues/281","number":281,"state":"open","locked":false,"title":"Perception/chisel","user":{"login":"jeking04","id":3662021,"avatar_url":"https://avatars.githubusercontent.com/u/3662021?v=3","gravatar_id":"","url":"https://api.github.com/users/jeking04","html_url":"https://github.com/jeking04","followers_url":"https://api.github.com/users/jeking04/followers","following_url":"https://api.github.com/users/jeking04/following{/other_user}","gists_url":"https://api.github.com/users/jeking04/gists{/gist_id}","starred_url":"https://api.github.com/users/jeking04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeking04/subscriptions","organizations_url":"https://api.github.com/users/jeking04/orgs","repos_url":"https://api.github.com/users/jeking04/repos","events_url":"https://api.github.com/users/jeking04/events{/privacy}","received_events_url":"https://api.github.com/users/jeking04/received_events","type":"User","site_admin":false},"body":"I think we are ready to merge this. @Shushman and I checked that chisel is working. And I have verified simtrack also works with these changes. We should test vncc one more time to ensure I didn't introduce any bugs with by switching to use the ```kinbody_helper``` functions. But in the meantime, lets start gathering comments on this PR and working it through. ","created_at":"2016-03-26T13:56:17Z","updated_at":"2016-03-27T00:33:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4ba0bce54bb469f55a3e2ad389fb933df832f4cf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/personalrobotics/prpy/pulls/281/commits","review_comments_url":"https://api.github.com/repos/personalrobotics/prpy/pulls/281/comments","review_comment_url":"https://api.github.com/repos/personalrobotics/prpy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/personalrobotics/prpy/issues/281/comments","statuses_url":"https://api.github.com/repos/personalrobotics/prpy/statuses/1b4af44caa58e208dbdf5311fa4098eb2f9f2fde","head":{"label":"personalrobotics:perception/chisel","ref":"perception/chisel","sha":"1b4af44caa58e208dbdf5311fa4098eb2f9f2fde","user":{"login":"personalrobotics","id":4705918,"avatar_url":"https://avatars.githubusercontent.com/u/4705918?v=3","gravatar_id":"","url":"https://api.github.com/users/personalrobotics","html_url":"https://github.com/personalrobotics","followers_url":"https://api.github.com/users/personalrobotics/followers","following_url":"https://api.github.com/users/personalrobotics/following{/other_user}","gists_url":"https://api.github.com/users/personalrobotics/gists{/gist_id}","starred_url":"https://api.github.com/users/personalrobotics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/personalrobotics/subscriptions","organizations_url":"https://api.github.com/users/personalrobotics/orgs","repos_url":"https://api.github.com/users/personalrobotics/repos","events_url":"https://api.github.com/users/personalrobotics/events{/privacy}","received_events_url":"https://api.github.com/users/personalrobotics/received_events","type":"Organization","site_admin":false},"repo":{"id":21152391,"name":"prpy","full_name":"personalrobotics/prpy","owner":{"login":"personalrobotics","id":4705918,"avatar_url":"https://avatars.githubusercontent.com/u/4705918?v=3","gravatar_id":"","url":"https://api.github.com/users/personalrobotics","html_url":"https://github.com/personalrobotics","followers_url":"https://api.github.com/users/personalrobotics/followers","following_url":"https://api.github.com/users/personalrobotics/following{/other_user}","gists_url":"https://api.github.com/users/personalrobotics/gists{/gist_id}","starred_url":"https://api.github.com/users/personalrobotics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/personalrobotics/subscriptions","organizations_url":"https://api.github.com/users/personalrobotics/orgs","repos_url":"https://api.github.com/users/personalrobotics/repos","events_url":"https://api.github.com/users/personalrobotics/events{/privacy}","received_events_url":"https://api.github.com/users/personalrobotics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/personalrobotics/prpy","description":"Python utilities used by the Personal Robotics Laboratory.","fork":false,"url":"https://api.github.com/repos/personalrobotics/prpy","forks_url":"https://api.github.com/repos/personalrobotics/prpy/forks","keys_url":"https://api.github.com/repos/personalrobotics/prpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/personalrobotics/prpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/personalrobotics/prpy/teams","hooks_url":"https://api.github.com/repos/personalrobotics/prpy/hooks","issue_events_url":"https://api.github.com/repos/personalrobotics/prpy/issues/events{/number}","events_url":"https://api.github.com/repos/personalrobotics/prpy/events","assignees_url":"https://api.github.com/repos/personalrobotics/prpy/assignees{/user}","branches_url":"https://api.github.com/repos/personalrobotics/prpy/branches{/branch}","tags_url":"https://api.github.com/repos/personalrobotics/prpy/tags","blobs_url":"https://api.github.com/repos/personalrobotics/prpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/personalrobotics/prpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/personalrobotics/prpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/personalrobotics/prpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/personalrobotics/prpy/statuses/{sha}","languages_url":"https://api.github.com/repos/personalrobotics/prpy/languages","stargazers_url":"https://api.github.com/repos/personalrobotics/prpy/stargazers","contributors_url":"https://api.github.com/repos/personalrobotics/prpy/contributors","subscribers_url":"https://api.github.com/repos/personalrobotics/prpy/subscribers","subscription_url":"https://api.github.com/repos/personalrobotics/prpy/subscription","commits_url":"https://api.github.com/repos/personalrobotics/prpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/personalrobotics/prpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/personalrobotics/prpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/personalrobotics/prpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/personalrobotics/prpy/contents/{+path}","compare_url":"https://api.github.com/repos/personalrobotics/prpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/personalrobotics/prpy/merges","archive_url":"https://api.github.com/repos/personalrobotics/prpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/personalrobotics/prpy/downloads","issues_url":"https://api.github.com/repos/personalrobotics/prpy/issues{/number}","pulls_url":"https://api.github.com/repos/personalrobotics/prpy/pulls{/number}","milestones_url":"https://api.github.com/repos/personalrobotics/prpy/milestones{/number}","notifications_url":"https://api.github.com/repos/personalrobotics/prpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/personalrobotics/prpy/labels{/name}","releases_url":"https://api.github.com/repos/personalrobotics/prpy/releases{/id}","deployments_url":"https://api.github.com/repos/personalrobotics/prpy/deployments","created_at":"2014-06-24T04:44:39Z","updated_at":"2016-01-14T04:26:54Z","pushed_at":"2016-03-26T17:43:27Z","git_url":"git://github.com/personalrobotics/prpy.git","ssh_url":"git@github.com:personalrobotics/prpy.git","clone_url":"https://github.com/personalrobotics/prpy.git","svn_url":"https://github.com/personalrobotics/prpy","homepage":"","size":1284,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":48,"forks":7,"open_issues":48,"watchers":4,"default_branch":"master"}},"base":{"label":"personalrobotics:master","ref":"master","sha":"f27f4546d7a6bcaad1d916d50b5f3356017f52c7","user":{"login":"personalrobotics","id":4705918,"avatar_url":"https://avatars.githubusercontent.com/u/4705918?v=3","gravatar_id":"","url":"https://api.github.com/users/personalrobotics","html_url":"https://github.com/personalrobotics","followers_url":"https://api.github.com/users/personalrobotics/followers","following_url":"https://api.github.com/users/personalrobotics/following{/other_user}","gists_url":"https://api.github.com/users/personalrobotics/gists{/gist_id}","starred_url":"https://api.github.com/users/personalrobotics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/personalrobotics/subscriptions","organizations_url":"https://api.github.com/users/personalrobotics/orgs","repos_url":"https://api.github.com/users/personalrobotics/repos","events_url":"https://api.github.com/users/personalrobotics/events{/privacy}","received_events_url":"https://api.github.com/users/personalrobotics/received_events","type":"Organization","site_admin":false},"repo":{"id":21152391,"name":"prpy","full_name":"personalrobotics/prpy","owner":{"login":"personalrobotics","id":4705918,"avatar_url":"https://avatars.githubusercontent.com/u/4705918?v=3","gravatar_id":"","url":"https://api.github.com/users/personalrobotics","html_url":"https://github.com/personalrobotics","followers_url":"https://api.github.com/users/personalrobotics/followers","following_url":"https://api.github.com/users/personalrobotics/following{/other_user}","gists_url":"https://api.github.com/users/personalrobotics/gists{/gist_id}","starred_url":"https://api.github.com/users/personalrobotics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/personalrobotics/subscriptions","organizations_url":"https://api.github.com/users/personalrobotics/orgs","repos_url":"https://api.github.com/users/personalrobotics/repos","events_url":"https://api.github.com/users/personalrobotics/events{/privacy}","received_events_url":"https://api.github.com/users/personalrobotics/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/personalrobotics/prpy","description":"Python utilities used by the Personal Robotics Laboratory.","fork":false,"url":"https://api.github.com/repos/personalrobotics/prpy","forks_url":"https://api.github.com/repos/personalrobotics/prpy/forks","keys_url":"https://api.github.com/repos/personalrobotics/prpy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/personalrobotics/prpy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/personalrobotics/prpy/teams","hooks_url":"https://api.github.com/repos/personalrobotics/prpy/hooks","issue_events_url":"https://api.github.com/repos/personalrobotics/prpy/issues/events{/number}","events_url":"https://api.github.com/repos/personalrobotics/prpy/events","assignees_url":"https://api.github.com/repos/personalrobotics/prpy/assignees{/user}","branches_url":"https://api.github.com/repos/personalrobotics/prpy/branches{/branch}","tags_url":"https://api.github.com/repos/personalrobotics/prpy/tags","blobs_url":"https://api.github.com/repos/personalrobotics/prpy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/personalrobotics/prpy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/personalrobotics/prpy/git/refs{/sha}","trees_url":"https://api.github.com/repos/personalrobotics/prpy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/personalrobotics/prpy/statuses/{sha}","languages_url":"https://api.github.com/repos/personalrobotics/prpy/languages","stargazers_url":"https://api.github.com/repos/personalrobotics/prpy/stargazers","contributors_url":"https://api.github.com/repos/personalrobotics/prpy/contributors","subscribers_url":"https://api.github.com/repos/personalrobotics/prpy/subscribers","subscription_url":"https://api.github.com/repos/personalrobotics/prpy/subscription","commits_url":"https://api.github.com/repos/personalrobotics/prpy/commits{/sha}","git_commits_url":"https://api.github.com/repos/personalrobotics/prpy/git/commits{/sha}","comments_url":"https://api.github.com/repos/personalrobotics/prpy/comments{/number}","issue_comment_url":"https://api.github.com/repos/personalrobotics/prpy/issues/comments{/number}","contents_url":"https://api.github.com/repos/personalrobotics/prpy/contents/{+path}","compare_url":"https://api.github.com/repos/personalrobotics/prpy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/personalrobotics/prpy/merges","archive_url":"https://api.github.com/repos/personalrobotics/prpy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/personalrobotics/prpy/downloads","issues_url":"https://api.github.com/repos/personalrobotics/prpy/issues{/number}","pulls_url":"https://api.github.com/repos/personalrobotics/prpy/pulls{/number}","milestones_url":"https://api.github.com/repos/personalrobotics/prpy/milestones{/number}","notifications_url":"https://api.github.com/repos/personalrobotics/prpy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/personalrobotics/prpy/labels{/name}","releases_url":"https://api.github.com/repos/personalrobotics/prpy/releases{/id}","deployments_url":"https://api.github.com/repos/personalrobotics/prpy/deployments","created_at":"2014-06-24T04:44:39Z","updated_at":"2016-01-14T04:26:54Z","pushed_at":"2016-03-26T17:43:27Z","git_url":"git://github.com/personalrobotics/prpy.git","ssh_url":"git@github.com:personalrobotics/prpy.git","clone_url":"https://github.com/personalrobotics/prpy.git","svn_url":"https://github.com/personalrobotics/prpy","homepage":"","size":1284,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":48,"forks":7,"open_issues":48,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/personalrobotics/prpy/pulls/281"},"html":{"href":"https://github.com/personalrobotics/prpy/pull/281"},"issue":{"href":"https://api.github.com/repos/personalrobotics/prpy/issues/281"},"comments":{"href":"https://api.github.com/repos/personalrobotics/prpy/issues/281/comments"},"review_comments":{"href":"https://api.github.com/repos/personalrobotics/prpy/pulls/281/comments"},"review_comment":{"href":"https://api.github.com/repos/personalrobotics/prpy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/personalrobotics/prpy/pulls/281/commits"},"statuses":{"href":"https://api.github.com/repos/personalrobotics/prpy/statuses/1b4af44caa58e208dbdf5311fa4098eb2f9f2fde"}}}}