Skip to content

Commit

Permalink
Add C++ simSpawn|Destroy object APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Aug 8, 2021
1 parent f6bd9c4 commit e706003
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions AirLib/include/api/RpcLibClientBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ namespace airlib
Vector3r simGetObjectScale(const std::string& object_name) const;
bool simSetObjectPose(const std::string& object_name, const Pose& pose, bool teleport = true);
bool simSetObjectScale(const std::string& object_name, const Vector3r& scale);
std::string simSpawnObject(const std::string& object_name, const std::string& load_component, const Pose& pose,
const Vector3r& scale, bool physics_enabled);
bool simDestroyObject(const std::string& object_name);

//task management APIs
void cancelLastTask(const std::string& vehicle_name = "");
Expand Down
11 changes: 11 additions & 0 deletions AirLib/src/api/RpcLibClientBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,17 @@ __pragma(warning(disable : 4239))
return pimpl_->client.call("simLoadLevel", level_name).as<bool>();
}

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>();
}

bool RpcLibClientBase::simDestroyObject(const std::string& object_name)
{
return pimpl_->client.call("simDestroyObject", object_name).as<bool>();
}

msr::airlib::Vector3r RpcLibClientBase::simGetObjectScale(const std::string& object_name) const
{
return pimpl_->client.call("simGetObjectScale", object_name).as<RpcLibAdaptorsBase::Vector3r>().to();
Expand Down
2 changes: 1 addition & 1 deletion AirLib/src/api/RpcLibServerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ namespace airlib
return getWorldSimApi()->loadLevel(level_name);
});

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

Expand Down

0 comments on commit e706003

Please sign in to comment.