Skip to content

Commit

Permalink
minor viewer updates
Browse files Browse the repository at this point in the history
  • Loading branch information
esquires committed Nov 26, 2018
1 parent cb9888f commit d9f1f59
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 12 additions & 1 deletion python/scrimmage/bindings/src/py_openai_env.cpp
Expand Up @@ -34,6 +34,7 @@

#include <scrimmage/entity/Entity.h>
#include <scrimmage/parse/MissionParse.h>
#include <scrimmage/parse/ParseUtils.h>
#include <scrimmage/simcontrol/SimControl.h>
#include <scrimmage/simcontrol/SimUtils.h>

Expand Down Expand Up @@ -256,9 +257,19 @@ void ScrimmageOpenAIEnv::reset_scrimmage(bool enable_gui) {
if (enable_gui) {
mp_->set_network_gui(true);
mp_->set_enable_gui(false);
std::string cmd = "scrimmage-viz ";

auto it = mp_->attributes().find("camera");
if (it != mp_->attributes().end()) {
auto camera_pos_str = sc::get<std::string>("pos", it->second, "0, 1, 200");
auto camera_focal_pos_str = sc::get<std::string>("focal_point", it->second, "0, 0, 0");
cmd += "--pos " + camera_pos_str
+ " --focal_point " + camera_focal_pos_str;
}
cmd += " &";

// TODO: fix this to get feedback that the gui is running
if (system("scrimmage-viz &")) {
if (system(cmd.c_str())) {
std::cout << "could not start scrimmage-viz" << std::endl;
}
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
Expand Down
10 changes: 9 additions & 1 deletion share/scrimmage-viz/main.cpp
Expand Up @@ -56,7 +56,9 @@ int main(int argc, char* argv[]) {
("local_ip,i", po::value<std::string>(), "The local IP address where this viewer will run.")
("local_port,p", po::value<std::string>(), "The local port where this viewer will listen.")
("remote_ip,r", po::value<std::string>(), "The remote IP address where SCRIMMAGE is running.")
("remote_port,o", po::value<std::string>(), "The remote port where SCRIMMAGE is running.");
("remote_port,o", po::value<std::string>(), "The remote port where SCRIMMAGE is running.")
("pos", po::value<std::string>(), "camera position")
("focal_point", po::value<std::string>(), "camera focal point");

po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
Expand All @@ -76,6 +78,12 @@ int main(int argc, char* argv[]) {
set_param(vm, params, "local_port");
set_param(vm, params, "remote_ip");
set_param(vm, params, "remote_port");
set_param(vm, params, "pos");
set_param(vm, params, "focal_point");

if (params.count("pos") > 0 || params.count("focal_point") > 0) {
params["mode"] = "FREE";
}

sc::Viewer viewer;
viewer.set_enable_network(true);
Expand Down
2 changes: 1 addition & 1 deletion test/test_openai.py
Expand Up @@ -49,7 +49,7 @@ def _run_test(version, combine_actors, global_sensor, get_action, timestep=-1):
entry_point='scrimmage.bindings:ScrimmageOpenAIEnv',
max_episode_steps=1e9,
reward_threshold=1e9,
kwargs={"enable_gui": False,
kwargs={"enable_gui": True,
"combine_actors": combine_actors,
"global_sensor": global_sensor,
"mission_file": TEMP_MISSION_FILE,
Expand Down

0 comments on commit d9f1f59

Please sign in to comment.