Skip to content

Commit 0ca86bf

Browse files
committed
Add C++ simSpawn|Destroy object APIs
1 parent 42bf5f4 commit 0ca86bf

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

AirLib/include/api/RpcLibClientBase.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ namespace airlib
6565
Vector3r simGetObjectScale(const std::string& object_name) const;
6666
bool simSetObjectPose(const std::string& object_name, const Pose& pose, bool teleport = true);
6767
bool simSetObjectScale(const std::string& object_name, const Vector3r& scale);
68+
std::string simSpawnObject(const std::string& object_name, const std::string& load_component, const Pose& pose,
69+
const Vector3r& scale, bool physics_enabled);
70+
bool simDestroyObject(const std::string& object_name);
6871

6972
//task management APIs
7073
void cancelLastTask(const std::string& vehicle_name = "");

AirLib/src/api/RpcLibClientBase.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ __pragma(warning(disable : 4239))
416416
return pimpl_->client.call("simLoadLevel", level_name).as<bool>();
417417
}
418418

419+
std::string RpcLibClientBase::simSpawnObject(const std::string& object_name, const std::string& load_component, const Pose& pose,
420+
const Vector3r& scale, bool physics_enabled)
421+
{
422+
return pimpl_->client.call("simSpawnObject", object_name, load_component, RpcLibAdaptorsBase::Pose(pose), RpcLibAdaptorsBase::Vector3r(scale), physics_enabled).as<std::string>();
423+
}
424+
425+
bool RpcLibClientBase::simDestroyObject(const std::string& object_name)
426+
{
427+
return pimpl_->client.call("simDestroyObject", object_name).as<bool>();
428+
}
429+
419430
msr::airlib::Vector3r RpcLibClientBase::simGetObjectScale(const std::string& object_name) const
420431
{
421432
return pimpl_->client.call("simGetObjectScale", object_name).as<RpcLibAdaptorsBase::Vector3r>().to();

AirLib/src/api/RpcLibServerBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ namespace airlib
302302
return getWorldSimApi()->loadLevel(level_name);
303303
});
304304

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

0 commit comments

Comments
 (0)