robopal.envs.base module

class robopal.envs.base.MujocoEnv(robot: BaseRobot | str, *, control_freq: int = 200, render_mode: str = 'human', is_show_camera_in_cv: bool = False, is_render_camera_offscreen=False, camera_in_render: str = 'frontview', camera_in_window='free')[源代码]

基类:object

This environment is the base class.

参数:
  • robot(str) -- Load xml file from xml_path to build the mujoco model

  • render_mode(str) -- Choose if you use the renderer to render the scene or not

  • camera_in_render(str) -- Choose the camera

  • control_freq(int) -- Upper-layer control frequency

Note that high frequency will cause high time-lag :param is_show_camera_in_cv(bool): Use camera or not

close()[源代码]

close the environment.

forward()[源代码]

Forward the simulation.

get_body_id(name: str)[源代码]

Get body id from body name.

参数:

name -- body name

返回:

body id

get_body_jacp(name)[源代码]

Query the position jacobian of a mujoco body using a name string.

参数:

name -- The name of a mujoco body

返回:

The jacp value of the mujoco body

get_body_jacr(name)[源代码]

Query the rotation jacobian of a mujoco body using a name string.

参数:

name -- The name of a mujoco body

返回:

The jacr value of the mujoco body

get_body_pos(name: str)[源代码]

Get body position from body name.

参数:

name -- body name

返回:

body position

get_body_quat(name: str)[源代码]

Get body quaternion from body name.

参数:

name -- body name

返回:

body quaternion

get_body_rotm(name: str)[源代码]

Get body rotation matrix from body name.

参数:

name -- body name

返回:

body rotation matrix

get_body_xvelp(name: str) ndarray[源代码]

Get body velocity from body name.

参数:

name -- body name

返回:

translational velocity of the body

get_body_xvelr(name: str) ndarray[源代码]

Get body rotational velocity from body name.

参数:

name -- body name

返回:

rotational velocity of the body

get_camera_pos(name: str)[源代码]

Get camera position from camera name.

参数:

name -- camera name

返回:

camera position

get_geom_id(name: str | List[str])[源代码]

Get geometry id from its name.

参数:

name -- geometry name

返回:

geometry id

get_site_id(name: str)[源代码]

Get site id from site name.

参数:

name -- site name

返回:

site id

get_site_jacp(name)[源代码]

Query the position jacobian of a mujoco site using a name string.

参数:

name -- The name of a mujoco site

返回:

The jacp value of the mujoco site

get_site_jacr(name)[源代码]

Query the rotation jacobian of a mujoco site using a name string.

参数:

name -- The name of a mujoco site

返回:

The jacr value of the mujoco site

get_site_pos(name: str)[源代码]

Get body position from site name.

参数:

name -- site name

返回:

site position

get_site_quat(name: str)[源代码]

Get site quaternion from site name.

参数:

name -- site name

返回:

site quaternion

get_site_rotm(name: str)[源代码]

Get site rotation matrix from site name.

参数:

name -- site name

返回:

site rotation matrix

get_site_xvelp(name: str) ndarray[源代码]

Get site velocity from site name.

参数:

name -- site name

返回:

translational velocity of the site

get_site_xvelr(name: str) ndarray[源代码]

Get site rotational velocity from site name.

参数:

name -- site name

返回:

rotational velocity of the site

get_state()[源代码]

Get the saved state

is_contact(geom1: str | List[str], geom2: str | List[str], verbose=False) bool[源代码]

Check if two geom or geom list is in contact.

参数:
  • geom1 -- geom name/list

  • geom2 -- geom name/list

返回:

True/False

load_model_from_string(xml_string)[源代码]

Override model from string.

参数:

xml_string -- xml string

load_state(state: ndarray = None)[源代码]

Load the state of the mujoco model.

metadata = {'render_modes': [None, 'human', 'rgb_array', 'depth', 'unity']}
property name
render(mode=None) None | ndarray[源代码]

render one frame in mujoco

reset(seed: int | None = None, options: Dict[str, Any] | None = None)[源代码]

Reset the simulate environment, in order to execute next episode.

reset_object()[源代码]

Set pose of the object.

save_state()[源代码]

Save the state of the mujoco model.

set_actuator_ctrl(torque: ndarray, agent: str = 'agent0')[源代码]

Set joint torque.

set_joint_qpos(qpos: ndarray, agent: str = 'agent0')[源代码]

Set joint position.

set_object_pose(obj_joint_name: str = None, obj_pose: ndarray = None)[源代码]

Set pose of the object.

set_site_pos(site_name: str = None, site_pos: ndarray = None)[源代码]

Set pose of the object.

step(action: ndarray | Dict[str, ndarray] = None) Any[源代码]

This method will be called with one-step in mujoco :param action: Input action :return: None

robopal.envs.base.make(env_name: str, **kwargs) MujocoEnv[源代码]

Create an environment instance.