-
Notifications
You must be signed in to change notification settings - Fork 342
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Desired behavior
Considering following example
void createEntityFromStr(const std::string modelStr)
{
//! [call service create sphere]
bool result;
gz::msgs::EntityFactory req;
gz::msgs::Boolean res;
req.set_sdf(modelStr);
bool executed = node.Request("/world/empty/create",
req, timeout, res, result);
if (executed)
{
if (result)
std::cout << "Entity was created : [" << res.data() << "]" << std::endl;
else
{
std::cout << "Service call failed" << std::endl;
return;
}
}
else
std::cerr << "Service call timed out" << std::endl;
//! [call service create sphere]
}I would suppose that if creation fails then result or res.data() will be set to false.
I've checked the implementation and we can see that CreateService, res is always set to true.
bool UserCommandsPrivate::CreateService(const msgs::EntityFactory &_req,
msgs::Boolean &_res)
{
// Create command and push it to queue
auto msg = _req.New();
msg->CopyFrom(_req);
auto cmd = std::make_unique<CreateCommand>(msg, this->iface);
// Push to pending
{
std::lock_guard<std::mutex> lock(this->pendingMutex);
this->pendingCmds.push_back(std::move(cmd));
}
_res.set_data(true);
return true;
}I've also checked the place where the command is executed and we can see that we never use the result of metod call.
void UserCommands::PreUpdate(const UpdateInfo &/*_info*/,
EntityComponentManager &)
{
GZ_PROFILE("UserCommands::PreUpdate");
// make a copy the cmds so execution does not block receiving other
// incoming cmds
std::vector<std::unique_ptr<UserCommandBase>> cmds;
{
std::lock_guard<std::mutex> lock(this->dataPtr->pendingMutex);
if (this->dataPtr->pendingCmds.empty())
return;
cmds = std::move(this->dataPtr->pendingCmds);
this->dataPtr->pendingCmds.clear();
}
// TODO(louise) Record current world state for undo
// Execute pending commands
for (auto &cmd : cmds)
{
// Execute
if (!cmd->Execute())
continue;
// TODO(louise) Update command with current world state
// TODO(louise) Move to undo list
}
// TODO(louise) Clear redo list
}|'ve seen that:
/// \brief Callback for create service
/// \param[in] _req Request containing entity description.
/// \param[out] _res True if message successfully received and queued.
/// It does not mean that the entity will be successfully spawned.
/// \return True if successful.I understand that res will be always true when message is successfully received and queued but what about the result parm in the request method call?
It would be great to have real result of request call (I see it could be hard to implement), at least we could work on docs to be more verbose on what is really happening.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Type
Projects
Status
To do