Javiergr cs/get socket names (#7170)
* Added new function to obtain the name of all actor sockets * Updating CHANGELOG.md * Simplifying code of get_actor_socket_names function --------- Co-authored-by: Blyron <53337103+Blyron@users.noreply.github.com>
This commit is contained in:
parent
fda970b881
commit
3eb9a76263
|
@ -8,6 +8,7 @@
|
|||
* Added functions to get actor' bones and components names
|
||||
* Added functions to get actor' sockets transforms
|
||||
* make PythonAPI Windows: Fixed incompatibility issue with Anaconda due `py` command.
|
||||
* Added function to get actor' sockets names
|
||||
* Fixed bug in python agents when vehicle list was empty causing a check on all vehicles (BasicAgent.py) and detected pedestrians as vehicles if no pedestrains are present (BehaviourAgent.py)
|
||||
* Added possibility to change gravity variable in imui sensor for the accelerometer
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ namespace client {
|
|||
return GetEpisode().Lock()->GetActorSocketRelativeTransforms(*this);
|
||||
}
|
||||
|
||||
std::vector<std::string> Actor::GetSocketNames() const {
|
||||
return GetEpisode().Lock()->GetActorSocketNames(*this);
|
||||
}
|
||||
|
||||
void Actor::SetLocation(const geom::Location &location) {
|
||||
GetEpisode().Lock()->SetActorLocation(*this, location);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace client {
|
|||
|
||||
std::vector<geom::Transform> GetSocketRelativeTransforms() const;
|
||||
|
||||
std::vector<std::string> GetSocketNames() const;
|
||||
|
||||
/// Teleport the actor to @a location.
|
||||
void SetLocation(const geom::Location &location);
|
||||
|
||||
|
|
|
@ -456,6 +456,11 @@ namespace detail {
|
|||
return _pimpl->CallAndWait<return_t>("get_actor_socket_relative_transforms", actor);
|
||||
}
|
||||
|
||||
std::vector<std::string> Client::GetActorSocketNames(rpc::ActorId actor) {
|
||||
using return_t = std::vector<std::string>;
|
||||
return _pimpl->CallAndWait<return_t>("get_actor_socket_names", actor);
|
||||
}
|
||||
|
||||
void Client::SetActorSimulatePhysics(rpc::ActorId actor, const bool enabled) {
|
||||
_pimpl->CallAndWait<void>("set_actor_simulate_physics", actor, enabled);
|
||||
}
|
||||
|
|
|
@ -263,6 +263,9 @@ namespace detail {
|
|||
std::vector<geom::Transform> GetActorSocketRelativeTransforms(
|
||||
rpc::ActorId actor);
|
||||
|
||||
std::vector<std::string> GetActorSocketNames(
|
||||
rpc::ActorId actor);
|
||||
|
||||
void SetActorSimulatePhysics(
|
||||
rpc::ActorId actor,
|
||||
bool enabled);
|
||||
|
|
|
@ -479,6 +479,10 @@ namespace detail {
|
|||
return _client.GetActorSocketRelativeTransforms(actor.GetId());
|
||||
}
|
||||
|
||||
std::vector<std::string> GetActorSocketNames(const Actor &actor) {
|
||||
return _client.GetActorSocketNames(actor.GetId());
|
||||
}
|
||||
|
||||
void SetActorLocation(Actor &actor, const geom::Location &location) {
|
||||
_client.SetActorLocation(actor.GetId(), location);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,8 @@ void export_actor() {
|
|||
.def("get_component_names", CALL_RETURNING_LIST(cc::Actor,GetComponentNames))
|
||||
.def("get_bone_names", CALL_RETURNING_LIST(cc::Actor,GetBoneNames))
|
||||
.def("get_socket_world_transforms", CALL_RETURNING_LIST(cc::Actor,GetSocketWorldTransforms))
|
||||
.def("get_socket_relative_transforms", CALL_RETURNING_LIST(cc::Actor,GetSocketRelativeTransforms))
|
||||
.def("get_socket_relative_transforms", CALL_RETURNING_LIST(cc::Actor,GetSocketRelativeTransforms))
|
||||
.def("get_socket_names", CALL_RETURNING_LIST(cc::Actor,GetSocketNames))
|
||||
.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")))
|
||||
|
|
|
@ -1402,7 +1402,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if (!CarlaActor)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_bone_world_transform",
|
||||
"get_actor_bone_world_transforms",
|
||||
ECarlaServerResponse::ActorNotFound,
|
||||
" Actor Id: " + FString::FromInt(ActorId));
|
||||
}
|
||||
|
@ -1414,7 +1414,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if(!SkinnedMeshComponents[0])
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_bone_relative_transforms",
|
||||
"get_actor_bone_world_transforms",
|
||||
ECarlaServerResponse::ComponentNotFound,
|
||||
" Component Name: SkinnedMeshComponent ");
|
||||
}
|
||||
|
@ -1443,7 +1443,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if (!CarlaActor)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_bone_relative_transform",
|
||||
"get_actor_bone_relative_transforms",
|
||||
ECarlaServerResponse::ActorNotFound,
|
||||
" Actor Id: " + FString::FromInt(ActorId));
|
||||
}
|
||||
|
@ -1509,7 +1509,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if (!CarlaActor)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_component_relative_transform",
|
||||
"get_actor_bone_names",
|
||||
ECarlaServerResponse::ActorNotFound,
|
||||
" Actor Id: " + FString::FromInt(ActorId));
|
||||
}
|
||||
|
@ -1519,7 +1519,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if(!SkinnedMeshComponent)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_bone_relative_transforms",
|
||||
"get_actor_bone_names",
|
||||
ECarlaServerResponse::ComponentNotFound,
|
||||
" Component Name: SkinnedMeshComponent ");
|
||||
}
|
||||
|
@ -1547,7 +1547,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if (!CarlaActor)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_component_relative_transform",
|
||||
"get_actor_socket_world_transforms",
|
||||
ECarlaServerResponse::ActorNotFound,
|
||||
" Actor Id: " + FString::FromInt(ActorId));
|
||||
}
|
||||
|
@ -1580,7 +1580,7 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
if (!CarlaActor)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_component_relative_transform",
|
||||
"get_actor_socket_relative_transforms",
|
||||
ECarlaServerResponse::ActorNotFound,
|
||||
" Actor Id: " + FString::FromInt(ActorId));
|
||||
}
|
||||
|
@ -1605,6 +1605,41 @@ BIND_SYNC(is_sensor_enabled_for_ros) << [this](carla::streaming::detail::stream_
|
|||
}
|
||||
};
|
||||
|
||||
BIND_SYNC(get_actor_socket_names) << [this](
|
||||
cr::ActorId ActorId) -> R<std::vector<std::string>>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
FCarlaActor* CarlaActor = Episode->FindCarlaActor(ActorId);
|
||||
if (!CarlaActor)
|
||||
{
|
||||
return RespondError(
|
||||
"get_actor_socket_names",
|
||||
ECarlaServerResponse::ActorNotFound,
|
||||
" Actor Id: " + FString::FromInt(ActorId));
|
||||
}
|
||||
else
|
||||
{
|
||||
TArray<FName> SocketNames;
|
||||
std::vector<std::string> StringSocketNames;
|
||||
TArray<UActorComponent*> Components;
|
||||
CarlaActor->GetActor()->GetComponents(Components);
|
||||
for(UActorComponent* ActorComponent : Components)
|
||||
{
|
||||
if(USceneComponent* SceneComponent = Cast<USceneComponent>(ActorComponent))
|
||||
{
|
||||
SocketNames = SceneComponent->GetAllSocketNames();
|
||||
for (const FName& Name : SocketNames)
|
||||
{
|
||||
FString FSocketName = Name.ToString();
|
||||
std::string StringSocketName = TCHAR_TO_UTF8(*FSocketName);
|
||||
StringSocketNames.push_back(StringSocketName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringSocketNames;
|
||||
}
|
||||
};
|
||||
|
||||
BIND_SYNC(get_physics_control) << [this](
|
||||
cr::ActorId ActorId) -> R<cr::VehiclePhysicsControl>
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue