How to add custom C++ codelets to a py_binary?

I have successfully followed the tutorial to create a simple Ping app and codelet here: https://docs.nvidia.com/isaac/isaac/doc/tutorials/ping.html

I would like to have this codelet run in a separate py_binary I have created that runs the carter_sim application. My BUILD looks like this:

py_binary(
    name = "train",
    srcs = [
        "differential_base_state.py",
        "train.py",
    ],
    data = [
        "apps/carter_sim.app.json",
        "configs/carter.config.json",
        "graphs/carter.graph.json",
        "configs/navigation.config.json",
        "graphs/navigation.graph.json",
        "//apps/assets/maps",
        "//packages/map:libmap_module.so",
        "//packages/flatsim:libflatsim_module.so",
        "//packages/ml:libml_module.so",
        "//packages/navigation:libnavigation_module.so",
        "//packages/perception:libperception_module.so",
        "//packages/planner:libplanner_module.so",
        "//packages/viewers:libviewers_module.so",
    ],
    deps = [
        "//engine/pyalice",
        "//packages/ml:pyml",
    ],
)

The tutorial creates an isaac_cc_module and includes it as a module in isaac_app. What is the equivalent include for a py_binary?

Hi Alexander,

I am honestly not entirely sure that this is the sanctioned approach, but I was able to include my own C++ module in a python-driven app by making the standard isaac_cc_module and then including a reference to //:lib_module.so in the data section of your py_binary. When bazel builds an Isaac C++ module, it automatically generates this .so file.

Here’s a sample of my BUILD file for clarity:

load("//engine/build:isaac.bzl", "isaac_pkg", "isaac_cc_module")

isaac_cc_module(
    name = "<b>arena_pattern_gen</b>",
    srcs = ["ArenaPatternGen.cpp"],
    hdrs = ["ArenaPatternGen.hpp"],
    visibility = ["//visibility:public"],
)

py_binary(
    name = "carter_sim",
    srcs = [
        "__init__.py",
        "carter_sim.py",
    ],
    data = [
        "carter_sim.app.json",
        "carter.config.json",
        "carter.graph.json",
        "navigation.graph.json",
        "navigation.config.json",
        "//apps/assets/maps",
        "//packages/map:libmap_module.so",
        "//packages/flatsim:libflatsim_module.so",
        "//packages/navigation:libnavigation_module.so",
        "//packages/perception:libperception_module.so",
        "//packages/planner:libplanner_module.so",
        "//packages/viewers:libviewers_module.so",
        <b>"//apps/carter_sim:libarena_pattern_gen_module.so"</b>,
    ],
    deps = [
        "//engine/pyalice",
    ],
)

isaac_pkg(
    name = "carter_sim-pkg",
    srcs = ["carter_sim"],
)

You will also need to include the module in your app.json as : (in my case:)

"modules": [
    "apps/carter_sim:arena_pattern_gen",

I suppose better practice would probably be making modules independent of individual applications, placing them somewhere like “packages” and designing their own BUILD files… I’ll get around to this later :P

Of course, you’ll also need to add a node, config, and edges to your graph as appropriate.

Good luck,
Travis

Thank you! All I was missing was a direct reference to a libX_module.so file. It works now.