From a22bdc51ccac35d804975cee9b444ea3ead1edcf Mon Sep 17 00:00:00 2001 From: Daniel Santos-Olivan Date: Wed, 23 Sep 2020 15:30:53 +0200 Subject: [PATCH] Added commands for AddTorque and AddForce --- LibCarla/source/carla/rpc/Command.h | 20 +++++++++++++++++++ .../Carla/Source/Carla/Server/CarlaServer.cpp | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/LibCarla/source/carla/rpc/Command.h b/LibCarla/source/carla/rpc/Command.h index 6e689a2be..b5cec5d66 100644 --- a/LibCarla/source/carla/rpc/Command.h +++ b/LibCarla/source/carla/rpc/Command.h @@ -132,6 +132,16 @@ namespace rpc { MSGPACK_DEFINE_ARRAY(actor, impulse); }; + struct ApplyForce : CommandBase { + ApplyForce() = default; + ApplyForce(ActorId id, const geom::Vector3D &value) + : actor(id), + force(value) {} + ActorId actor; + geom::Vector3D force; + MSGPACK_DEFINE_ARRAY(actor, force); + }; + struct ApplyAngularImpulse : CommandBase { ApplyAngularImpulse() = default; ApplyAngularImpulse(ActorId id, const geom::Vector3D &value) @@ -142,6 +152,16 @@ namespace rpc { MSGPACK_DEFINE_ARRAY(actor, impulse); }; + struct ApplyTorque : CommandBase { + ApplyTorque() = default; + ApplyTorque(ActorId id, const geom::Vector3D &value) + : actor(id), + torque(value) {} + ActorId actor; + geom::Vector3D torque; + MSGPACK_DEFINE_ARRAY(actor, torque); + }; + struct SetSimulatePhysics : CommandBase { SetSimulatePhysics() = default; SetSimulatePhysics(ActorId id, bool value) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp index 99a4abeec..bc1384bff 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Server/CarlaServer.cpp @@ -1250,10 +1250,12 @@ void FCarlaServer::FPimpl::BindActions() [=](auto, const C::ApplyVehicleControl &c) { MAKE_RESULT(apply_control_to_vehicle(c.actor, c.control)); }, [=](auto, const C::ApplyWalkerControl &c) { MAKE_RESULT(apply_control_to_walker(c.actor, c.control)); }, [=](auto, const C::ApplyTransform &c) { MAKE_RESULT(set_actor_transform(c.actor, c.transform)); }, - [=](auto, const C::ApplyTargetVelocity &c) { MAKE_RESULT(set_actor_target_velocity(c.actor, c.velocity)); }, + [=](auto, const C::ApplyTargetVelocity &c) { MAKE_RESULT(set_actor_target_velocity(c.actor, c.velocity)); }, [=](auto, const C::ApplyTargetAngularVelocity &c) { MAKE_RESULT(set_actor_target_angular_velocity(c.actor, c.angular_velocity)); }, [=](auto, const C::ApplyImpulse &c) { MAKE_RESULT(add_actor_impulse(c.actor, c.impulse)); }, + [=](auto, const C::ApplyForce &c) { MAKE_RESULT(add_actor_force(c.actor, c.force)); }, [=](auto, const C::ApplyAngularImpulse &c) { MAKE_RESULT(add_actor_angular_impulse(c.actor, c.impulse)); }, + [=](auto, const C::ApplyTorque &c) { MAKE_RESULT(add_actor_torque(c.actor, c.torque)); }, [=](auto, const C::SetSimulatePhysics &c) { MAKE_RESULT(set_actor_simulate_physics(c.actor, c.enabled)); }, // TODO: SetAutopilot should be removed. This is the old way to control the vehicles [=](auto, const C::SetAutopilot &c) { MAKE_RESULT(set_actor_autopilot(c.actor, c.enabled)); },