curobo.util_file module

Contains helper functions for interacting with file systems.

get_module_path() str

Get absolute path of cuRobo library.

get_root_path() str

Get absolute path of cuRobo library.

get_content_path() str

Get path to content directory in cuRobo.

Content directory contains configuration parameters for different tasks, some robot parameters for using in examples, and some world assets. Use ContentPath when running cuRobo with assets from a different location.

Returns:

path to content directory.

Return type:

str

get_configs_path() str

Get path to configuration parameters for different tasks(e.g., IK, TrajOpt, MPC) in cuRobo.

Returns:

path to configuration directory.

Return type:

str

get_assets_path() str

Get path to assets (robot urdf, meshes, world meshes) directory in cuRobo.

get_weights_path()

Get path to neural network weights directory in cuRobo. Currently not used in cuRobo.

join_path(path1: str, path2: str) str

Join two paths, considering OS specific path separators.

Parameters:
  • path1 – Path prefix.

  • path2 – Path suffix. If path2 is an absolute path, path1 is ignored.

Returns:

Joined path.

Return type:

str

load_yaml(
file_path: str | Dict,
) Dict

Load yaml file and return as dictionary. If file_path is a dictionary, return as is.

Parameters:

file_path – File path to yaml file or dictionary.

Returns:

Dictionary containing yaml file content.

Return type:

Dict

write_yaml(
data: Dict,
file_path: str,
)

Write dictionary to yaml file.

Parameters:
  • data – Dictionary to write to yaml file.

  • file_path – Path to write the yaml file.

get_robot_path() str

Get path to robot directory in cuRobo.

Deprecated: Use get_robot_configs_path instead. Robot directory contains robot configuration files in yaml format. See Configuring a New Robot for how to create a robot configuration file.

Returns:

path to robot directory.

Return type:

str

get_task_configs_path() str

Get path to task configuration directory in cuRobo.

Task directory contains configuration parameters for different tasks (e.g., IK, TrajOpt, MPC).

Returns:

path to task configuration directory.

Return type:

str

get_robot_configs_path() str

Get path to robot configuration directory in cuRobo.

Robot configuration directory contains robot configuration files in yaml format. See Configuring a New Robot for how to create a robot configuration file.

Returns:

path to robot configuration directory.

Return type:

str

get_world_configs_path() str

Get path to world configuration directory in cuRobo.

World configuration directory contains world configuration files in yaml format. World information includes obstacles represented with respect to the robot base frame.

Returns:

path to world configuration directory.

Return type:

str

get_debug_path() str

Get path to debug directory in cuRobo.

Debug directory can be used to store logs and debug information.

Returns:

path to debug directory.

Return type:

str

get_cpp_path()

Get path to cpp directory in cuRobo.

Directory contains CUDA implementations (kernels) of robotics algorithms, which are wrapped in C++ and compiled with PyTorch to enable usage in Python.

Returns:

path to cpp directory.

Return type:

str

add_cpp_path(
sources: List[str],
) List[str]

Add cpp path to list of source files.

Parameters:

sources – List of source files.

Returns:

List of source files with cpp path added.

Return type:

List[str]

copy_file_to_path(
source_file: str,
destination_path: str,
) str

Copy file from source to destination.

Parameters:
  • source_file – Path of source file.

  • destination_path – Path of destination directory.

Returns:

Destination path of copied file.

Return type:

str

get_filename(
file_path: str,
remove_extension: bool = False,
) str

Get file name from file path, removing extension if required.

Parameters:
  • file_path – Path of file.

  • remove_extension – If True, remove file extension.

Returns:

File name.

Return type:

str

get_path_of_dir(file_path: str) str

Get path of directory containing the file.

Parameters:

file_path – Path of file.

Returns:

Path of directory containing the file.

Return type:

str

get_files_from_dir(
dir_path,
extension: List[str],
contains: str,
) List[str]

Get list of files from directory with specified extension and containing a string.

Parameters:
  • dir_path – Path of directory.

  • extension – List of file extensions to filter.

  • contains – String to filter file names.

Returns:

List of file names. Does not include path.

Return type:

List[str]

file_exists(path: str) bool

Check if file exists.

Parameters:

path – Path of file.

Returns:

True if file exists, False otherwise.

Return type:

bool

get_motion_gen_robot_list() List[str]

Get list of robot configuration examples in cuRobo for motion generation.

get_robot_list() List[str]

Get list of robots example configurations in cuRobo.

get_multi_arm_robot_list() List[str]

Get list of multi-arm robot configuration examples in cuRobo.

merge_dict_a_into_b(
a: Dict[str, Any],
b: Dict[str, Any],
) Dict[str, Any]

Merge dictionary values in “a” into dictionary “b”. Overwrite values in “b” if key exists.

Parameters:
  • a – New dictionary to merge.

  • b – Base dictionary to merge into.

Returns:

Merged dictionary.

is_platform_windows() bool

Check if platform is Windows.

is_platform_linux() bool

Check if platform is Linux.

is_file_xrdf(file_path: str) bool

Check if file is an XRDF file.

Parameters:

file_path – Path of file.

Returns:

True if file is xrdf, False otherwise.

Return type:

bool