Merge branch 'dev' into jose/adjustvehiclebb

This commit is contained in:
Blyron 2024-02-13 14:17:32 +01:00 committed by GitHub
commit bc96c5feb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 178 additions and 4 deletions

View File

@ -2,6 +2,7 @@
* Prevent from segfault on failing SignalReference identification when loading OpenDrive files
* Added vehicle doors to the recorder
* Adjusted vehicle BoundingBox when the vehicle opens the doors.
* Added functions to get actor' components transform
## CARLA 0.9.15

View File

@ -422,10 +422,10 @@ Drag your desired foliage item into the box labeled `+ Drop Foliage Here`. Set a
To export a map as a map package that can be ingested into a standalone CARLA package installation, use the `make package` command as follows:
```sh
make package ARGS="--packages=<mapPackage>"
make package ARGS="--packages=<mapName>"
```
The `<mapPackage>` must point to a json file located in `CARLA_ROOT/Unreal/CarlaUE4/Content/Carla/Config` named *mapPackage.json* which has the following structure:
The `<mapName>` must point to a json file located in `CARLA_ROOT/Unreal/CarlaUE4/Content/Carla/Config` named *mapName.Package.json* which has the following structure:
```json
{

9
Jenkinsfile vendored
View File

@ -189,12 +189,14 @@ pipeline
sh 'DISPLAY= ./Dist/CarlaUE4.sh -nullrhi -RenderOffScreen --carla-rpc-port=3654 --carla-streaming-port=0 -nosound > CarlaUE4.log &'
sh 'make smoke_tests ARGS="--xml --python-version=3.8 --target-wheel-platform=manylinux_2_27_x86_64"'
sh 'make run-examples ARGS="localhost 3654"'
sh 'tar -czf CarlaUE4_logs.tar.gz Unreal/CarlaUE4/Saved/Logs/'
}
post
{
always
{
archiveArtifacts 'CarlaUE4.log'
archiveArtifacts 'CarlaUE4_logs.tar.gz'
junit 'Build/test-results/smoke-tests-*.xml'
}
}
@ -320,6 +322,13 @@ pipeline
}
}
}
post
{
always
{
deleteDir()
}
}
}
/*
stage('windows')

View File

@ -32,6 +32,14 @@ namespace client {
return GetEpisode().Lock()->GetActorAcceleration(*this);
}
geom::Transform Actor::GetComponentWorldTransform(const std::string componentName) const {
return GetEpisode().Lock()->GetActorComponentWorldTransform(*this, componentName);
}
geom::Transform Actor::GetComponentRelativeTransform(const std::string componentName) const {
return GetEpisode().Lock()->GetActorComponentRelativeTransform(*this, componentName);
}
void Actor::SetLocation(const geom::Location &location) {
GetEpisode().Lock()->SetActorLocation(*this, location);
}

View File

@ -60,6 +60,10 @@ namespace client {
/// acceleration calculated after the actor's velocity.
geom::Vector3D GetAcceleration() const;
geom::Transform GetComponentWorldTransform(const std::string componentName) const;
geom::Transform GetComponentRelativeTransform(const std::string componentName) const;
/// Teleport the actor to @a location.
void SetLocation(const geom::Location &location);

View File

@ -408,6 +408,14 @@ namespace detail {
_pimpl->AsyncCall("add_actor_torque", actor, vector);
}
geom::Transform Client::GetActorComponentWorldTransform(rpc::ActorId actor, const std::string componentName) {
return _pimpl->CallAndWait<geom::Transform>("get_actor_component_world_transform", actor, componentName);
}
geom::Transform Client::GetActorComponentRelativeTransform(rpc::ActorId actor, const std::string componentName) {
return _pimpl->CallAndWait<geom::Transform>("get_actor_component_relative_transform", actor, componentName);
}
void Client::SetActorSimulatePhysics(rpc::ActorId actor, const bool enabled) {
_pimpl->CallAndWait<void>("set_actor_simulate_physics", actor, enabled);
}

View File

@ -88,6 +88,7 @@ namespace detail {
void DestroyTrafficManager(uint16_t port) const;
void SetTimeout(time_duration timeout);
time_duration GetTimeout() const;
@ -232,6 +233,14 @@ namespace detail {
rpc::ActorId actor,
const geom::Vector3D &vector);
geom::Transform GetActorComponentWorldTransform(
rpc::ActorId actor,
const std::string componentName);
geom::Transform GetActorComponentRelativeTransform(
rpc::ActorId actor,
const std::string componentName);
void SetActorSimulatePhysics(
rpc::ActorId actor,
bool enabled);

View File

@ -438,6 +438,14 @@ namespace detail {
return GetActorSnapshot(actor).acceleration;
}
geom::Transform GetActorComponentWorldTransform(const Actor &actor, const std::string componentName) {
return _client.GetActorComponentWorldTransform(actor.GetId(), componentName);
}
geom::Transform GetActorComponentRelativeTransform(const Actor &actor, std::string componentName) {
return _client.GetActorComponentRelativeTransform(actor.GetId(), componentName);
}
void SetActorLocation(Actor &actor, const geom::Location &location) {
_client.SetActorLocation(actor.GetId(), location);
}

View File

@ -113,6 +113,8 @@ void export_actor() {
.def("get_velocity", &cc::Actor::GetVelocity)
.def("get_angular_velocity", &cc::Actor::GetAngularVelocity)
.def("get_acceleration", &cc::Actor::GetAcceleration)
.def("get_component_world_transform", &cc::Actor::GetComponentWorldTransform, (arg("component_name")))
.def("get_component_relative_transform", &cc::Actor::GetComponentRelativeTransform, (arg("component_name")))
.def("set_location", &cc::Actor::SetLocation, (arg("location")))
.def("set_transform", &cc::Actor::SetTransform, (arg("transform")))
.def("set_target_velocity", &cc::Actor::SetTargetVelocity, (arg("velocity")))

View File

@ -0,0 +1,34 @@
import glob
import os
import sys
try:
sys.path.append(glob.glob('../carla/dist/carla-*%d.%d-%s.egg' % (
sys.version_info.major,
sys.version_info.minor,
'win-amd64' if os.name == 'nt' else 'linux-x86_64'))[0])
except IndexError:
pass
# ==============================================================================
# -- imports -------------------------------------------------------------------
# ==============================================================================
import carla
client = carla.Client('localhost', 2000)
world = client.get_world()
location = carla.Location(200.0, 200.0, 200.0)
rotation = carla.Rotation(0.0, 0.0, 0.0)
transform = carla.Transform(location, rotation)
bp_library = world.get_blueprint_library()
bp_audi = bp_library.find('vehicle.audi.tt')
audi = world.spawn_actor(bp_audi, transform)
component_transform = audi.get_component_world_transform('front-blinker-r-1')
print(component_transform)

View File

@ -1274,6 +1274,94 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
return R<void>::Success();
};
BIND_SYNC(get_actor_component_world_transform) << [this](
cr::ActorId ActorId,
const std::string componentName) -> R<cr::Transform>
{
REQUIRE_CARLA_EPISODE();
FCarlaActor* CarlaActor = Episode->FindCarlaActor(ActorId);
if (!CarlaActor)
{
return RespondError(
"get_actor_component_world_transform",
ECarlaServerResponse::ActorNotFound,
" Actor Id: " + FString::FromInt(ActorId));
}
else
{
TArray<UActorComponent*> Components;
CarlaActor->GetActor()->GetComponents(Components);
USceneComponent* Component;
for(auto Cmp : Components)
{
if(USceneComponent* SCMP = Cast<USceneComponent>(Cmp))
{
if(SCMP->GetName() == componentName.c_str())
{
Component = SCMP;
break;
}
}
}
if(!Component)
{
return RespondError(
"get_actor_component_world_transform",
ECarlaServerResponse::ComponentNotFound,
" Component Name: " + FString(componentName.c_str()));
}
FTransform ComponentWorldTransform = Component->GetComponentTransform();
return cr::Transform(ComponentWorldTransform);
}
};
BIND_SYNC(get_actor_component_relative_transform) << [this](
cr::ActorId ActorId,
const std::string componentName) -> R<cr::Transform>
{
REQUIRE_CARLA_EPISODE();
FCarlaActor* CarlaActor = Episode->FindCarlaActor(ActorId);
if (!CarlaActor)
{
return RespondError(
"get_actor_component_relative_transform",
ECarlaServerResponse::ActorNotFound,
" Actor Id: " + FString::FromInt(ActorId));
}
else
{
TArray<UActorComponent*> Components;
CarlaActor->GetActor()->GetComponents(Components);
USceneComponent* Component;
for(auto Cmp : Components)
{
if(USceneComponent* SCMP = Cast<USceneComponent>(Cmp))
{
if(SCMP->GetName() == componentName.c_str())
{
Component = SCMP;
break;
}
}
}
if(!Component)
{
return RespondError(
"get_actor_component_world_transform",
ECarlaServerResponse::ComponentNotFound,
" Component Name: " + FString(componentName.c_str()));
}
FTransform ComponentRelativeTransform = Component->GetRelativeTransform();
return cr::Transform(ComponentRelativeTransform);
}
};
BIND_SYNC(get_physics_control) << [this](
cr::ActorId ActorId) -> R<cr::VehiclePhysicsControl>
{

View File

@ -14,6 +14,8 @@ FString CarlaGetStringError(ECarlaServerResponse Response)
return "Sucess";
case ECarlaServerResponse::ActorNotFound:
return "Actor could not be found in the registry";
case ECarlaServerResponse::ComponentNotFound:
return "Component could not be found in this actor";
case ECarlaServerResponse::ActorTypeMismatch:
return "Actor does not match the expected type";
case ECarlaServerResponse::MissingActor:

View File

@ -10,6 +10,7 @@ enum class ECarlaServerResponse
{
Success,
ActorNotFound,
ComponentNotFound,
ActorTypeMismatch,
FunctionNotSupported,
NullActor,