Skip to content

Commit

Permalink
added forest hilly levels
Browse files Browse the repository at this point in the history
  • Loading branch information
hrnycze committed Aug 30, 2024
1 parent 2e4979f commit 27d8ec1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
8 changes: 7 additions & 1 deletion config/unreal_simulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ ueds_graphics_settings_enum: 0
ueds_world_level_name_enum: 2


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

# Choose cluttered difficulties from 1 [high] to 10 [low]
ueds_forest_density: 6

# Choose Hilly Level from 1 [totally flat] to 5 [the most hilly]
ueds_forest_hilly_level: 3

####################################################################

sensors:

lidar:
Expand Down
2 changes: 2 additions & 0 deletions include/ueds_connector/game_mode_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class GameModeController : public SocketClient {
bool SwitchWorldLevel(const Serializable::GameMode::WorldLevelEnum& worldLevelEnum);

bool SetForestDensity(const int DensityLevel);

bool SetForestHillyLevel(const int HillyLevel);
};

} // namespace ueds_connector
22 changes: 21 additions & 1 deletion include/ueds_connector/serialization/serializable_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,8 @@ enum MessageType : unsigned short
get_api_version = 9,
set_graphics_settings = 10,
switch_world_level = 11,
set_forest_density = 12
set_forest_density = 12,
set_forest_hilly_level = 13
};

namespace GetDrones
Expand Down Expand Up @@ -927,6 +928,25 @@ struct Response : public Common::NetworkResponse
};
}; // namespace SetForestDensity

namespace SetForestHillyLevel
{
struct Request : public Common::NetworkRequest
{
Request() : Common::NetworkRequest(MessageType::set_forest_hilly_level){}
int Hilly_Level;

template <class Archive>
void serialize(Archive& archive) {
archive(cereal::base_class<Common::NetworkRequest>(this), Hilly_Level);
}
};
struct Response : public Common::NetworkResponse
{
Response() : Common::NetworkResponse(static_cast<unsigned short>(MessageType::set_forest_hilly_level)){};
explicit Response(bool _status) : Common::NetworkResponse(MessageType::set_forest_hilly_level, _status){};
};
}; // namespace SetForestHilly


namespace SpawnDrone
{
Expand Down
18 changes: 17 additions & 1 deletion src/ueds_connector/game_mode_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool GameModeController::RemoveDrone(const int port) {

//}

/* removeDrone() //{ */
/* SetForestDensity() //{ */

bool GameModeController::SetForestDensity(const int DensityLevel) {

Expand All @@ -71,6 +71,22 @@ bool GameModeController::SetForestDensity(const int DensityLevel) {

//}

/* SetForestHillyLevel() //{ */

bool GameModeController::SetForestHillyLevel(const int HillyLevel) {

Serializable::GameMode::SetForestHillyLevel::Request request{};
request.Hilly_Level = HillyLevel;

Serializable::GameMode::SetForestHillyLevel::Response response{};
const auto status = Request(request, response);
const auto success = status && response.status;

return success;
}

//}

/* getCameraCaptureMode() //{ */

std::pair<bool, CameraCaptureModeEnum> GameModeController::GetCameraCaptureMode() {
Expand Down
15 changes: 13 additions & 2 deletions src/unreal_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ class UnrealSimulator : public nodelet::Nodelet {
double ueds_fps_ = 0;
int ueds_world_level_name_enum_ = 2;
int ueds_graphics_settings_enum_ = 0;
int ueds_forest_density_ = 5;
int ueds_forest_density_ = 5;
int ueds_forest_hilly_level_ = 3;

std::vector<double> last_rgb_ue_stamp_;
std::vector<double> last_rgb_seg_ue_stamp_;
Expand Down Expand Up @@ -294,6 +295,7 @@ void UnrealSimulator::onInit() {
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("ueds_forest_density", ueds_forest_density_);
param_loader.loadParam("ueds_forest_hilly_level", ueds_forest_hilly_level_);

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

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

res = ueds_game_controller_->SetForestDensity(ueds_forest_density_);
if (res) {
Expand All @@ -465,6 +467,15 @@ void UnrealSimulator::onInit() {
ROS_ERROR("[UnrealSimulator]: Forest Density wasn't set succesfully to '%d'", ueds_forest_density_);
}

res = ueds_game_controller_->SetForestHillyLevel(ueds_forest_hilly_level_);
if (res) {
ROS_INFO("[UnrealSimulator]: Forest Hilly Level was set succesfully to '%d'", ueds_forest_hilly_level_);
} else {
ROS_ERROR("[UnrealSimulator]: Forest Hilly Level wasn't set succesfully to '%d'", ueds_forest_hilly_level_);
}

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

// | --------------------- Spawn the UAVs --------------------- |

for (size_t i = 0; i < uav_names.size(); i++) {
Expand Down

0 comments on commit 27d8ec1

Please sign in to comment.