6 """Run this script in order to execute:
7 `robowflex_visualization/src/robowflex.py`
9 This script contains some utility functions for loading system Python paths
10 and finding the ROS package. You can change which script is ran by changing
11 the arguments to `load_ROS_module` at the bottom of the file.
13 Moreover, the `robowflex_visualization/src` directory is added to the path,
14 so that the various helper modules can be found.
16 You should put all of your visualization code in whatever file is loaded at
22 """Add a path to the system search path.
24 if not path
in sys.path:
26 print(
"Adding path {} to system path.".
format(path))
30 """Initialize Blender Python's system path with the system Python's paths.
33 output = subprocess.check_output(
34 [
"python3",
"-c",
"import sys; print('\\n'.join(sys.path))"])
35 paths = output.decode().strip().split(
'\n')
40 except subprocess.CalledProcessError:
41 print(
"Unable to call system Python3")
46 """Find a ROS package path.
49 output = subprocess.check_output([
"rospack",
"find", package])
50 return output.decode().strip()
52 except subprocess.CalledProcessError:
53 print(
"Unable to find package: `{}`".
format(package))
58 """Adds the robowflex_visualization/src folder to search path.
66 package = "robowflex_visualization"):
67 """Load a robowflex visualization module.
71 spec = importlib.util.spec_from_file_location(
72 module_name, os.path.join(directory, module_file))
74 module = importlib.util.module_from_spec(spec)
75 spec.loader.exec_module(module)
78 if __name__ ==
'__main__':
79 bpy.ops.outliner.orphans_purge()
def find_package(package)
def initialize_robowflex_path()
def load_ROS_module(module_name, module_file, package="robowflex_visualization")
std::string format(const std::string &fmt, Args &&... args)
Recursion base case, return string form of formatted arguments.