Skip to content

AirLib C++ API Mismatch for "simSpawnObject" #130

@drhill-larc

Description

@drhill-larc

Bug report

  • AirSim Version/#commit: Main as of 06/23/2025; commit # 2831bd2
  • UE/Unity version: Unreal 5.5.3
  • autopilot version: N/A
  • OS Version: Windows 11

What's the issue you encountered?

While using the C++ API within a client ros2 application, and I attempted to spawn a known Unreal asset object using "simSpawnObject." This produced a fatal exception repeatedly, and after much debugging it was determined that there was argument mismatch issue between the RpcLibClientBase::simSpawnObject function declaration and definition and the use of "simSpawnObject" by RcpLibServerBase (and WorldSimApiBase).

Under the function binding and redirection to WorldSimApiBase, RcpLibServerBase (Line 375 in RcpLinServerBase.cpp) expects a function argument list that includes an optional parameter "is_blueprint".

pimpl_->server.bind("simSpawnObject", [&](string& object_name, const string& load_component, const RpcLibAdaptorsBase::Pose& pose, const RpcLibAdaptorsBase::Vector3r& scale, bool physics_enabled, bool is_blueprint) -> string { return getWorldSimApi()->spawnObject(object_name, load_component, pose.to(), scale.to(), physics_enabled, is_blueprint); });

However, the calling object, RcpLibClientBase, does not expect nor provide this parameter when being executed and subsequently issuing the pimpl client call (starting at line 516 of RcpLinClientBase.cpp).

std::string RpcLibClientBase::simSpawnObject(const std::string& object_name, const std::string& load_component, const Pose& pose, const Vector3r& scale, bool physics_enabled) { return pimpl_->client.call("simSpawnObject", object_name, load_component, RpcLibAdaptorsBase::Pose(pose), RpcLibAdaptorsBase::Vector3r(scale), physics_enabled).as<std::string>(); }

By adding the optional parameter "is_blueprint" to RpcLibClientBase::simSpawnObject function and correctly passing "is_blueprint" within the function body's pimpl call, the issue was resolved.

Affected Files:
"/AirLib/include/api/RpcLibClientBase.hpp"
"/AirLib/src/api/RpcLibClientBase.cpp"

Settings

N/A

How can the issue be reproduced?

-Create a c++ node application that does the following:
-Create a client connection to an Active Unreal Airsim environment.
-Attempt to spawn an object (non airsim vehicle actor) such as any of the starting content meshes; e.g. "Shape_Cone" or "Shape_Sphere"

You can test this spawning with a python client first, as this function doesn't fail with the python client interface.

Include full error message in text form

What's better than filing an issue? Filing a pull request :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions