Ejemplo n.º 1
0
    def enabled(self, enabled: bool) -> None:

        if self.collision_model:
            if not self._enabled and enabled:
                assert self.id not in scene_service.collision_ids()
                scene_service.upsert_collision(self.collision_model, self.pose)
            if self._enabled and not enabled:
                # TODO not sure if it's intentional, but stopped scene service 0.4.2 returns empty list of collision IDs
                # assert self.id in scene_service.collision_ids()
                scene_service.delete_collision_id(self.id)
        self._enabled = enabled
Ejemplo n.º 2
0
def main() -> None:

    # robots
    aubo = Aubo(uid("rbt"), "Whatever", Pose(), RobotSettings("http://127.0.0.1:13000", "aubo"))
    simatic = Aubo(uid("rbt"), "Whatever", Pose(), RobotSettings("http://127.0.0.1:13001", "simatic"))

    # objects with pose, with 'System' and 'Configurations' controllers
    barcode = Barcode(uid("srv"), "Whatever", Pose(), settings=Settings("http://127.0.0.1:14000", "simulator"))
    search = Search(uid("srv"), "Whatever", Pose(), settings=Settings("http://127.0.0.1:12000", "simulator"))
    ict = Ict(uid("srv"), "Whatever", Pose(), settings=Settings("http://127.0.0.1:19000", "simulator"))

    # objects without pose, without 'System' and 'Configurations' controllers
    interaction = Interaction(uid("srv"), "Whatever", SimpleSettings("http://127.0.0.1:17000"))
    statistic = Statistic(uid("srv"), "Whatever", SimpleSettings("http://127.0.0.1:16000"))

    # Add @action decorator to all actions of each object using patch_object_actions.
    # It has to be called exactly once for each type!
    # Certain functions of Execution unit (as e.g. pausing script execution) would not work without this step.
    # Note: in a generated script, this is done within the Resources context manager.
    # Side effect: a lot of JSON data will be printed out to the console when running the script manually.
    patch_object_actions(Aubo)
    patch_object_actions(Barcode)
    patch_object_actions(Search)
    patch_object_actions(Ict)
    patch_object_actions(Interaction)
    patch_object_actions(Statistic)

    scene_service.delete_all_collisions()
    scene_service.upsert_collision(Box("box_id", 0.1, 0.1, 0.1), Pose())
    scene_service.start()  # this is normally done by auto-generated Resources class

    aubo.move("suction", Pose(), MoveTypeEnum.SIMPLE, safe=False)
    simatic.set_joints(ProjectRobotJoints("", "", [Joint("x", 0), Joint("y", 0)]), MoveTypeEnum.SIMPLE)
    barcode.scan()
    search.set_search_parameters(SearchEngineParameters(search_log_level=SearchLogLevel(LogLevel.DEBUG)))
    search.grab_image()
    interaction.add_notification("Test", NotificationLevelEnum.INFO)

    try:
        statistic.get_groups()
    except rest.RestHttpException as e:
        # service returned error code
        print(f"The error code is {e.error_code}.")
    except rest.RestException as e:
        # request totally failed (timeout, connection error, etc)
        print(str(e))

    if ict.ready():
        test = ict.test("OK")
        print(test)

    scene_service.stop()  # this is normally done by auto-generated Resources class
Ejemplo n.º 3
0
    def __init__(
        self,
        obj_id: str,
        name: str,
        pose: Pose,
        collision_model: Optional[Models] = None,
        settings: Optional[Settings] = None,
    ) -> None:

        super(GenericWithPose, self).__init__(obj_id, name, settings)

        self._pose = pose
        self.collision_model = copy.deepcopy(collision_model)
        self._enabled = True
        if self.collision_model:
            # originally, each model has id == object type (e.g. BigBox) but here we need to set it to something unique
            self.collision_model.id = self.id
            scene_service.upsert_collision(self.collision_model, pose)
Ejemplo n.º 4
0
 def pose(self, pose: Pose) -> None:
     self._pose = pose
     if self.collision_model and self._enabled:
         scene_service.upsert_collision(self.collision_model, pose)