Skip to content

Commit

Permalink
graphics/worldName string api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Hrncir committed Nov 15, 2024
1 parent 0ac97ba commit 20a084b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
6 changes: 3 additions & 3 deletions config/unreal_simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ collisions: true
# 2 - HIGH
# 4 - EPIC
# 5 - CINEMATIC
ueds_graphics_settings_enum: 0
graphics_settings: "medium"

# 0 - VALLEY
# 1 - FOREST
Expand All @@ -24,7 +24,7 @@ ueds_graphics_settings_enum: 0
# 4 - CAVE
# 5 - ERDING_AIRBASE
# 6 - TEMESVAR :D
ueds_world_level_name_enum: 3
world_name: "infinite_forest"

# {"sunny", 0},
# {"cloudy", 1},
Expand All @@ -36,7 +36,7 @@ ueds_world_level_name_enum: 3
# {"sand_dust_storm", 7},
# {"snow", 8},
# {"snow_blizzards", 9}
weather_type: "rain"
weather_type: "foggy"

daytime:
hour: 7
Expand Down
18 changes: 8 additions & 10 deletions src/unreal_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ class UnrealSimulator : public nodelet::Nodelet {
std::mutex mutex_wall_time_offset_;

double ueds_fps_ = 0;
int ueds_world_level_name_enum_ = 2;
int ueds_graphics_settings_enum_ = 0;
std::string ueds_world_level_name_enum_;
std::string ueds_graphics_settings_enum_;
int ueds_forest_density_ = 5;
int ueds_forest_hilly_level_ = 3;
std::string weather_type_;
Expand Down Expand Up @@ -321,8 +321,8 @@ void UnrealSimulator::onInit() {
param_loader.addYamlFileFromParam("config");
param_loader.addYamlFileFromParam("config_uavs");

param_loader.loadParam("ueds_graphics_settings_enum", ueds_graphics_settings_enum_);
param_loader.loadParam("ueds_world_level_name_enum", ueds_world_level_name_enum_);
param_loader.loadParam("graphics_settings", ueds_graphics_settings_enum_);
param_loader.loadParam("world_name", ueds_world_level_name_enum_);
param_loader.loadParam("ueds_forest_density", ueds_forest_density_);
param_loader.loadParam("ueds_forest_hilly_level", ueds_forest_hilly_level_);
param_loader.loadParam("weather_type", weather_type_);
Expand Down Expand Up @@ -469,8 +469,7 @@ void UnrealSimulator::onInit() {

// | --------------------- Set graphical settings and choose World Level --------------------- |

Serializable::GameMode::WorldLevelEnum worldLevelEnum = Serializable::GameMode::WorldLevelEnum(ueds_world_level_name_enum_);
res = ueds_game_controller_->SwitchWorldLevel(worldLevelEnum);
res = ueds_game_controller_->SwitchWorldLevel(ueds_connector::WorldName::Name2Id().at(ueds_world_level_name_enum_));
if (res) {
ROS_INFO("[UnrealSimulator] World was switched succesfully.");
} else {
Expand All @@ -497,13 +496,12 @@ void UnrealSimulator::onInit() {
std::this_thread::sleep_for(std::chrono::seconds(1));
}

Serializable::GameMode::GraphicsSettingsEnum graphicsSettings = Serializable::GameMode::GraphicsSettingsEnum(ueds_graphics_settings_enum_);
res = ueds_game_controller_->SetGraphicsSettings(graphicsSettings);
res = ueds_game_controller_->SetGraphicsSettings(ueds_connector::GraphicsSettings::Name2Id().at(ueds_graphics_settings_enum_));

if (res) {
ROS_INFO("[UnrealSimulator]: Graphical Settings was set succesfully to '%d'", graphicsSettings);
ROS_INFO("[UnrealSimulator]: Graphical Settings was set succesfully to '%s'", ueds_graphics_settings_enum_.c_str());
} else {
ROS_ERROR("[UnrealSimulator]: Graphical Settings was not set succesfully to '%d'", graphicsSettings);
ROS_ERROR("[UnrealSimulator]: Graphical Settings was not set succesfully to '%s'", ueds_graphics_settings_enum_.c_str());
}

res = ueds_game_controller_->SetWeather(ueds_connector::WeatherType::Type2Id().at(weather_type_));
Expand Down
13 changes: 10 additions & 3 deletions tmux/one_drone/config/simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ uav_names: [
"uav1",
]

ueds_graphics_settings_enum: 2
ueds_world_level_name_enum: 2
ueds_forest_hilly_level: 2

graphics_settings: "low"

world_name: "infinite_forest"

weather_type: "rain"

daytime:
hour: 7
minute: 30

uav1:
frame: "x500"
Expand Down

0 comments on commit 20a084b

Please sign in to comment.