Skip to content

Commit e88a46f

Browse files
authored
wind addition to advanced_lift_drag plugin (#2226)
* wind addition to advanced_lift_drag plugin Signed-off-by: frederik <frederik@auterion.com> * added note on wind Signed-off-by: frederik <frederik@auterion.com> --------- Signed-off-by: frederik <frederik@auterion.com> Co-authored-by: frederik <frederik@auterion.com>
1 parent 82fbdba commit e88a46f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/systems/advanced_lift_drag/AdvancedLiftDrag.cc

+13-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "gz/sim/components/Name.hh"
6060
#include "gz/sim/components/ExternalWorldWrenchCmd.hh"
6161
#include "gz/sim/components/Pose.hh"
62+
#include "gz/sim/components/Wind.hh"
6263

6364
using namespace gz;
6465
using namespace sim;
@@ -481,6 +482,13 @@ void AdvancedLiftDragPrivate::Update(EntityComponentManager &_ecm)
481482
const auto worldPose =
482483
_ecm.Component<components::WorldPose>(this->linkEntity);
483484

485+
// get wind as a component from the _ecm
486+
components::WorldLinearVelocity *windLinearVel = nullptr;
487+
if(_ecm.EntityByComponents(components::Wind()) != kNullEntity){
488+
Entity windEntity = _ecm.EntityByComponents(components::Wind());
489+
windLinearVel =
490+
_ecm.Component<components::WorldLinearVelocity>(windEntity);
491+
}
484492

485493
std::vector<components::JointPosition*> controlJointPosition_vec(
486494
this->num_ctrl_surfaces);
@@ -499,8 +507,12 @@ void AdvancedLiftDragPrivate::Update(EntityComponentManager &_ecm)
499507

500508
const auto &pose = worldPose->Data();
501509
const auto cpWorld = pose.Rot().RotateVector(this->cp);
502-
const auto air_velocity = worldLinVel->Data() + worldAngVel->Data().Cross(
510+
auto air_velocity = worldLinVel->Data() + worldAngVel->Data().Cross(
503511
cpWorld);
512+
if (windLinearVel != nullptr){
513+
air_velocity = worldLinVel->Data() + worldAngVel->Data().Cross(
514+
cpWorld) - windLinearVel->Data();
515+
}
504516

505517
// Define body frame: X forward, Z downward, Y out the right wing
506518
gz::math::Vector3d body_x_axis = pose.Rot().RotateVector(this->forward);

src/systems/advanced_lift_drag/AdvancedLiftDrag.hh

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ namespace systems
4444
/// https://github.com/PX4/PX4-Autopilot/blob/main/Tools/simulation/
4545
/// gz/tools/avl_automation/
4646
///
47+
/// Note: Wind calculations can be enabled by setting the wind parameter
48+
/// in the world file.
4749
///
4850
/// ## System Parameters
4951
///

0 commit comments

Comments
 (0)