Added commands for AddTorque and AddForce

This commit is contained in:
Daniel Santos-Olivan 2020-09-23 15:30:53 +02:00 committed by bernat
parent 11f5a749f4
commit a22bdc51cc
2 changed files with 23 additions and 1 deletions

View File

@ -132,6 +132,16 @@ namespace rpc {
MSGPACK_DEFINE_ARRAY(actor, impulse);
};
struct ApplyForce : CommandBase<ApplyForce> {
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> {
ApplyAngularImpulse() = default;
ApplyAngularImpulse(ActorId id, const geom::Vector3D &value)
@ -142,6 +152,16 @@ namespace rpc {
MSGPACK_DEFINE_ARRAY(actor, impulse);
};
struct ApplyTorque : CommandBase<ApplyTorque> {
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> {
SetSimulatePhysics() = default;
SetSimulatePhysics(ActorId id, bool value)

View File

@ -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)); },