Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/scrimmage/simcontrol/SimControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class SimControl {
* parameters.
*/
bool generate_entity(const int &ent_desc_id,
std::map<std::string, std::string> &params);
std::map<std::string, std::string> &params,
int request_id=0);

/// @brief Get the pointer to the MissionParser instance.
MissionParsePtr mp();
Expand Down
2 changes: 2 additions & 0 deletions msgs/Event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ message UserForcedExit {

message EntityGenerated {
int32 entity_id = 1;
int32 request_id = 2;
}

message EntityRemoved {
Expand All @@ -45,4 +46,5 @@ message GenerateEntity {
scrimmage_proto.State state = 2;
repeated KeyValuePair entity_param = 3;
int32 entity_id = 4;
int32 request_id = 5;
}
11 changes: 8 additions & 3 deletions src/simcontrol/SimControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,12 @@ bool SimControl::generate_entity(const int &ent_desc_id) {
if (it_params == mp_->entity_descriptions().end()) {
return false;
}
return generate_entity(ent_desc_id, it_params->second);
return generate_entity(ent_desc_id, it_params->second, 0);
}

bool SimControl::generate_entity(const int &ent_desc_id,
std::map<std::string, std::string> &params) {
std::map<std::string, std::string> &params,
int request_id) {
#if ENABLE_JSBSIM == 1
params["JSBSIM_ROOT"] = jsbsim_root_;
#endif
Expand Down Expand Up @@ -394,6 +395,7 @@ bool SimControl::generate_entity(const int &ent_desc_id,

auto msg = std::make_shared<Message<sm::EntityGenerated>>();
msg->data.set_entity_id(ent->id().id());
msg->data.set_request_id(request_id);
pub_ent_gen_->publish(msg);

return true;
Expand Down Expand Up @@ -864,10 +866,13 @@ bool SimControl::start() {
params[msg->data.entity_param(i).key()] = msg->data.entity_param(i).value();
}

int request_id = 0;
request_id = msg->data.request_id();

// Recreate the rtree with one additional size for this entity.
this->create_rtree(1);

if (not this->generate_entity(it_ent_desc_id->second, params)) {
if (not this->generate_entity(it_ent_desc_id->second, params, request_id)) {
cout << "Failed to generate entity with tag: "
<< msg->data.entity_tag() << endl;
return;
Expand Down