Skip to content

Commit

Permalink
vtd: Enable VTD dynamics models
Browse files Browse the repository at this point in the history
A major overhaul of the initialization was necessary to support
multi-agent control with scenario selection both via GUI and config.
  • Loading branch information
clssn committed Feb 2, 2021
1 parent a073638 commit 8fac4bd
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 75 deletions.
22 changes: 20 additions & 2 deletions plugins/vtd/src/scp_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const char* Pause = "<SimCtrl><Pause/></SimCtrl>";
const char* Restart = "<SimCtrl><Restart/></SimCtrl>";
const char* Apply = "<SimCtrl><Apply/></SimCtrl>";
const char* Config = "<SimCtrl><Config/></SimCtrl>";
const char* QueryInit = "<Query entity=\"taskControl\"><Init source=\"cloe\" /></Query>";
const char* AckInit = "<SimCtrl><InitDone source=\"cloe\" /></SimCtrl>";
const char* InitOperation = "<SimCtrl><Init mode=\"operation\" /></SimCtrl>";

std::string ParamServerConfig::to_scp() const {
std::string tc_config = fmt::format(R"SCP(
Expand Down Expand Up @@ -64,12 +67,11 @@ std::string ParamServerConfig::to_scp() const {
)SCP", tc_config);
}

std::string ScenarioStartConfig::to_scp() const {
std::string ScenarioConfig::to_scp() const {
return fmt::format(R"SCP(
<SimCtrl>
<UnloadSensors />
<LoadScenario filename="{}" />
<Start mode="operation" />
</SimCtrl>
)SCP", filename);
}
Expand Down Expand Up @@ -153,6 +155,15 @@ std::string SensorConfiguration::to_scp() const {
</Sensor>)SCP", sensor_id, port, player_id);
}

std::string DynamicsPluginConfig::to_scp() const {
return fmt::format(R"SCP(
<DynamicsPlugin name="viTrafficDyn_{0}" enable="true">
<Load lib="libModuleTrafficDyn.so" path=""/>
<Player name="{0}" />
<Debug enable="false" />
</DynamicsPlugin>)SCP", name);
}

std::string LabelVehicle::to_scp() const {
return fmt::format(R"SCP(
<Symbol name="{0}">
Expand All @@ -169,6 +180,13 @@ std::string RecordDat::to_scp() const {
</Record>)SCP", datfile_path.parent_path().string(), datfile_path.filename().string());
}

std::string QueryScenario::to_scp() const {
return fmt::format(R"SCP(
<Query entity="traffic">
<GetScenario filename="{0}"/>
</Query>)SCP", scenario);
}

// clang-format on
} // namespace scp
} // namespace vtd
15 changes: 14 additions & 1 deletion plugins/vtd/src/scp_messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ extern const char* Pause;
extern const char* Restart;
extern const char* Apply;
extern const char* Config;
extern const char* QueryInit;
extern const char* AckInit;
extern const char* InitOperation;

struct ParamServerConfig : public ScpMessage {
std::string sync_source = "RDB";
bool no_image_generator = false;
std::string to_scp() const override;
};

struct ScenarioStartConfig : public ScpMessage {
struct ScenarioConfig : public ScpMessage {
std::string filename;
std::string to_scp() const override;
};
Expand All @@ -66,6 +69,11 @@ struct SensorConfiguration : public ScpMessage {
std::string to_scp() const override;
};

struct DynamicsPluginConfig : public ScpMessage {
std::string name;
std::string to_scp() const override;
};

struct LabelVehicle : public ScpMessage {
std::string tethered_to_player;
std::string text;
Expand All @@ -85,5 +93,10 @@ struct RecordDat : public ScpMessage {
std::string to_scp() const override;
};

struct QueryScenario : public ScpMessage {
std::string scenario;
std::string to_scp() const override;
};

} // namespace scp
} // namespace vtd
Loading

0 comments on commit 8fac4bd

Please sign in to comment.