Skip to content

Commit 350e321

Browse files
authored
Merge pull request #524 from gazebosim/scpeters/merge_9_main
Merge gz-sensors9 ➡️ main
2 parents 05cb532 + fe99619 commit 350e321

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

include/gz/sensors/AirSpeedSensor.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ namespace gz
7171
/// \brief Update the velocity of the sensor
7272
public: void SetVelocity(const gz::math::Vector3d &_vel);
7373

74+
/// \brief Update the wind velocity
75+
public: void SetWindVelocity(const gz::math::Vector3d &_windVel);
76+
7477
using Sensor::Update;
7578

7679
/// \brief Update the sensor and generate data

src/AirSpeedSensor.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class gz::sensors::AirSpeedSensorPrivate
6868
/// \brief Velocity of the air coming from the sensor
6969
public: gz::math::Vector3d vel;
7070

71+
/// \brief Velocity of the wind coming from the sensor
72+
public: gz::math::Vector3d windVel;
73+
7174
/// \brief Noise added to sensor data
7275
public: std::map<SensorNoiseType, NoisePtr> noises;
7376
};
@@ -169,12 +172,10 @@ bool AirSpeedSensor::Update(
169172
const float density_ratio = powf(kTemperaturMsl / temperature_local , 4.256f);
170173
const float air_density = kAirDensityMsl / density_ratio;
171174

172-
math::Vector3d wind_vel_{0, 0, 0};
173175
math::Quaterniond veh_q_world_to_body = this->Pose().Rot();
174-
175176
// calculate differential pressure + noise in hPa
176177
math::Vector3d air_vel_in_body_ = this->dataPtr->vel -
177-
veh_q_world_to_body.RotateVectorReverse(wind_vel_);
178+
veh_q_world_to_body.RotateVectorReverse(this->dataPtr->windVel);
178179
float diff_pressure = math::sgn(air_vel_in_body_.X()) * 0.005f * air_density
179180
* air_vel_in_body_.X() * air_vel_in_body_.X();
180181

@@ -209,6 +210,12 @@ void AirSpeedSensor::SetVelocity(const gz::math::Vector3d &_vel)
209210
this->dataPtr->vel = _vel;
210211
}
211212

213+
//////////////////////////////////////////////////
214+
void AirSpeedSensor::SetWindVelocity(const gz::math::Vector3d &_windVel)
215+
{
216+
this->dataPtr->windVel = _windVel;
217+
}
218+
212219
//////////////////////////////////////////////////
213220
bool AirSpeedSensor::HasConnections() const
214221
{

0 commit comments

Comments
 (0)