Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Plugin XML Attributes to Mission XML Log #568

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
58c3fed
Initial commit
Mar 31, 2023
84bd801
Working verison, adds attribute and value and then prints the doc upd…
Apr 10, 2023
68dc6c3
Working for all plugins
Apr 10, 2023
21c7b98
Created function to parse the plugin specific xml file. This is worki…
Apr 11, 2023
c95c68a
Code cleanup
Apr 11, 2023
45508c5
Removed mission file change
Apr 11, 2023
75a9aa9
minor error message changes, added extra digit to time UI
Apr 11, 2023
812b327
Merge branch 'william-qol' of https://github.com/gtri/scrimmage into …
Apr 11, 2023
cc27377
Added returns in case of error with finding params files
Apr 11, 2023
afd20a8
Working with scrimmage_plugin_path environment variable
Apr 18, 2023
ad6b58f
Mission.plugin.xml log file added
Apr 18, 2023
a9fb57d
Code cleanup
Apr 18, 2023
2d04f5a
Initial commit of mission to mission xml pull request. Currently, abl…
May 24, 2023
36187fa
Struct is working between mission parse and sim control files. Can re…
May 25, 2023
87f2ed7
Working for updating x, y, and z pos of new entities
May 26, 2023
811875e
Removes original entity blocks
May 26, 2023
2f9d201
Additional checks/removals
May 31, 2023
b2936d3
Added tag to determine if mission 2 mission output file should be cre…
Jun 1, 2023
a5d6fce
Remove block tag working for original entities being added/removed fr…
Jun 5, 2023
4fce2a7
New final entity state file is created to view the final states of ea…
Jun 5, 2023
b8eaacb
Code cleanup
Jun 5, 2023
1e0fa94
Code cleanup
Jun 7, 2023
794e018
Working before trying to put struct with fwd decl file
Jun 7, 2023
7902c32
Struct in header is now working... do not need fwd decl or the new he…
Jun 7, 2023
b119eab
Delete EntEndStates.h
laserjetprinter Jun 7, 2023
7e6d3cb
Cleanup and support for struct in simcontrol header
Jun 7, 2023
d47c78d
Merge branch 'plugintomissionxml' of https://github.com/gtri/scrimmag…
Jun 7, 2023
1b53c6f
Updating header comments
Jun 7, 2023
683ef14
Test commit
Jun 14, 2023
d09062e
Code clean up
Jun 21, 2023
495c54a
Fixing a seg fault case based on mission xml tags
Jun 23, 2023
50e6269
Working on getting the plugin specific xml tag values. Currently am a…
Jun 26, 2023
300567f
Function working to get the xml tag values from the autonomy plugin
Jun 26, 2023
5115e3b
Rapid xml is working, writing plugin specific tags to the motion mode…
Jun 28, 2023
44a8fd7
Fully working for plugin specific xml tags populating the mission to …
Jun 30, 2023
5ae9f77
Fixed so that the plugin xml tags that are from the function overwrit…
Jun 30, 2023
35035ae
Fixed remove block tag logic
Jul 5, 2023
d54a383
Code cleanup and adding briefs
Jul 6, 2023
f5dfa48
Changing var names of miss2miss
Jul 6, 2023
09bde10
Added brief to Mission Parse header
Jul 6, 2023
4271d6a
RST file
Jul 10, 2023
318b405
Forgot to add the mission-to-mission-xml rst file
Jul 10, 2023
050e2d5
Minor updates
Jul 13, 2023
bd6a242
Merge branch 'master' of https://github.com/gtri/scrimmage into plugi…
Jul 25, 2023
ebf9605
Removing files that were used only for demoing
Aug 2, 2023
2ddb14b
Reverting William's changes to see if Docker builds
Aug 2, 2023
c025b7c
Fixed issue where docker was seg faulting for the test_openai.py file
Aug 2, 2023
c0267fa
Adding williams changes back
Aug 9, 2023
064bcd5
Merge branch 'master' of https://github.com/gtri/scrimmage into plugi…
Aug 21, 2023
fd5c886
Fixed the team id check and wording in the tutorial file
Aug 26, 2023
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
19 changes: 18 additions & 1 deletion include/scrimmage/parse/MissionParse.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include <scrimmage/proto/Visual.pb.h>

#include <scrimmage/proto/Color.pb.h>
#include <scrimmage/simcontrol/SimControl.h>
#include <rapidxml/rapidxml.hpp>

#include <list>
#include <vector>
Expand Down Expand Up @@ -78,12 +80,21 @@ struct GenerateInfo {
bool first_in_group;
double time_variance;
};

// test
class MissionParse {
public:
bool create_log_dir();
void set_overrides(const std::string &overrides);
bool parse(const std::string &filename);
void get_plugin_params(std::string node_name, std::string node_value);

/// @brief Generate the mission to mission xml file for all final states of entities
/// @param all_end_states
void final_state_xml(std::list<SimControl::ent_end_state> & all_end_states);

/// @brief Track the number of entity blocks in the input Mission XML file
int num_ents = 0;

bool write(const std::string &filename);

double t0();
Expand Down Expand Up @@ -161,6 +172,12 @@ class MissionParse {
protected:
std::string mission_filename_ = "";
std::string mission_file_content_ = "";
std::string miss2miss_file_content = "";
std::stringstream ent_state_file_content;
std::string mission_plugin_file_content = "";
std::string scrimmage_plugin_path = "";
std::map<std::string, std::string> plugin_spec_attrs;
rapidxml::xml_document<> doc;

double t0_ = 0;
double tend_ = 50;
Expand Down
21 changes: 21 additions & 0 deletions include/scrimmage/simcontrol/SimControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,26 @@ class SimControl {

void set_running_in_thread(bool running_in_thread);

/// @brief Contains the final state values of each entity
struct ent_end_state {
int team_id;
double x_pos;
double y_pos;
double z_pos;

double yaw;
double pitch;
double roll;

int health_points;

double vel_x;
double vel_y;
double vel_z;
} end_state;

std::list<ent_end_state> all_end_states;

protected:
// Key: Entity ID
// Value: Team ID
Expand Down Expand Up @@ -363,6 +383,7 @@ class SimControl {

bool finished_ = false;
bool exit_ = false;
bool miss2miss = false;

std::mutex finished_mutex_;
std::mutex contacts_mutex_;
Expand Down
2 changes: 1 addition & 1 deletion src/entity/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ void Entity::print_plugins(std::ostream &out) const {
out << c->name() << endl;
}
out << "----------- Motion -------------" << endl;
if (motion_model_->name() != "BLANK") {
if (motion_model_ && motion_model_->name() != "BLANK") {
out << motion_model_->name() << endl;
}
}
Expand Down
14 changes: 13 additions & 1 deletion src/parse/ConfigParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,19 @@ bool ConfigParse::parse(const std::map<std::string, std::string> &overrides,
buffer << file.rdbuf();
file.close();
std::string content(buffer.str());
doc.parse<0>(&content[0]);
try {
// Note: This parse function can hard fail (seg fault, no exception) on
// badly formatted xml data. Sometimes it'll except, sometimes not.
// doc.parse<0>(mission_file_content_vec.data());
doc.parse<0>(&content[0]);
}
catch (const rapidxml::parse_error& e)
{
std::cout << e.what() << std::endl;
throw std::runtime_error("Error parsing config file " + filename);
// cout << "scrimmage::MissionParse::parse: Exception during rapidxml::xml_document<>.parse<>()." << endl;
return false;
}

rx::xml_node<> *config_node = doc.first_node("params");
if (config_node == 0) {
Expand Down
Loading