Adding conversion for meter / centimeter for Vector3D
This commit is contained in:
parent
eaf3392c66
commit
c360d1407b
|
@ -38,7 +38,7 @@ namespace detail {
|
|||
DEBUG_ONLY(auto result = )
|
||||
next->_actors.emplace(
|
||||
actor.id,
|
||||
ActorState{actor.transform, actor.velocity, actor.angularVelocity, acceleration, actor.state});
|
||||
ActorState{actor.transform, actor.velocity, actor.angular_velocity, acceleration, actor.state});
|
||||
DEBUG_ASSERT(result.second);
|
||||
}
|
||||
return next;
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace detail {
|
|||
struct ActorState {
|
||||
geom::Transform transform;
|
||||
geom::Vector3D velocity;
|
||||
geom::Vector3D angularVelocity;
|
||||
geom::Vector3D angular_velocity;
|
||||
geom::Vector3D acceleration;
|
||||
sensor::data::ActorDynamicState::TypeDependentState state;
|
||||
};
|
||||
|
|
|
@ -178,7 +178,7 @@ namespace detail {
|
|||
}
|
||||
|
||||
geom::Vector3D GetActorAngularVelocity(const Actor &actor) const {
|
||||
return GetActorDynamicState(actor).angularVelocity;
|
||||
return GetActorDynamicState(actor).angular_velocity;
|
||||
}
|
||||
|
||||
void SetActorAngularVelocity(const Actor &actor, const geom::Vector3D &vector) {
|
||||
|
|
|
@ -137,8 +137,22 @@ namespace geom {
|
|||
|
||||
#ifdef LIBCARLA_INCLUDED_FROM_UE4
|
||||
|
||||
Vector3D(const FVector &vector) // from centimeters to meters.
|
||||
: Vector3D(1e-2f * vector.X, 1e-2f * vector.Y, 1e-2f * vector.Z) {}
|
||||
Vector3D(const FVector &vector)
|
||||
: Vector3D(vector.X, vector.Y, vector.Z) {}
|
||||
|
||||
Vector3D &ToMeters(void) { // from centimeters to meters.
|
||||
x *= 0.001f;
|
||||
y *= 0.001f;
|
||||
z *= 0.001f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Vector3D &ToCentimeters(void) { // from meters to centimeters.
|
||||
x *= 100.0f;
|
||||
y *= 100.0f;
|
||||
z *= 100.0f;
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator FVector() const {
|
||||
return FVector{1e2f * x, 1e2f * y, 1e2f * z}; // from meters to centimeters.
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace detail {
|
|||
|
||||
geom::Vector3D velocity;
|
||||
|
||||
geom::Vector3D angularVelocity;
|
||||
geom::Vector3D angular_velocity;
|
||||
|
||||
union TypeDependentState {
|
||||
rpc::TrafficLightState traffic_light_state;
|
||||
|
|
|
@ -305,7 +305,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
if (!ActorView.IsValid() || ActorView.GetActor()->IsPendingKill()) {
|
||||
RespondErrorStr("unable to get actor velocity: actor not found");
|
||||
}
|
||||
return {ActorView.GetActor()->GetRootComponent()->GetComponentVelocity()};
|
||||
return cr::Vector3D(ActorView.GetActor()->GetRootComponent()->GetComponentVelocity()).ToMeters();
|
||||
});
|
||||
|
||||
Server.BindSync("get_actor_angular_velocity", [this](cr::Actor Actor) -> cr::Vector3D {
|
||||
|
@ -318,7 +318,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
if (RootComponent == nullptr) {
|
||||
RespondErrorStr("unable to get actor angular velocity: not supported by actor");
|
||||
}
|
||||
return {RootComponent->GetPhysicsAngularVelocityInDegrees()};
|
||||
return cr::Vector3D(RootComponent->GetPhysicsAngularVelocityInDegrees()).ToMeters();
|
||||
});
|
||||
|
||||
Server.BindSync("set_actor_angular_velocity", [this](
|
||||
|
@ -334,7 +334,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
RespondErrorStr("unable to set actor angular velocity: not supported by actor");
|
||||
}
|
||||
RootComponent->SetPhysicsAngularVelocityInDegrees(
|
||||
vector,
|
||||
vector.ToCentimeters(),
|
||||
false,
|
||||
"None");
|
||||
});
|
||||
|
@ -352,7 +352,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
RespondErrorStr("unable to set actor velocity: not supported by actor");
|
||||
}
|
||||
RootComponent->SetPhysicsLinearVelocity(
|
||||
vector,
|
||||
vector.ToCentimeters(),
|
||||
false,
|
||||
"None");
|
||||
});
|
||||
|
@ -370,7 +370,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
RespondErrorStr("unable to add actor force: not supported by actor");
|
||||
}
|
||||
RootComponent->AddForce(
|
||||
vector,
|
||||
vector.ToCentimeters(),
|
||||
"None",
|
||||
false);
|
||||
});
|
||||
|
@ -388,7 +388,7 @@ void FTheNewCarlaServer::FPimpl::BindActions()
|
|||
RespondErrorStr("unable to add actor impulse: not supported by actor");
|
||||
}
|
||||
RootComponent->AddImpulse(
|
||||
vector,
|
||||
vector.ToCentimeters(),
|
||||
"None",
|
||||
false);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue