예제 #1
0
    def __init__(self,
                 mps_left: Sequence[dict],
                 mps_right: Sequence[dict],
                 continuous_rew_fcn: bool = True,
                 **kwargs):
        """
        Constructor

        :param mps_left: left arm's movement primitives holding the dynamical systems and the goal states
        :param mps_right: right arm's movement primitives holding the dynamical systems and the goal states
        :param continuous_rew_fcn: specify if the continuous or an uninformative reward function should be used
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       checkJointLimits: bool = False,
                       collisionAvoidanceIK: bool = True,
                       observeCollisionCost: bool = True,
                       observePredictedCollisionCost: bool = False,
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor
        RcsSim.__init__(self,
                        envType='TargetTracking',
                        task_args=dict(continuous_rew_fcn=continuous_rew_fcn,
                                       mps_left=mps_left,
                                       mps_right=mps_right),
                        extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH,
                                                'TargetTracking'),
                        tasksLeft=mps_left,
                        tasksRight=mps_right,
                        **kwargs)
예제 #2
0
    def __init__(self, task_args: [dict, None] = None, max_dist_force: [float, None] = None, **kwargs):
        """
        Constructor

        :param task_args: arguments for the task construction, pass `None` to use default values
                          state_des: 4-dim np.ndarray
                          Q: 4x4-dim np.ndarray
                          R: 4x4-dim np.ndarray
        :param max_dist_force: maximum disturbance force, pass `None` for no disturbance
        :param kwargs: keyword arguments forwarded to the RcsSim
        """
        Serializable._init(self, locals())

        # Forward to RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="QuanserQube",
            task_args=task_args if task_args is not None else dict(),
            graphFileName="gQuanserQube_trqCtrl.xml",
            physicsConfigFile="pQuanserQube.xml",
            actionModelType="joint_acc",
            **kwargs,
        )

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #3
0
    def __init__(self,
                 task_args: dict,
                 ref_frame: str,
                 position_mps: bool,
                 mps_left: [Sequence[dict], None],
                 fixed_init_state: bool = False,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param ref_frame: reference frame for the MPs, e.g. 'world', 'box', or 'upperGoal'
        :param mps_left: left arm's movement primitives holding the dynamical systems and the goal states
        :param position_mps: `True` if the MPs are defined on position level, `False` if defined on velocity level
        :param fixed_init_state: use an init state space with only one state (e.g. for debugging)
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       taskCombinationMethod: str = 'mean',  # 'sum', 'mean',  'product', or 'softmax'
                       checkJointLimits: bool = False,
                       collisionAvoidanceIK: bool = True,
                       observeVelocities: bool = True,
                       observeCollisionCost: bool = True,
                       observePredictedCollisionCost: bool = False,
                       observeManipulabilityIndex: bool = False,
                       observeCurrentManipulability: bool = True,
                       observeDynamicalSystemDiscrepancy: bool = False,
                       observeTaskSpaceDiscrepancy: bool = True,
                       observeForceTorque: bool = True
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor
        RcsSim.__init__(
            self,
            envType='BoxShelving',
            extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH, 'BoxShelving'),
            hudColor='BLACK_RUBBER',
            task_args=task_args,
            refFrame=ref_frame,
            positionTasks=position_mps,
            tasksLeft=mps_left,
            **kwargs
        )

        # Initial state space definition
        if fixed_init_state:
            dafault_init_state = np.array([0., 0., 0., 0.8, 30.*np.pi/180, 90.*np.pi/180])  # [m, m, rad, m, rad, rad]
            self._init_space = SingularStateSpace(dafault_init_state,
                                                  labels=['$x$', '$y$', '$th$', '$z$', '$q_2$', '$q_4$'])
        else:
            min_init_state = np.array([-0.02, -0.02, -3.*np.pi/180., 0.78, 27.*np.pi/180, 77.*np.pi/180])
            max_init_state = np.array([0.02, 0.02, 3.*np.pi/180., 0.82, 33.*np.pi/180, 83.*np.pi/180])
            self._init_space = BoxSpace(min_init_state, max_init_state,  # [m, m, rad, m, rad, rad]
                                        labels=['$x$', '$y$', '$th$', '$z$', '$q_2$', '$q_4$'])
예제 #4
0
    def __init__(self,
                 task_args: dict,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, pass `None` for no disturbance
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       fixedInitState: bool = True,
                       collisionConfig: specification of the Rcs CollisionModel
        """
        Serializable._init(self, locals())

        if kwargs.get("collisionConfig", None) is None:
            collision_config = {
                "pairs": [
                    {
                        "body1": "Effector",
                        "body2": "Link2"
                    },
                    {
                        "body1": "Effector",
                        "body2": "Link1"
                    },
                ],
                "threshold":
                0.15,
                "predCollHorizon":
                20,
            }
        else:
            collision_config = kwargs.get("collisionConfig")

        # Forward to RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="Planar3Link",
            task_args=task_args,
            graphFileName=kwargs.pop(
                "graphFileName",
                "gPlanar3Link_trqCtrl.xml"),  # by default torque control
            positionTasks=kwargs.pop(
                "positionTasks", None
            ),  # invalid default value, positionTasks can be unnecessary
            collisionConfig=collision_config,
            **kwargs,
        )

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #5
0
    def __init__(self,
                 task_args: dict,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, pass `None` for no disturbance
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       fixedInitState: bool = True,
                       collisionConfig: specification of the Rcs CollisionModel
        """
        Serializable._init(self, locals())

        if kwargs.get('collisionConfig', None) is None:
            collision_config = {
                'pairs': [
                    {
                        'body1': 'Effector',
                        'body2': 'Link2'
                    },
                    {
                        'body1': 'Effector',
                        'body2': 'Link1'
                    },
                ],
                'threshold':
                0.15,
                'predCollHorizon':
                20
            }
        else:
            collision_config = kwargs.get('collisionConfig')

        # Forward to RcsSim's constructor
        RcsSim.__init__(
            self,
            task_args=task_args,
            envType='Planar3Link',
            graphFileName=kwargs.pop(
                'graphFileName',
                'gPlanar3Link_trqCtrl.xml'),  # by default torque control
            positionTasks=kwargs.pop(
                'positionTasks', None
            ),  # invalid default value, positionTasks can be unnecessary
            collisionConfig=collision_config,
            **kwargs)

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #6
0
    def __init__(self,
                 task_args: dict,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, set to None (default) for no disturbance
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       collisionConfig: specification of the Rcs CollisionModel
        """
        Serializable._init(self, locals())

        if kwargs.get('collisionConfig', None) is None:
            collision_config = {
                'pairs': [
                    {
                        'body1': 'Effector',
                        'body2': 'Link2'
                    },
                    {
                        'body1': 'Effector',
                        'body2': 'Link1'
                    },
                ],
                'threshold':
                0.15,
                'predCollHorizon':
                20
            }
        else:
            collision_config = kwargs.get('collisionConfig')

        # Forward to the RcsSim's constructor, nothing more needs to be done here
        RcsSim.__init__(self,
                        envType='Planar3Link',
                        graphFileName='gPlanar3Link.xml',
                        task_args=task_args,
                        collisionConfig=collision_config,
                        **kwargs)

        # Initial state space definition
        upright_init_state = np.array([0.1, 0.1, 0.1])  # [rad, rad, rad]
        self._init_space = SingularStateSpace(
            upright_init_state, labels=['$q_1$', '$q_2$', '$q_3$'])

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #7
0
    def __init__(self, task_args: dict, ref_frame: str, position_mps: bool,
                 mps_left: [Sequence[dict], None], **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param ref_frame: reference frame for the MPs, e.g. 'world', 'basket', or 'box'
        :param position_mps: `True` if the MPs are defined on position level, `False` if defined on velocity level
        :param mps_left: left arm's movement primitives holding the dynamical systems and the goal states
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       fixedInitState: bool = False,
                       taskCombinationMethod: str = 'sum',  # or 'mean', 'softmax', 'product'
                       checkJointLimits: bool = False,
                       collisionAvoidanceIK: bool = True,
                       observeVelocities: bool = False,
                       observeCollisionCost: bool = True,
                       observePredictedCollisionCost: bool = False,
                       observeManipulabilityIndex: bool = False,
                       observeCurrentManipulability: bool = True,
                       observeDynamicalSystemDiscrepancy: bool = False,
                       observeTaskSpaceDiscrepancy: bool = True,
                       observeForceTorque: bool = True
        """
        Serializable._init(self, locals())

        if kwargs.get('collisionConfig', None) is None:
            kwargs.update(
                collisionConfig={
                    'pairs': [
                        {
                            'body1': 'Hand',
                            'body2': 'Table'
                        },
                    ],
                    'threshold': 0.07
                })

        # Forward to the RcsSim's constructor
        RcsSim.__init__(self,
                        task_args=task_args,
                        envType='BoxLiftingSimple',
                        physicsConfigFile='pBoxLifting.xml',
                        extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH,
                                                'BoxLifting'),
                        hudColor='BLACK_RUBBER',
                        refFrame=ref_frame,
                        positionTasks=position_mps,
                        tasksLeft=mps_left,
                        **kwargs)
예제 #8
0
    def __init__(self, task_args: dict, **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param relativeZdTask: if `True`, the action model uses a relative velocity task for the striking motion
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       fixedInitState: bool = False,
                       checkJointLimits: bool = True,
                       collisionAvoidanceIK: bool = False,
                       observeVelocities: bool = False,
                       observeForceTorque: bool = False,
        """
        Serializable._init(self, locals())

        if kwargs.get("collisionConfig", None) is None:
            collision_config = {
                "pairs": [
                    {
                        "body1": "Club",
                        "body2": "Ground"
                    },
                ],
                "threshold": 0.05,
                "predCollHorizon": 20,
            }
        else:
            collision_config = kwargs.get("collisionConfig")

        # Forward to the RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="MiniGolf",
            task_args=task_args,
            state_mask_labels=("Ball_X", "Ball_Y", "base-m3", "m3-m4", "m4-m5",
                               "m5-m6", "m6-m7", "m7-m8", "m8-m9"),
            graphFileName="gMiniGolf_FTS.xml" if kwargs.get(
                "observeForceTorque", False) else kwargs.pop(
                    "graphFileName", "gMiniGolf.xml"),
            physicsConfigFile=kwargs.pop("physicsConfigFile", "pMiniGolf.xml"),
            collisionConfig=collision_config,
            extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH, "MiniGolf"),
            **kwargs,
        )
예제 #9
0
    def __init__(self,
                 task_args: dict,
                 ref_frame: str,
                 position_mps: bool,
                 mps_left: [Sequence[dict], None] = None,
                 mps_right: [Sequence[dict], None] = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param ref_frame: reference frame for the position and orientation MPs, e.g. 'world', 'table', or 'box'
        :param position_mps: `True` if the MPs are defined on position level, `False` if defined on velocity level
        :param mps_left: left arm's movement primitives holding the dynamical systems and the goal states
        :param mps_right: right arm's movement primitives holding the dynamical systems and the goal states
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       checkJointLimits: bool = False,
                       collisionAvoidanceIK: bool = True,
                       observeVelocities: bool = False,
                       observeCollisionCost: bool = True,
                       observePredictedCollisionCost: bool = False,
                       observeManipulabilityIndex: bool = False,
                       observeCurrentManipulability: bool = True,
                       observeDynamicalSystemDiscrepancy: bool = False,
                       observeTaskSpaceDiscrepancy: bool = True,
                       observeForceTorque: bool = True
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor
        RcsSim.__init__(
            self,
            envType='BoxFlipping',
            physicsConfigFile='pBoxFlipping.xml',
            extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH, 'BoxFlipping'),
            hudColor='BLACK_RUBBER',
            task_args=task_args,
            refFrame=ref_frame,
            positionTasks=position_mps,
            taskCombinationMethod='sum',
            tasksLeft=mps_left,
            tasksRight=mps_right,
            **kwargs
        )
예제 #10
0
    def __init__(self, task_args: dict, ref_frame: str, **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param ref_frame: reference frame for the MPs, e.g. 'world', or 'table'
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       fixedInitState: bool = False,
                       taskCombinationMethod: str = 'sum',  # or 'mean', 'softmax', 'product'
                       checkJointLimits: bool = False,
                       collisionAvoidanceIK: bool = True,
                       observeVelocities: bool = True,
                       observeCollisionCost: bool = True,
                       observePredictedCollisionCost: bool = False,
                       observeManipulabilityIndex: bool = False,
                       observeCurrentManipulability: bool = True,
                       observeDynamicalSystemDiscrepancy: bool = False,
                       observeTaskSpaceDiscrepancy: bool = True,
                       observeForceTorque: bool = True
        """
        Serializable._init(self, locals())

        # collision_config = {
        #     'pairs': [
        #         {'body1': 'Hook_L', 'body2': 'Table'},
        #         {'body1': 'Hook_L', 'body2': 'Slider'},
        #         {'body1': 'Hook_L', 'body2': 'Hook_R'},
        #     ],
        #     'threshold': 0.15,
        #     'predCollHorizon': 20
        # }

        # Forward to the RcsSim's constructor
        RcsSim.__init__(self,
                        task_args=task_args,
                        envType='BallInTube',
                        physicsConfigFile='pBallInTube.xml',
                        extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH,
                                                'BallInTube'),
                        collisionConfig={'file': 'collisionModel.xml'},
                        hudColor='BLACK_RUBBER',
                        refFrame=ref_frame,
                        **kwargs)
예제 #11
0
    def reset(self, init_state: np.ndarray = None, domain_param: dict = None) -> np.ndarray:
        # Call the parent class
        obs = RcsSim.reset(self, init_state, domain_param)

        # Apply a initial ball velocity if given
        if self._init_ball_vel is not None:
            self._impl.applyBallVelocity(self._init_ball_vel)
            # We could try to adapt obs here, but it's not really necessary

        return obs
예제 #12
0
    def __init__(self,
                 task_args: dict,
                 init_ball_vel: np.ndarray = None,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param init_ball_vel: initial ball velocity applied to ball on `reset()`
        :param max_dist_force: maximum disturbance force, set to `None` (default) for no disturbance
        :param kwargs: keyword arguments forwarded to the `BallOnPlateSim` constructor
        """
        if init_ball_vel is not None:
            if not init_ball_vel.size() == 2:
                raise pyrado.ShapeErr(given=init_ball_vel, expected_match=np.empty(2))

        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor
        RcsSim.__init__(self,
                        envType='BallOnPlate',
                        graphFileName='gBotKuka.xml',
                        physicsConfigFile='pBallOnPlate.xml',
                        task_args=task_args,
                        **kwargs)

        # Store BallOnPlateSim specific vars
        self._init_ball_vel = init_ball_vel
        l_plate = 0.5  # [m], see the config XML-file
        min_init_state = np.array([0.7*l_plate/2, -np.pi])
        max_init_state = np.array([0.8*l_plate/2, np.pi])
        self._init_space = Polar2DPosSpace(min_init_state, max_init_state, labels=['$r$', r'$\phi$'])

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #13
0
    def __init__(self,
                 action_model_type: str,
                 mps: Sequence[dict] = None,
                 task_args: dict = None,
                 **kwargs):
        """
        Constructor

        :param action_model_type: `ds_activation` or `ik_activation`
        :param mps: movement primitives holding the dynamical systems and the goal states
        :param task_args: arguments for the task construction
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       positionTasks: bool = True,
                       taskCombinationMethod: str = 'sum', # or 'mean', 'softmax', 'product'
        """
        Serializable._init(self, locals())

        task_spec_ik = [
            dict(x_des=np.array([0.0, 0.0, 0.0])),
            dict(x_des=np.array([0.0, 0.0, 0.0])),
            dict(x_des=np.array([0.0, 0.0, 0.0])),
            dict(x_des=np.array([0.0, 0.0, 0.0])),
        ]

        # Forward to RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="MPBlending",
            task_args=task_args,
            graphFileName="gMPBlending.xml",
            actionModelType=action_model_type,
            tasks=mps,
            positionTasks=kwargs.pop(
                "positionTasks", None
            ),  # invalid default value, positionTasks can be unnecessary
            taskSpecIK=task_spec_ik,
            **kwargs,
        )
예제 #14
0
    def __init__(self,
                 task_args: dict,
                 init_ball_vel: np.ndarray = None,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param init_ball_vel: initial ball velocity applied to ball on `reset()`
        :param max_dist_force: maximum disturbance force, set to `None` (default) for no disturbance
        :param kwargs: keyword arguments forwarded to the `BallOnPlateSim` constructor
        """
        if init_ball_vel is not None:
            if not init_ball_vel.size() == 2:
                raise pyrado.ShapeErr(given=init_ball_vel,
                                      expected_match=np.empty(2))

        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="BallOnPlate",
            task_args=task_args,
            graphFileName="gBotKuka.xml",
            physicsConfigFile="pBallOnPlate.xml",
            **kwargs,
        )

        # Initial ball velocity
        self._init_ball_vel = init_ball_vel

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #15
0
    def __init__(self,
                 state_des: np.ndarray = None,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        :param state_des: desired state for the task
        :param max_dist_force: maximum disturbance force, set to None (default) for no disturbance
        :param kwargs: keyword arguments forwarded to the RcsSim
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor, nothing more needs to be done here
        RcsSim.__init__(self,
                        envType='QuanserQube',
                        graphFileName='gQuanserQube_trqCtrl.xml',
                        physicsConfigFile='pQuanserQube.xml',
                        task_args=dict(state_des=state_des),
                        **kwargs)

        # Store QQubeRcsSim specific vars
        max_init_state = np.array([
            5. / 180 * np.pi,
            3. / 180 * np.pi,  # [rad, rad, ...
            0.5 / 180 * np.pi,
            0.5 / 180 * np.pi
        ])  # ... rad/s, rad/s]
        self._init_space = BoxSpace(-max_init_state,
                                    max_init_state,
                                    labels=[
                                        r'$\theta$', r'$\alpha$',
                                        r'$\dot{\theta}$', r'$\dot{\alpha}$'
                                    ])

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #16
0
    def __init__(self, task_args: dict, ref_frame: str, **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param ref_frame: reference frame for the MPs, e.g. 'world', 'basket', or 'box'
        :param kwargs: keyword arguments which are available for all task-based `RcsSim`
                       fixedInitState: bool = False,
                       taskCombinationMethod: str = 'sum',  # or 'mean', 'softmax', 'product'
                       checkJointLimits: bool = True,
                       collisionAvoidanceIK: bool = True,
                       observeVelocities: bool = True,
                       observeCollisionCost: bool = True,
                       observePredictedCollisionCost: bool = False,
                       observeManipulabilityIndex: bool = False,
                       observeCurrentManipulability: bool = True,
                       observeDynamicalSystemDiscrepancy: bool = False,
                       observeTaskSpaceDiscrepancy: bool = True,
                       observeForceTorque: bool = True
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="BoxLifting",
            task_args=task_args,
            physicsConfigFile="pBoxLifting.xml",
            extraConfigDir=osp.join(rcsenv.RCSPYSIM_CONFIG_PATH, "BoxLifting"),
            hudColor="BLACK_RUBBER",
            refFrame=ref_frame,
            **kwargs,
        )
예제 #17
0
    def __init__(self,
                 mps: Sequence[dict] = None,
                 task_args: dict = None,
                 max_dist_force: float = None,
                 position_mps: bool = True,
                 **kwargs):
        """
        Constructor

        :param mps: movement primitives holding the dynamical systems and the goal states
        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, set to None (default) for no disturbance
        :param position_mps: `True` if the MPs are defined on position level, `False` if defined on velocity level,
                             only matters if `actionModelType='activation'`
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       taskCombinationMethod='sum'  # or 'mean' or 'product'
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor, nothing more needs to be done here
        RcsSim.__init__(
            self,
            envType='MPBlending',
            task_args=task_args,
            actionModelType='activation',
            tasks=mps,
            positionTasks=position_mps,
            **kwargs
        )

        # Store Planar3Link specific vars
        center_init_state = np.array([0., 0.])  # [m]
        self._init_space = SingularStateSpace(center_init_state, labels=['$x$', '$y$'])

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #18
0
    def __init__(self,
                 task_args: dict,
                 collision_config: dict = None,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, pass `None` for no disturbance
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       collisionConfig: specification of the Rcs CollisionModel
        """
        Serializable._init(self, locals())

        # Forward to RcsSim's constructor
        RcsSim.__init__(self,
                        task_args=task_args,
                        envType='PlanarInsert',
                        physicsConfigFile='pPlanarInsert.xml',
                        collisionConfig=collision_config,
                        **kwargs)

        if kwargs.get('collisionConfig', None) is None:
            collision_config = {
                'pairs': [
                    {
                        'body1': 'Effector',
                        'body2': 'Link3'
                    },
                    {
                        'body1': 'Effector',
                        'body2': 'Link2'
                    },
                    {
                        'body1': 'UpperWall',
                        'body2': 'Link4'
                    },
                    {
                        'body1': 'LowerWall',
                        'body2': 'Link4'
                    },
                    {
                        'body1': 'LowerWall',
                        'body2': 'Link3'
                    },
                    {
                        'body1': 'LowerWall',
                        'body2': 'Link2'
                    },
                ],
                'threshold':
                0.05
            }
        else:
            collision_config = kwargs.get('collisionConfig')

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #19
0
    def __init__(self,
                 task_args: dict,
                 collision_config: dict = None,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, pass `None` for no disturbance
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       collisionConfig: specification of the Rcs CollisionModel
        """
        Serializable._init(self, locals())

        # Forward to RcsSim's constructor
        RcsSim.__init__(
            self,
            envType="PlanarInsert",
            task_args=task_args,
            physicsConfigFile="pPlanarInsert.xml",
            collisionConfig=collision_config,
            **kwargs,
        )

        if kwargs.get("collisionConfig", None) is None:
            collision_config = {
                "pairs": [
                    {
                        "body1": "Effector",
                        "body2": "Link3"
                    },
                    {
                        "body1": "Effector",
                        "body2": "Link2"
                    },
                    {
                        "body1": "UpperWall",
                        "body2": "Link4"
                    },
                    {
                        "body1": "LowerWall",
                        "body2": "Link4"
                    },
                    {
                        "body1": "LowerWall",
                        "body2": "Link3"
                    },
                    {
                        "body1": "LowerWall",
                        "body2": "Link2"
                    },
                ],
                "threshold":
                0.05,
            }
        else:
            collision_config = kwargs.get("collisionConfig")

        # Setup disturbance
        self._max_dist_force = max_dist_force
예제 #20
0
    def __init__(self,
                 task_args: dict,
                 collision_config: dict = None,
                 max_dist_force: float = None,
                 **kwargs):
        """
        Constructor

        .. note::
            This constructor should only be called via the subclasses.

        :param task_args: arguments for the task construction
        :param max_dist_force: maximum disturbance force, set to None (default) for no disturbance
        :param kwargs: keyword arguments forwarded to `RcsSim`
                       collisionConfig: specification of the Rcs CollisionModel
        """
        Serializable._init(self, locals())

        # Forward to the RcsSim's constructor, nothing more needs to be done here
        RcsSim.__init__(self,
                        envType='PlanarInsert',
                        physicsConfigFile='pPlanarInsert.xml',
                        task_args=task_args,
                        collisionConfig=collision_config,
                        **kwargs)

        if kwargs.get('collisionConfig', None) is None:
            collision_config = {
                'pairs': [
                    {
                        'body1': 'Effector',
                        'body2': 'Link3'
                    },
                    {
                        'body1': 'Effector',
                        'body2': 'Link2'
                    },
                    {
                        'body1': 'UpperWall',
                        'body2': 'Link4'
                    },
                    {
                        'body1': 'LowerWall',
                        'body2': 'Link4'
                    },
                    {
                        'body1': 'LowerWall',
                        'body2': 'Link3'
                    },
                    {
                        'body1': 'LowerWall',
                        'body2': 'Link2'
                    },
                ],
                'threshold':
                0.05
            }
        else:
            collision_config = kwargs.get('collisionConfig')

        # Initial state space definition
        init_state = np.array([-40, 30, 30, 30, -30
                               ]) / 180 * np.pi  # [rad, rad, rad]
        self._init_space = SingularStateSpace(
            init_state, labels=['$q_1$', '$q_2$', '$q_3$', '$q_4$', '$q_5$'])

        # Setup disturbance
        self._max_dist_force = max_dist_force