Skip to content

Commit

Permalink
set time api
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Hrncir committed Nov 15, 2024
1 parent 122a608 commit 0ac97ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
6 changes: 5 additions & 1 deletion config/unreal_simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ ueds_world_level_name_enum: 3
# {"sand_dust_storm", 7},
# {"snow", 8},
# {"snow_blizzards", 9}
weather_type: "snow_blizzards"
weather_type: "rain"

daytime:
hour: 7
minute: 30

############ Only Forest Procedural Generation settings ############

Expand Down
24 changes: 17 additions & 7 deletions src/unreal_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class UnrealSimulator : public nodelet::Nodelet {
int ueds_forest_density_ = 5;
int ueds_forest_hilly_level_ = 3;
std::string weather_type_;
ueds_connector::Daytime daytime_;

std::vector<double> last_rgb_ue_stamp_;
std::vector<double> last_rgb_seg_ue_stamp_;
Expand Down Expand Up @@ -325,6 +326,8 @@ void UnrealSimulator::onInit() {
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_);
param_loader.loadParam("daytime/hour", daytime_.hour);
param_loader.loadParam("daytime/minute", daytime_.minute);

param_loader.loadParam("simulation_rate", _simulation_rate_);
param_loader.loadParam("realtime_factor", drs_params_.realtime_factor);
Expand Down Expand Up @@ -503,6 +506,20 @@ void UnrealSimulator::onInit() {
ROS_ERROR("[UnrealSimulator]: Graphical Settings was not set succesfully to '%d'", graphicsSettings);
}

res = ueds_game_controller_->SetWeather(ueds_connector::WeatherType::Type2Id().at(weather_type_));
if (res) {
ROS_INFO("[UnrealSimulator]: SetWeather successful.");
} else {
ROS_ERROR("[UnrealSimulator]: SetWeather error");
}

res = ueds_game_controller_->SetDatetime(daytime_.hour, daytime_.minute);
if (res) {
ROS_INFO("[UnrealSimulator]: SetDatetime successful.");
} else {
ROS_ERROR("[UnrealSimulator]: SetDatetime error");
}


// | --------------------- These graphical settings influence only Forest Game World --------------------- |

Expand All @@ -520,13 +537,6 @@ void UnrealSimulator::onInit() {
ROS_ERROR("[UnrealSimulator]: Forest Hilly Level wasn't set succesfully to '%d'", ueds_forest_hilly_level_);
}

res = ueds_game_controller_->SetWeather(ueds_connector::WeatherType::Type2Id().at(weather_type_));
if (res) {
ROS_INFO("[UnrealSimulator]: SetWeather successful.");
} else {
ROS_INFO("[UnrealSimulator]: SetWeather error !!!");
}

std::this_thread::sleep_for(std::chrono::seconds(1));

// | --------------------- Spawn the UAVs --------------------- |
Expand Down
4 changes: 2 additions & 2 deletions tmux/one_drone/config/simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ uav_names: [
]

ueds_graphics_settings_enum: 2
ueds_world_level_name_enum: 1
ueds_forest_hilly_level: 4
ueds_world_level_name_enum: 2
ueds_forest_hilly_level: 2

uav1:
frame: "x500"
Expand Down

0 comments on commit 0ac97ba

Please sign in to comment.