Added IMUI gravity parameter
This commit is contained in:
parent
aa19e139d8
commit
caca5f02e8
|
@ -90,6 +90,15 @@ namespace client {
|
|||
void World::SetWeather(const rpc::WeatherParameters &weather) {
|
||||
_episode.Lock()->SetWeatherParameters(weather);
|
||||
}
|
||||
|
||||
float World::GetIMUISensorGravity() const {
|
||||
return _episode.Lock()->GetIMUISensorGravity();
|
||||
}
|
||||
|
||||
void World::SetIMUISensorGravity(float NewIMUISensorGravity) {
|
||||
_episode.Lock()->SetIMUISensorGravity(NewIMUISensorGravity);
|
||||
}
|
||||
|
||||
|
||||
WorldSnapshot World::GetSnapshot() const {
|
||||
return _episode.Lock()->GetWorldSnapshot();
|
||||
|
|
|
@ -94,6 +94,12 @@ namespace client {
|
|||
/// Change the weather in the simulation.
|
||||
void SetWeather(const rpc::WeatherParameters &weather);
|
||||
|
||||
/// Get Gravity value used for IMUI Sensor accelerometer calculation
|
||||
float GetIMUISensorGravity() const;
|
||||
|
||||
/// Set Gravity value used for IMUI Sensor accelerometer calculation
|
||||
void SetIMUISensorGravity(float NewIMUISensorGravity);
|
||||
|
||||
/// Return a snapshot of the world at this moment.
|
||||
WorldSnapshot GetSnapshot() const;
|
||||
|
||||
|
|
|
@ -266,6 +266,14 @@ namespace detail {
|
|||
void Client::SetWeatherParameters(const rpc::WeatherParameters &weather) {
|
||||
_pimpl->AsyncCall("set_weather_parameters", weather);
|
||||
}
|
||||
|
||||
float Client::GetIMUISensorGravity() {
|
||||
return _pimpl->CallAndWait<float>("get_imui_gravity");
|
||||
}
|
||||
|
||||
void Client::SetIMUISensorGravity(float NewIMUISensorGravity) {
|
||||
_pimpl->AsyncCall("set_imui_gravity", NewIMUISensorGravity);
|
||||
}
|
||||
|
||||
std::vector<rpc::Actor> Client::GetActorsById(
|
||||
const std::vector<ActorId> &ids) {
|
||||
|
|
|
@ -148,6 +148,10 @@ namespace detail {
|
|||
rpc::WeatherParameters GetWeatherParameters();
|
||||
|
||||
void SetWeatherParameters(const rpc::WeatherParameters &weather);
|
||||
|
||||
float GetIMUISensorGravity();
|
||||
|
||||
void SetIMUISensorGravity( float NewIMUISensorGravity );
|
||||
|
||||
std::vector<rpc::Actor> GetActorsById(const std::vector<ActorId> &ids);
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ namespace detail {
|
|||
}
|
||||
|
||||
uint64_t SetEpisodeSettings(const rpc::EpisodeSettings &settings);
|
||||
|
||||
|
||||
rpc::WeatherParameters GetWeatherParameters() {
|
||||
return _client.GetWeatherParameters();
|
||||
}
|
||||
|
@ -259,6 +259,14 @@ namespace detail {
|
|||
_client.SetWeatherParameters(weather);
|
||||
}
|
||||
|
||||
float GetIMUISensorGravity() {
|
||||
return _client.GetIMUISensorGravity();
|
||||
}
|
||||
|
||||
void SetIMUISensorGravity(float NewIMUISensorGravity) {
|
||||
_client.SetIMUISensorGravity(NewIMUISensorGravity);
|
||||
}
|
||||
|
||||
rpc::VehiclePhysicsControl GetVehiclePhysicsControl(const Vehicle &vehicle) const {
|
||||
return _client.GetVehiclePhysicsControl(vehicle.GetId());
|
||||
}
|
||||
|
|
|
@ -111,7 +111,11 @@ public:
|
|||
const carla::rpc::MaterialParameter& TextureParam);
|
||||
|
||||
TArray<FString> GetNamesOfAllActors();
|
||||
|
||||
|
||||
// Gravitational acceleration. Default is earth one, which is approximately 9.81 m/s^2
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="Sensor Gravity")
|
||||
float IMUISensorGravity = 9.81f;
|
||||
|
||||
protected:
|
||||
|
||||
void InitGame(const FString &MapName, const FString &Options, FString &ErrorMessage) override;
|
||||
|
@ -176,8 +180,9 @@ private:
|
|||
UPROPERTY()
|
||||
ATrafficLightManager* TrafficLightManager = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
ALargeMapManager* LMManager = nullptr;
|
||||
|
||||
|
||||
FDelegateHandle OnEpisodeSettingsChangeHandle;
|
||||
|
||||
boost::optional<carla::road::Map> Map;
|
||||
|
|
|
@ -104,8 +104,8 @@ carla::geom::Vector3D AInertialMeasurementUnit::ComputeAccelerometer(
|
|||
{
|
||||
// Used to convert from UE4's cm to meters
|
||||
constexpr float TO_METERS = 1e-2;
|
||||
// Earth's gravitational acceleration is approximately 9.81 m/s^2
|
||||
constexpr float GRAVITY = 9.81f;
|
||||
// Gravity set by gamemode
|
||||
const float GRAVITY = UCarlaStatics::GetGameMode(GetWorld())->IMUISensorGravity;
|
||||
|
||||
// 2nd derivative of the polynomic (quadratic) interpolation
|
||||
// using the point in current time and two previous steps:
|
||||
|
|
|
@ -664,6 +664,31 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
Weather->ApplyWeather(weather);
|
||||
return R<void>::Success();
|
||||
};
|
||||
|
||||
// -- IMUI Gravity ---------------------------------------------------------
|
||||
|
||||
BIND_SYNC(get_imui_gravity) << [this]() -> R<float>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
||||
if (GameMode == nullptr)
|
||||
{
|
||||
RESPOND_ERROR("get_imui_gravity error: unable to get carla gamemode");
|
||||
}
|
||||
return GameMode->IMUISensorGravity;
|
||||
};
|
||||
|
||||
BIND_SYNC(set_imui_gravity) << [this](float newimuigravity) -> R<void>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
||||
if (GameMode == nullptr)
|
||||
{
|
||||
RESPOND_ERROR("get_imui_gravity error: unable to get carla gamemode");
|
||||
}
|
||||
GameMode->IMUISensorGravity = newimuigravity;
|
||||
return R<void>::Success();
|
||||
};
|
||||
|
||||
// ~~ Actor operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
Loading…
Reference in New Issue