Envs

CausalWorld

class causal_world.envs.CausalWorld(task=None, skip_frame=10, enable_visualization=False, seed=0, action_mode='joint_positions', observation_mode='structured', normalize_actions=True, normalize_observations=True, max_episode_length=None, data_recorder=None, camera_indicies=array([0, 1, 2]), wrappers=None)[source]
__init__(task=None, skip_frame=10, enable_visualization=False, seed=0, action_mode='joint_positions', observation_mode='structured', normalize_actions=True, normalize_observations=True, max_episode_length=None, data_recorder=None, camera_indicies=array([0, 1, 2]), wrappers=None)[source]

The causal world encapsulates the environment of the agent, where you can perform actions, intervene, reset the state..etc

Parameters
  • task – (causal_world.BaseTask) this is the task produced by one of the available task generators or the custom task created.

  • skip_frame – (int) the low level controller is running @250Hz which corresponds to skip frame of 1, a skip frame of 250 corresponds to frequency of 1Hz

  • enable_visualization – (bool) this is a boolean which indicates if a GUI is enabled or the environment should operate in a headless mode.

  • seed – (int) this is the random seed used in the environment.

  • action_mode – (str) action_modes available are “joint_positions”, “end_effector_positions” which is non deterministic at the moment since it uses IK of pybullet and lastly “joint_torques”.

  • observation_mode – (str) observation modes available are “structured” or “pixel” modes. The structured observations are specified in the task generator itself. For the “pixel” mode you will get maximum 6 images concatenated where the first half are the current images rendered in the platform and the second half are the goal images rendered from the same point of view.

  • normalize_actions – (bool) this is a boolean which specifies whether the actions passed to the step function are normalized or not.

  • normalize_observations – (bool) this is a boolean which specifies whether the observations returned should be normalized or not.

  • max_episode_length – (int) it specifies what is the episode length of the task, by default this will be calculated according to how many objects are in the arena (5 secs * number of objects).

  • data_recorder – (causal_world.DataRecorder) passed only when you want to log and record the episodes which can be used further in imitation learning for instance.

  • camera_indicies – (list) maximum of 3 elements where each element is from 0 to , specifies which cameras to return in the observations and the order as well.

  • wrappers – (causal_world.wrappers) should not be used for now.

add_ground_truth_state_to_info()[source]

Adds the ground truth state variables in the info dict returned after stepping through the environment, can be used in representation learning.

Returns

None

add_wrapper_info(wrapper_dict)[source]

Adds wrapper info to the wrappers property such that the world can be saved with the wrappers and loaded afterwards.

Parameters

wrapper_dict – (dict) a dict specifying the wrapper info.

Returns

None

are_actions_normalized()[source]
Returns

(bool) whether the actions are normalized or not.

are_observations_normalized()[source]
Returns

(bool) whether the observations are normalized or not.

close()[source]

closes the environment in a safe manner should be called at the end of the program.

Returns

None

do_intervention(interventions_dict, check_bounds=True)[source]

Performs interventions on variables specified by the intervention dict to intervene on.

Parameters
  • interventions_dict – (dict) The variables to intervene on and the values of the intervention.

  • check_bounds – (bool) specified when not in train mode and a check for the intervention if its allowed or not is needed.

Returns

(bool) indicating if an intervention was successful or not.

Returns

(nd.array) the observations after performing the intervention.

do_single_random_intervention()[source]

Performs a single random intervention on one of the available variables to intervene on, which are the variables included in space A or space B. Depending if the env is using train_space_only or not.

Returns

(dict) The intervention that was performed.

Returns

(bool) indicating if an intervention was successful or not.

Returns

(nd.array) the observations after performing the intervention.

expose_potential_partial_solution()[source]

Adds the partial solution field in the info dict returned after stepping Through the environment.

Returns

None

get_action_mode()[source]
Returns

(str) returns which action mode the causal_world is operating in.

get_current_state_variables()[source]

Returns a snapshot of the world at that point in time, includes all variables that can be intervened on and exposed in the environment.

Returns

(dict) specifying all state variables along with their values.

get_intervention_space_a()[source]
Returns

(dict) specifies the variables and their corresponding bounds in space A.

get_intervention_space_a_b()[source]
Returns

(dict) specifies the variables and their corresponding bounds in space A_B.

get_intervention_space_b()[source]
Returns

(dict) specifies the variables and their corresponding bounds in space B.

get_joint_positions_raised()[source]
Returns

(nd.array) specifying the 9 joint positions of the raised fingers.

get_robot()[source]
Returns

(causal_world.TriFingerRobot) returns the robot object of the causal_world.

get_stage()[source]
Returns

(causal_world.Stage) returns the stage object of the causal_world.

get_state()[source]

Returns the current state of the environment, can be used to save the state.

Note: Setting state and getting state doesnt work when there is an intermediate intervention

Returns

(dict) specifying the state elements as a snapshot.

get_task()[source]
Returns

(causal_world.BaseTask) returns the task object of the causal_world.

get_tracker()[source]
Returns

(causal_world.Tracker) returns the tracker object of the causal_world.

get_variable_space_used()[source]
Returns

(str) specifying the space that is currently used by the environment.

get_world_params()[source]

Returns the current params of the world that were supposed to be passed to the CausalWorld object or manipulated in a further function.

Returns

(dict) describing the params that can be used to recreate the CausalWorld object not including the task.

render(mode='human')[source]

Returns an RGB image taken from above the platform.

Parameters

mode – (str) not taken in account now.

Returns

(nd.array) an RGB image taken from above the platform.

reset()[source]

Resets the environment to the current starting state of the environment.

Returns

(nd.array) specifies the observations returned after resetting the environment. Again, it follows the observation_mode specified.

reset_default_state()[source]

Used to reset the environment starting state to the default starting state specified by the task generator. Can be used if an intervention on the starting state was performed and its needed to go back to the default starting state that was specified before.

Returns

None

sample_new_goal(level=None)[source]

Used to sample a new goal in the task subspace, the environment is operating in, so goals are still restricted depends on the task generator that was used.

Parameters

level – (int) this is not used at the moment.

Returns

None

save_world(log_relative_path)[source]

saves the tracker object of the world that tracks different aspects of the current running world.

Parameters

log_relative_path – (str) relative path to save the tracker object in

Returns

None

seed(seed=None)[source]

Used to set the seed of the environment, to reproduce the same randomness.

Parameters

seed – (int) specifies the seed number

Returns

(int in list) the numpy seed that you can use further.

set_action_mode(action_mode)[source]

used to set or change the action mode.

Parameters

action_mode – (str) action mode to operate in.

Returns

None

set_intervention_space(variables_space)[source]
Parameters

variables_space – (str) “space_a”, “space_b” or “space_a_b”

Returns

set_skip_frame(new_skip_frame)[source]
Parameters

new_skip_frame – (int) the new skip frame of the environment.

Returns

set_starting_state(interventions_dict=None, check_bounds=True)[source]

Used to intervene on the starting state of the environment.

Parameters
  • interventions_dict – (dict) specifies the state variables that you want to intervene on as well as values of the interventions.

  • check_bounds – (bool) specified when not in train mode and a check for the intervention if its allowed or not is needed.

Returns

(bool) indicating if an intervention was successful or not.

set_state(new_full_state)[source]

Restores the state of the environment which is passed as an argument.

Note: Setting state and getting state doesnt work when there is an intermediate intervention

Parameters

new_full_state – (dict) specifying the state elements as a snapshot.

Returns

None

step(action)[source]

Used to step through the enviroment.

Parameters

action – (nd.array) specifies which action should be taken by the robot, should follow the same action mode specified.

Returns

(nd.array) specifies the observations returned after stepping through the environment. Again, it follows the observation_mode specified.

Robot

class causal_world.envs.TriFingerRobot(action_mode, observation_mode, skip_frame, normalize_actions, normalize_observations, simulation_time, pybullet_client_full_id, pybullet_client_w_goal_id, pybullet_client_w_o_goal_id, revolute_joint_ids, finger_tip_ids, cameras=None, camera_indicies=array([0, 1, 2]))[source]
__init__(action_mode, observation_mode, skip_frame, normalize_actions, normalize_observations, simulation_time, pybullet_client_full_id, pybullet_client_w_goal_id, pybullet_client_w_o_goal_id, revolute_joint_ids, finger_tip_ids, cameras=None, camera_indicies=array([0, 1, 2]))[source]

This class provides the functionalities of the robot itself

Parameters
  • action_mode – (str) defines the action mode of the robot whether its joint_positions, end_effector_positions or joint_torques.

  • observation_mode – (str) defines the observation mode of the robot if cameras or structured.

  • skip_frame – (int) the low level controller is running @250Hz which corresponds to skip frame of 1, a skip frame of 250 corresponds to frequency of 1Hz

  • normalize_actions – (bool) this is a boolean which specifies whether the actions passed to the step function are normalized or not.

  • normalize_observations – (bool) this is a boolean which specifies whether the observations returned should be normalized or not.

  • simulation_time – (float) the time for one action step in the pybullet simulation.

  • pybullet_client_full_id – (int) pybullet client full mode id

  • pybullet_client_w_goal_id – (int) pybullet client with goal mode id

  • pybullet_client_w_o_goal_id – (int) pybullet client without goal mode id

  • revolute_joint_ids – (list) joint ids in the urdf

  • finger_tip_ids – (list) finger tip ids in the urdf

  • cameras – (list) Camera objects list

  • camera_indicies – (list) maximum of 3 elements where each element is from 0 to , specifies which cameras to return in the observations and the order as well.

add_observation(observation_key, lower_bound=None, upper_bound=None, observation_fn=None)[source]
Parameters
  • observation_key – (str) observation name to be added.

  • lower_bound – (nd.array) the lower bound of this observation when added to the space unnormalized.

  • upper_bound – (nd.array) the upper bound of this observation when added to the space unnormalized.

  • observation_fn – (function) a callable function that when passed the robot stat, it calculates this custom observation.

Returns

None.

apply_action(action)[source]

Applied the passed action to the robot.

Parameters

action – (nd.array) the action to be applied. Should adhere to the action_mode.

Returns

None.

apply_interventions(interventions_dict)[source]
Parameters

interventions_dict – (dict) a dictionary specifying which variables and values for a do intervention on variables that belong to the robot only.

Returns

None.

check_feasibility_of_robot_state()[source]

This function checks the feasibility of the current state of the robot (i.e checks if its in penetration with anything now

Returns

(bool) A boolean indicating whether the robot is in a collision state or not.

clear()[source]

clears the robot for a reset for instance.

Returns

None.

close()[source]

closes the pybullet clients connected.

Returns

None.

compute_pd_control_torques(joint_positions)[source]

Compute torque command to reach given target position using a PD controller.

Parameters

joint_positions – (list) Desired joint positions.

Returns

(list) torques to be sent to the joints of the finger in order to reach the specified joint_positions.

denormalize_observation_for_key(observation, key)[source]
Parameters
  • observation – (nd.array) the observation to be denormalized.

  • key – (str) the key corresponding to this observation.

Returns

(nd.array) observation after de-normalization.

forward_simulation(time=1)[source]
Parameters

time – (float) forwards the simulation by the time specified.

Returns

get_action_mode()[source]
Returns

(str) returns the current action mode.

get_action_spaces()[source]
Returns

(gym.Spaces) returns the current action space of the robot.

get_control_index()[source]
Returns

(int) returns the current control index

get_current_camera_observations()[source]
Returns

(nd.array) returns the current camera observations from the cameras selected on the robot in case the observation mode was “pixel”

get_current_observations(helper_keys)[source]
Parameters

helper_keys – (list) list of observation keys not part of the default observation space but needed to compute part of a reward function or to compute custom observations.

Returns

(dict) returns the full observations of the robot itself with the values of the helper keys as well.

get_current_variable_values()[source]
Returns

(dict) returns all the exposed variables in the environment along with their corresponding values.

get_default_state()[source]
Returns

(nd.array) returns the default state of the robot, (18,) first 9 positions occupy the joint positions and the second 9 positions occupy the joint velocities which is zero.

get_dt()[source]
Returns

(float) returns the current dt of one step. How much time is equivilant to one step function.

get_full_env_state()[source]
Returns

returns the current state variables and their values in the environment wrt to the robot.

get_full_state()[source]
Returns

(nd.array) return the positions and velocities of the three fingers concatenated.

get_joint_positions_from_tip_positions(tip_positions, default_pose=None)[source]
Parameters
  • tip_positions – (list) desired tip positions in world frame.

  • default_pose – (list) initial inverse kinemetics solution to start from.

Returns

get_joint_positions_raised()[source]
Returns

(list) returns the upper joint positions limit.

get_last_action()[source]
Returns

(nd.array) returns the last action passed to the robot.

get_last_applied_joint_positions()[source]
Returns

(nd.array) returns the last applied joint positions passed to the pd controller. This is not valid if the action mode is “joint_torques”.

get_last_clipped_action()[source]
Returns

(nd.array) returns the last clipped action passed to the robot, based on the range of the action space.

get_latest_full_state()[source]
Returns

(dict) returns a dict with joint velocities, joint positions and joint torques of the robot.

Returns

(list) returns the link names in the urdf

get_normal_interaction_force_with_block(block, finger_tip_number)[source]
Parameters
  • block – (causal_world.envs.RigidObject) rigid object to query collision with the robot.

  • finger_tip_number – (int) should be 60, 120 or 300.

Returns

(float) returns the normal interaction force between the block and the finger tip or None if no interaction exists.

get_observation_mode()[source]
Returns

(str) returns the observation mode of the robot.

get_observation_spaces()[source]
Returns

(gym.Spaces) returns the current observation space of the robot.

get_rest_pose()[source]
Returns

(tuple) returns the rest pose that the robot usually start from, the first in the tuple being the joint positions and the second is the end effector positions.

get_skip_frame()[source]
Returns

(int) returns the current skip frame.

get_state_size()[source]
Returns

(int) returns the state size of the robot, mainly joint positions and joint velocities that defines the state of the robot, ignoring interventions.

get_tip_contact_states()[source]
Returns

(list) returns a list of 3, 0 if open and 1 is closed (i.e 0 when the correpsonding finger tip is not in contact with anything and 1 otherwise).

inverse_kinematics(desired_tip_positions, rest_pose)[source]
Parameters
  • desired_tip_positions – (list) desired tip positions in world frame.

  • rest_pose – (list) initial inverse kinemetics solution to start from.

Returns

is_colliding_with_stage()[source]
Returns

(bool) A boolean indicating whether the robot is colliding with the stage.

is_in_contact_with_block(block)[source]
Parameters

block – (causal_world.envs.RigidObject) rigid object to query collision with the robot.

Returns

(bool) A boolean indicating whether the robot is colliding with block passed.

is_self_colliding()[source]
Returns

(bool) A boolean indicating whether the robot is self colliding with itself.

normalize_observation_for_key(observation, key)[source]
Parameters
  • observation – (nd.array) the observation to be normalized.

  • key – (str) the key corresponding to this observation.

Returns

(nd.array) observation after normalization.

reset_state(joint_positions=None, joint_velocities=None, end_effector_positions=None)[source]
Parameters
  • joint_positions – (nd.array) the joint positions for the root to be reset in.

  • joint_velocities – (nd.array) the joint velocities for the root to be reset in.

  • end_effector_positions – (nd.array) the end effector positions for the root to be reset in, this shouldn’t be used in combination with the other args.

Returns

sample_end_effector_positions(sampling_strategy='middle_stage')[source]
Parameters

sampling_strategy – (str) this only supports “middle_stage” strategy for now.

Returns

(nd.array) returns the sampled end effector positions.

sample_joint_positions(sampling_strategy='uniform')[source]
Parameters

sampling_strategy – (str) this only supports “uniform” strategy for now.

Returns

(nd.array) returns the sampled joint positions.

select_observations(observation_keys)[source]
Parameters

observation_keys – (list) the observations keys for the robot to be added in the observation space itself.

Returns

None.

send_torque_commands(desired_torque_commands)[source]
Parameters

desired_torque_commands – (nd.array) the desired torque commands to be applied to the robot.

Returns

(nd.array) the actual torque commands sent to the robot after applying a safety check.

set_action_mode(action_mode)[source]

Sets the action mode

Parameters

action_mode – (str) specifies the action mode of the robot.

Returns

None

set_full_env_state(env_state)[source]

This function is used to set the env state through interventions on the environment itself

Parameters

env_state – (dict) specifies the state variables and its values to intervene on.

Returns

None

set_full_state(state)[source]
Parameters

state – (nd.array) sets the positions and velocities, shape (18,).

Returns

None

set_observation_mode(observation_mode)[source]

Sets the observation mode

Parameters

observation_mode – (str) sets the observation mode of the robot itself.

Returns

None

step_simulation()[source]

steps through the simulation function of the pybullet backend.

Returns

update_latest_full_state()[source]

Updates the latest full state in terms of joint positions, velocities, torques..etc

Returns

None

Stage

class causal_world.envs.Stage(observation_mode, normalize_observations, pybullet_client_full_id, pybullet_client_w_goal_id, pybullet_client_w_o_goal_id, cameras, camera_indicies)[source]
__init__(observation_mode, normalize_observations, pybullet_client_full_id, pybullet_client_w_goal_id, pybullet_client_w_o_goal_id, cameras, camera_indicies)[source]

This class represents the stage object, where it handles all the arena functionalities including the objects and silhouettes existing in the arena.

Parameters
  • observation_mode – (str) should be “structured” or “pixel”

  • normalize_observations – (bool) to normalize the observations or not.

  • pybullet_client_full_id – (int) pybullet client if visualization is enabled.

  • pybullet_client_w_goal_id – (int) pybullet client with the goal in the image without tool objects.

  • pybullet_client_w_o_goal_id – (int) pybullet client without the goal, only tool blocks.

  • cameras – (list) list of causal_world.robot.Camera object specifying the cameras mounted on top of the trifinger robot.

  • camera_indicies – (list) list of integers of the order of cameras to be used.

add_observation(observation_key, lower_bound=None, upper_bound=None)[source]
Parameters
  • observation_key – (str) new observation key to be added.

  • lower_bound – (nd.array) low bound of the observation.

  • upper_bound – (nd.array) upper bound of the observation.

Returns

add_rigid_general_object(name, shape, **object_params)[source]
Parameters
  • name – (str) a str specifying a unique name of the rigid object.

  • shape – (str) specifying “cube” or “static_cube” for now.

  • object_params – (params) depends on the parameters used for constructing the corresponding object.

Returns

add_rigid_mesh_object(name, filename, **object_params)[source]
Parameters
  • name – (str) a str specifying a unique name of the mesh object.

  • filename – (str) a str specifying the location of the .obj file.

  • object_params – (params) depends on the parameters used for constructing the corresponding object.

Returns

add_silhoutte_general_object(name, shape, **object_params)[source]
Parameters
  • name – (str) specifying a unique name of the visual object.

  • shape – (str) specifying “cube” or “sphere” for now.

  • object_params – (params) depends on the parameters used for constructing the corresponding object.

Returns

add_silhoutte_mesh_object(name, filename, **object_params)[source]
Parameters
  • name – (str) specifying a unique name of the mesh visual object.

  • filename – (str) a str specifying the location of the .obj file.

  • object_params – (params) depends on the parameters used for constructing the corresponding object.

Returns

apply_interventions(interventions_dict)[source]
Parameters

interventions_dict – (dict) dict specifying the intervention to be performed.

Returns

are_blocks_colliding(block1, block2)[source]
Parameters
  • block1 – (causal_world.RigidObject) first block.

  • block2 – (causal_world.RigidObject) second block.

Returns

(bool) true if the two blocks passed are colliding.

check_feasiblity_of_stage()[source]

This function checks the feasibility of the current state of the stage (i.e checks if any of the bodies in the simulation are in a penetration mode)

Returns

(bool) A boolean indicating whether the stage is in a collision state or not. As well as if the visual objects are outside of the bounding box or not.

check_stage_free_of_colliding_blocks()[source]
Returns

(bool) true if the stage is free of collisions of blocks.

denormalize_observation_for_key(observation, key)[source]
Parameters
  • observation – (nd.array) observation to denormalize.

  • key – (str) observation key to be denormalized.

Returns

(nd.array) denormalized observation.

finalize_stage()[source]

finalizes the observation space of the environment after adding all the objects and visuals in the stage.

Returns

get_arena_bb()[source]
Returns

(list) list of the lower bound (x, y, z) and the upper bound (x, y, z) so (2, 3) shape.

get_current_goal_image()[source]
Returns

(nd.array) returns the goal images concatenated if ‘pixel’ mode is enabled.

get_current_object_keys()[source]
Returns

(list) returns the names of the rigid objects and visual objects concatenated.

get_current_observations(helper_keys)[source]
Parameters

helper_keys – (list) list of observation keys that are not part of the observation space but still needed to be returned to calculate further observations or for a dense reward function calculation.

Returns

(dict) returns the current observations where the keys corresponds to the observation key.

get_current_variable_values()[source]
Returns

(dict) returns all the exposed variables and their values in the environment’s stage.

get_current_variable_values_for_arena()[source]
Returns

(dict) returns all the exposed variables and their values in the environment’s stage except for objects.

get_current_variable_values_for_objects()[source]
Returns

(dict) returns all the exposed variables and their values in the environment’s stage for objects only.

get_floor_height()[source]
Returns

(float) returns the floor height.

get_full_env_state()[source]
Returns

(dict) returns a dict specifying everything about the current state of the arena.

get_full_state(state_type='list')[source]
Parameters

state_type – (str) ‘list’ or ‘dict’ specifying to return the state as a dict with the state name as a key or just a concatenated list.

Returns

(list or dict) depending on the arg state_type, returns the full state of the stage itself.

get_normal_interaction_force_between_blocks(block1, block2)[source]
Parameters
  • block1 – (causal_world.RigidObject) first block.

  • block2 – (causal_world.RigidObject) second block.

Returns

(float) normal interaction force between blocks or None if no interaction.

get_object(key)[source]
Parameters

key – (str) specifying the name of the object to return it.

Returns

(causal_world.RigidObject or causal_world.SilhouetteObject) object to return.

get_object_full_state(key)[source]
Parameters

key – (str) specifying the name of the object to return its state.

Returns

(dict) specifies the state of the object queried.

get_object_state(key, state_variable)[source]
Parameters
  • key – (str) specifying the name of the object to return its state’s variable value.

  • state_variable – (str) specifying the variable’s name of the object.

Returns

(nd.array) returns the variable’s value of the object queried.

get_observation_spaces()[source]
Returns

(gym.spaces.Box) returns the current observation space of the environment.

get_rigid_objects()[source]
Returns

(dict) returns the rigid objects in the arena currently.

get_stage_bb()[source]
Returns

(tuple) first element indicates the lower bound the stage arena (x,y, z) and second element indicated the upper bound similarly.

get_visual_objects()[source]
Returns

(dict) returns the visual objects in the arena currently.

is_colliding_with_floor(block1)[source]
Parameters

block1 – (causal_world.RigidObject) first block.

Returns

(bool) true if the block is colliding with the floor.

is_colliding_with_stage(block1)[source]
Parameters

block1 – (causal_world.RigidObject) first block.

Returns

(bool) true if the stage is free of collisions between blocks.

normalize_observation_for_key(observation, key)[source]
Parameters
  • observation – (nd.array) observation to normalize.

  • key – (str) observation key to be normalized.

Returns

(nd.array) normalized observation.

object_intervention(key, interventions_dict)[source]
Parameters
  • key – (str) the unique name of the rigid or visual object to intervene on.

  • interventions_dict – (dict) dict specifying the intervention to be performed.

Returns

random_position(height_limits=0.05, 0.15, angle_limits=- 6.283185307179586, 6.283185307179586, radius_limits=0.0, 0.15, allowed_section=array([[- 0.5, - 0.5, 0.0], [0.5, 0.5, 0.5]]))[source]
Parameters
  • height_limits – (tuple) tuple of two values for low bound and upper bound.

  • angle_limits – (tuple) tuple of two values for low bound and upper bound, theta in polar coordinates.

  • radius_limits – (tuple) tuple of two values for low bound and upper bound, radius in polar coordinates.

  • allowed_section – (nd.array) array of two sublists for low bound and upper bound (x, y, z) of restricted area for sampling, the shape of the input is basically (2,2).

Returns

(list) returns a cartesian random position in the arena (x, y, z).

remove_everything()[source]

removes all the objects and visuals from the arena.

Returns

remove_general_object(name)[source]
Parameters

name – (str) a str specifying a unique name of the object to remove from the arena.

Returns

select_observations(observation_keys)[source]

selects the observations to be returned by the environment.

Parameters

observation_keys – (list) list of str that specifies the observation keys to be returned and calculated by the environment.

Returns

set_full_env_state(env_state)[source]
Parameters

env_state – (dict) dict specifying everything about the current state of the arena, usually obtained through get_full_env_state function.

Returns

set_full_state(new_state)[source]
Parameters

new_state – (dict) specifies the full state of all the objects in the arena.

Returns

set_objects_pose(names, positions, orientations)[source]
Parameters
  • names – (list) list of object names to set their positions and orientations.

  • positions – (list) corresponding list of positions of objects to be set.

  • orientations – (list) corresponding list of orientations of objects to be set.

Returns

update_goal_image()[source]

updated the goal image.

Returns

RigidObject

class causal_world.envs.RigidObject(pybullet_client_ids, name, size, initial_position, initial_orientation, mass, color, lateral_friction, spinning_friction, restitution, initial_linear_velocity, initial_angular_velocity, fixed_bool)[source]
__init__(pybullet_client_ids, name, size, initial_position, initial_orientation, mass, color, lateral_friction, spinning_friction, restitution, initial_linear_velocity, initial_angular_velocity, fixed_bool)[source]

This is the base class of any rigid object whether it is fixed or not.

Parameters
  • pybullet_client_ids – (list) specifies the pybullet client ids where this object will be in.

  • name – (str) specifies the name of the object, needs to be unique.

  • size – (float list) 3 dimensional list specifies the size

  • initial_position – (float list) specifies the x,y,z position in the arena.

  • initial_orientation – (float list) specifies the quaternion orientation.

  • mass – (float) specifies the mass of the object itself. 0 if fixed.

  • color – (float list) specifies the RGB values of the object.

  • lateral_friction – (float) specifies the lateral friction of the object.

  • spinning_friction – (float) specifies the spinning friction of the object.

  • restitution – (float) specifies the restitution of the object.

  • initial_linear_velocity – (float list) specifies the velocity in the x,y,z directions.

  • initial_angular_velocity – (float list) specifies the velocity in the yaw, roll, pitch values.

  • fixed_bool – (bool) specifies if the object is fixed or not.

apply_interventions(interventions_dict)[source]
Parameters

interventions_dict – (dict) specifies the interventions to be performed on the various variables.

Returns

get_block_ids()[source]
Returns

(list) returns the block ids in the active pybullet clients.

get_bounding_box()[source]
Returns

(nd.array) first position of the array is the lower bound of the bounding box of the object and second position of the array is the upper bound of the bounding box.

get_bounds()[source]
Returns

(tuple) first position of the tuple is the lower bound of the bounding box of the object and second position of the tuple is the upper bound of the bounding box.

get_initial_position()[source]
Returns

(nd.array) initial position where the object was created.

get_name()[source]
Returns

(str) returns the name of the object.

get_recreation_params()[source]

gets the params that are needed to recreate the same object again.

Returns

get_rotation_matrix()[source]
Returns

(nd.array) returns the rotation matrix of the object.

get_size()[source]
Returns

(nd.array) returns the size of the object.

get_state(state_type='dict')[source]
Parameters

state_type – ‘list’ or ‘dict’.

Returns

(dict or list) specifies the state of the object.

get_state_size()[source]
Returns

(int) specifies how large is the state of the object.

get_state_variable_names()[source]
Returns

(list) returns the state variable names.

get_variable_state(variable_name)[source]
Parameters

variable_name – (str) variable name to query about the object.

Returns

(nd.array, float or int) returns the corresponding value of the variable.

get_vertices()[source]
Returns

(nd.array) specifies the current vertices of the object.

get_volume()[source]
Returns

(nd.array) returns the volume of the object.

is_not_fixed()[source]
Returns

(bool) true if its not fixed object.

reinit_object()[source]

removes the object and reinitilaizes it again.

Returns

remove()[source]

removes the object.

Returns

set_full_state(new_state)[source]
Parameters

new_state – (list) specifies the state of the object to be set.

Returns

set_pose(position, orientation)[source]
Parameters
  • position – (nd.array) specifies the cartesian position of the object.

  • orientation – (nd.array) specifies the quaternion orientation of the object.

Returns

world_to_cube_r_matrix()[source]
Returns

(nd.array) returns the transformation matrix of the object.

StaticCuboid

class causal_world.envs.StaticCuboid(pybullet_client_ids, name, size=array([0.065, 0.065, 0.065]), position=array([0.0, 0.0, 0.0425]), orientation=array([0, 0, 0, 1]), color=array([1, 0, 0]), lateral_friction=1)[source]
__init__(pybullet_client_ids, name, size=array([0.065, 0.065, 0.065]), position=array([0.0, 0.0, 0.0425]), orientation=array([0, 0, 0, 1]), color=array([1, 0, 0]), lateral_friction=1)[source]
Parameters
  • pybullet_client_ids – (list) specifies the pybullet clients.

  • name – (str) specifies the name of the object.

  • size – (list float) specifies the size in the three directions.

  • position – (list float) specifies the position in x,y,z.

  • orientation – (list float) specifies the quaternion of the object.

  • color – (list float) specifies the RGB values of the cuboid.

  • lateral_friction – (float) specifies the lateral friction.

get_recreation_params()[source]
Returns

(dict) the creation parameters needed to recreate the object.

Cuboid

class causal_world.envs.Cuboid(pybullet_client_ids, name, size=array([0.065, 0.065, 0.065]), initial_position=array([0.0, 0.0, 0.0425]), initial_orientation=array([0, 0, 0, 1]), mass=0.08, color=array([1, 0, 0]), initial_linear_velocity=array([0, 0, 0]), initial_angular_velocity=array([0, 0, 0]), lateral_friction=1)[source]
__init__(pybullet_client_ids, name, size=array([0.065, 0.065, 0.065]), initial_position=array([0.0, 0.0, 0.0425]), initial_orientation=array([0, 0, 0, 1]), mass=0.08, color=array([1, 0, 0]), initial_linear_velocity=array([0, 0, 0]), initial_angular_velocity=array([0, 0, 0]), lateral_friction=1)[source]

This specifies the moving cuboid object in the arena.

Parameters
  • pybullet_client_ids – (list) specifies the pybullet client ids.

  • name – (str) specifies the name of the object.

  • size – (list float) specifies the size in the three directions.

  • initial_position – (list float) specifies the position in x,y,z.

  • initial_orientation – (list float) specifies the quaternion of the object.

  • mass – (float) specifies the mass of the object.

  • color – (list float) specifies the RGB values of the cuboid.

  • initial_linear_velocity – (list float) specifies the initial linear velocity vx, vy, vz.

  • initial_angular_velocity – (list float) specifies the initial angular velocities.

  • lateral_friction – (float) specifies the lateral friction.

get_recreation_params()[source]
Returns

(dict) the creation parameters needed to recreate the object.

MeshObject

class causal_world.envs.MeshObject(pybullet_client_ids, name, filename, scale=array([0.01, 0.01, 0.01]), initial_position=array([0.0, 0.0, 0.0425]), initial_orientation=array([0, 0, 0, 1]), color=array([1, 0, 0]), mass=0.08, initial_linear_velocity=array([0, 0, 0]), initial_angular_velocity=array([0, 0, 0]), lateral_friction=1)[source]
__init__(pybullet_client_ids, name, filename, scale=array([0.01, 0.01, 0.01]), initial_position=array([0.0, 0.0, 0.0425]), initial_orientation=array([0, 0, 0, 1]), color=array([1, 0, 0]), mass=0.08, initial_linear_velocity=array([0, 0, 0]), initial_angular_velocity=array([0, 0, 0]), lateral_friction=1)[source]
Parameters
  • pybullet_client_ids – (list) specifies the pybullet clients.

  • name – (str) specifies the name of the object.

  • filename – (str) specifies the name of the file itself.

  • scale – (list float) specifies the scale of the mesh object.

  • initial_position – (list float) specifies the positions in x,y,z

  • initial_orientation – (list float) specifies the quaternion of the object.

  • color – (list float) specifies the RGB values.

  • mass – (float) specifies the object mass.

  • initial_linear_velocity – (list float) specifies the velocity in vx, vy, vz.

  • initial_angular_velocity – (list float) specifies the velocity in yaw, roll, pitch.

  • lateral_friction – (float) specifies the lateral friction.

get_recreation_params()[source]
Returns

(dict) the creation parameters needed to recreate the object.

SilhouetteObject

class causal_world.envs.SilhouetteObject(pybullet_client_ids, name, size, position, orientation, color)[source]
__init__(pybullet_client_ids, name, size, position, orientation, color)[source]

This is the base object for a silhouette in the arena.

Parameters
  • pybullet_client_ids – (list) list of pybullet client ids.

  • name – (str) specifies the name of the silhouette object

  • size – (list float) specifies the size of the object.

  • position – (list float) x, y, z position.

  • orientation – (list float) quaternion.

  • color – (list float) RGB values.

apply_interventions(interventions_dict)[source]
Parameters

interventions_dict – (dict) specifies the interventions to be performed on the goal shape itself.

Returns

get_block_ids()[source]
Returns

(list) returns the block ids in the active pybullet clients.

get_bounding_box()[source]
Returns

(tuple) first position specifying the lower bounds of the variables, second position specifying the upper bounds of the variables.

get_bounds()[source]
Returns

(tuple) first position specifying the lower bounds of the variables, second position specifying the upper bounds of the variables.

get_name()[source]
Returns

(str) returns the name of the object.

get_size()[source]
Returns

(nd.array) returns the size of the goal shape.

get_state(state_type='dict')[source]
Parameters

state_type – (str) specifying ‘dict’ or ‘list’

Returns

(list) returns either a dict or a list specifying the state variables of the goal shape.

get_state_size()[source]
Returns

(int) returns the size of the state variables.

get_state_variable_names()[source]
Returns

(list) specifies the various variable names in the list itself.

get_variable_state(variable_name)[source]
Parameters

variable_name – (str) specifies the variable name of the goal.

Returns

(nd.array) the high level variable value.

get_vertices()[source]
Returns

(nd.array) specifies the current vertices of the gaol shape.

get_volume()[source]
Returns

(nd.array) returns the volume of the goal shape.

reinit_object()[source]

Used to remove the goal from the arena and creating it again.

Returns

remove()[source]

Used to remove the goal from the arena.

Returns

set_full_state(new_state)[source]
Parameters

new_state – (list) specifies the state to set the goal shape to.

Returns

set_pose(position, orientation)[source]
Parameters
  • position – (list) cartesian x,y,z positon of the center of the gaol shape.

  • orientation – (list) quaternion x,y,z,w of the goal itself.

Returns

SMeshObject

class causal_world.envs.SMeshObject(pybullet_client_ids, name, filename, scale=array([0.01, 0.01, 0.01]), position=array([0.0, 0.0, 0.0425]), orientation=array([0, 0, 0, 1]), color=array([0, 1, 0]))[source]
__init__(pybullet_client_ids, name, filename, scale=array([0.01, 0.01, 0.01]), position=array([0.0, 0.0, 0.0425]), orientation=array([0, 0, 0, 1]), color=array([0, 1, 0]))[source]
Parameters
  • pybullet_client_ids – (list) specifies the pybullet clients.

  • name – (str) specifies the name of the goal.

  • filename – (str) specifies the name of the file itself.

  • scale – (list float) specifies the scale of the mesh goal.

  • position – (list float) specifies the positions in x,y,z

  • orientation – (list float) specifies the quaternion of the goal.

  • color – (list float) specifies the RGB values.

get_recreation_params()[source]
Returns

(dict) the creation parameters needed to recreate the goal shape.

SSphere

class causal_world.envs.SSphere(pybullet_client_ids, name, radius=0.015, position=array([0.0, 0.0, 0.0425]), color=array([0, 1, 0]))[source]
__init__(pybullet_client_ids, name, radius=0.015, position=array([0.0, 0.0, 0.0425]), color=array([0, 1, 0]))[source]
Parameters
  • pybullet_client_ids – (list) specifies the pybullet client ids.

  • name – (str) specifies the name of the goal shape.

  • radius – (float) specifies the radius of the sphere goal.

  • position – (list float) specifies the position in x,y,z.

  • color – (list float) specifies the RGB values of the cuboid.

apply_interventions(interventions_dict)[source]
Parameters

interventions_dict – (dict) specifies the interventions to be performed on the various variables.

Returns

get_recreation_params()[source]
Returns

(dict) the creation parameters needed to recreate the goal shape.

SCuboid

class causal_world.envs.SCuboid(pybullet_client_ids, name, size=array([0.065, 0.065, 0.065]), position=array([0.0, 0.0, 0.0425]), orientation=array([0, 0, 0, 1]), color=array([0, 1, 0]))[source]
__init__(pybullet_client_ids, name, size=array([0.065, 0.065, 0.065]), position=array([0.0, 0.0, 0.0425]), orientation=array([0, 0, 0, 1]), color=array([0, 1, 0]))[source]

This is the silhoutte cuboid object.

Parameters
  • pybullet_client_ids – (list) specifies the pybullet client ids.

  • name – (str) specifies the name of the object.

  • size – (list float) specifies the size in the three directions.

  • position – (list float) specifies the position in x,y,z.

  • orientation – (list float) specifies the quaternion of the object.

  • color – (list float) specifies the RGB values of the cuboid.

get_recreation_params()[source]
Returns

(dict) the creation parameters needed to recreate the goal.