-
Notifications
You must be signed in to change notification settings - Fork 110
Airflow/Wind Sensor #1349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
henrykotze
wants to merge
7
commits into
gazebosim:sdf13
Choose a base branch
from
henrykotze:airflow-sensor
base: sdf13
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Airflow/Wind Sensor #1349
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9e8da4b
Airflow Sensor
eabab06
codecheck passed
dba65db
Fix typos
73a7dda
Apply suggestions from code review
9560bfc
Add python Airflow Test
6f3b092
Merge branch 'sdf13' into airflow-sensor
mjcarroll adf9777
Merge branch 'sdf13' into airflow-sensor
mjcarroll File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright 2023 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
#ifndef SDF_AirFlow_HH_ | ||
#define SDF_AirFlow_HH_ | ||
|
||
#include <gz/utils/ImplPtr.hh> | ||
|
||
#include <sdf/Error.hh> | ||
#include <sdf/Element.hh> | ||
#include <sdf/Noise.hh> | ||
#include <sdf/sdf_config.h> | ||
|
||
namespace sdf | ||
{ | ||
// Inline bracke to help doxygen filtering. | ||
inline namespace SDF_VERSION_NAMESPACE { | ||
/// \brief AirFlow contains information about a general | ||
/// purpose air flow sensor. | ||
/// This sensor can be attached to a link. | ||
class SDFORMAT_VISIBLE AirFlow | ||
{ | ||
/// \brief Default constructor | ||
public: AirFlow(); | ||
|
||
/// \brief Load the air flow based on an element pointer. | ||
/// This is *not* the usual entry point. Typical usage of the SDF DOM is | ||
/// through the Root object. | ||
/// \param[in] _sdf The SDF Element pointer | ||
/// \return Errors, which is a vector of Error objects. Each Error includes | ||
/// an error code and message. An empty vector indicates no error. | ||
public: Errors Load(ElementPtr _sdf); | ||
|
||
/// \brief Get a pointer to the SDF element that was used during | ||
/// load. | ||
/// \return SDF element pointer. The value will be nullptr if Load has | ||
/// not been called. | ||
public: sdf::ElementPtr Element() const; | ||
|
||
/// \brief Get the noise values. | ||
/// \return Noise values for differential pressure data. | ||
public: const Noise &SpeedNoise() const; | ||
|
||
/// \brief Set the noise values related to the differential pressure data. | ||
/// \param[in] _noise Noise values for the pressure data. | ||
public: void SetSpeedNoise(const Noise &_noise);\ | ||
|
||
/// \brief Get the noise values. | ||
/// \return Noise values for differential pressure data. | ||
public: const Noise &DirectionNoise() const; | ||
|
||
/// \brief Set the noise values related to the differential pressure data. | ||
/// \param[in] _noise Noise values for the pressure data. | ||
public: void SetDirectionNoise(const Noise &_noise); | ||
|
||
/// \brief Return true if both AirFlow objects contain the | ||
/// same values. | ||
/// \param[_in] _air AirFlow value to compare. | ||
/// \returen True if 'this' == _air. | ||
public: bool operator==(const AirFlow &_air) const; | ||
|
||
/// \brief Return true this AirFlow object does not contain | ||
/// the same values as the passed in parameter. | ||
/// \param[_in] _air AirFlow value to compare. | ||
/// \returen True if 'this' != _air. | ||
public: bool operator!=(const AirFlow &_air) const; | ||
|
||
/// \brief Create and return an SDF element filled with data from this | ||
/// air pressure sensor. | ||
/// Note that parameter passing functionality is not captured with this | ||
/// function. | ||
/// \return SDF element pointer with updated sensor values. | ||
public: sdf::ElementPtr ToElement() const; | ||
|
||
/// \brief Private data pointer. | ||
GZ_UTILS_IMPL_PTR(dataPtr) | ||
}; | ||
} | ||
} | ||
#endif | ||
henrykotze marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2023 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "pyAirFlow.hh" | ||
|
||
#include <pybind11/operators.h> | ||
#include <pybind11/pybind11.h> | ||
|
||
#include "sdf/AirFlow.hh" | ||
|
||
|
||
using namespace pybind11::literals; | ||
henrykotze marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace sdf | ||
{ | ||
// Inline bracket to help doxygen filtering. | ||
inline namespace SDF_VERSION_NAMESPACE { | ||
namespace python | ||
{ | ||
///////////////////////////////////////////////// | ||
void defineAirFlow(pybind11::object module) | ||
{ | ||
pybind11::class_<sdf::AirFlow> geometryModule(module, "AirFlow"); | ||
geometryModule | ||
.def(pybind11::init<>()) | ||
.def(pybind11::init<sdf::AirFlow>()) | ||
.def(pybind11::self == pybind11::self) | ||
.def(pybind11::self != pybind11::self) | ||
.def("speed_noise", &sdf::AirFlow::SpeedNoise, | ||
"Get the speed noise values.") | ||
.def("set_speed_noise", | ||
&sdf::AirFlow::SetSpeedNoise, | ||
"Set the noise values related to the speed data.") | ||
.def("dir_noise", &sdf::AirFlow::DirectionNoise, | ||
"Get the direction noise values.") | ||
.def("set_direction_noise", | ||
&sdf::AirFlow::SetDirectionNoise, | ||
"Set the noise values related to the direction data.") | ||
.def("__copy__", [](const sdf::AirFlow &self) { | ||
return sdf::AirFlow(self); | ||
}) | ||
.def("__deepcopy__", [](const sdf::AirFlow &self, pybind11::dict) { | ||
return sdf::AirFlow(self); | ||
}, "memo"_a); | ||
} | ||
} // namespace python | ||
} // namespace SDF_VERSION_NAMESPACE | ||
} // namespace sdf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2023 Open Source Robotics Foundation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef SDFORMAT_PYTHON_AIRFLOW_HH_ | ||
#define SDFORMAT_PYTHON_AIRFLOW_HH_ | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
#include "sdf/AirFlow.hh" | ||
|
||
#include "sdf/config.hh" | ||
|
||
namespace sdf | ||
{ | ||
// Inline bracket to help doxygen filtering. | ||
inline namespace SDF_VERSION_NAMESPACE { | ||
namespace python | ||
{ | ||
/// Define a pybind11 wrapper for an sdf::AirFlow | ||
/** | ||
* \param[in] module a pybind11 module to add the definition to | ||
*/ | ||
void defineAirFlow(pybind11::object module); | ||
} // namespace python | ||
} // namespace SDF_VERSION_NAMESPACE | ||
} // namespace sdf | ||
|
||
#endif // SDFORMAT_PYTHON_AirFlow_HH_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (C) 2023 Open Source Robotics Foundation | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License") | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from gz_test_deps.sdformat import AirFlow, Noise | ||
import gz_test_deps.sdformat as sdf | ||
import unittest | ||
|
||
class AirFlowTEST(unittest.TestCase): | ||
|
||
|
||
def test_default_construction(self): | ||
airflow = AirFlow() | ||
defaultNoise = Noise() | ||
self.assertEqual(defaultNoise, airflow.direction_noise()) | ||
self.assertEqual(defaultNoise, airflow.speed_noise()) | ||
|
||
def test_set(self): | ||
air = AirFlow() | ||
defaultNoise = Noise() | ||
dir_noise = Noise() | ||
speed_noise = Noise() | ||
self.assertEqual(defaultNoise, air.speed_noise()) | ||
self.assertEqual(defaultNoise, air.direction_noise()) | ||
|
||
dir_noise.set_type(sdf.NoiseType.GAUSSIAN) | ||
dir_noise.set_mean(1.2) | ||
dir_noise.set_std_dev(2.3) | ||
dir_noise.set_bias_mean(4.5) | ||
dir_noise.set_bias_std_dev(6.7) | ||
dir_noise.set_precision(8.9) | ||
|
||
speed_noise.set_type(sdf.NoiseType.GAUSSIAN) | ||
speed_noise.set_mean(1.2) | ||
speed_noise.set_std_dev(2.3) | ||
speed_noise.set_bias_mean(4.5) | ||
speed_noise.set_bias_std_dev(6.7) | ||
speed_noise.set_precision(8.9) | ||
|
||
air.set_direction_noise(dir_noise) | ||
self.assertEqual(dir_noise, air.direction_noise()) | ||
self.assertEqual(speed_noise, air.speed_noise()) | ||
|
||
# Copy Constructor | ||
air2 = AirFlow(air) | ||
self.assertEqual(air, air2) | ||
|
||
# Copy operator | ||
air3 = air | ||
self.assertEqual(air, air3) | ||
|
||
air4 = AirFlow() | ||
self.assertNotEqual(air3, air4); | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
set (sdfs | ||
actor.sdf | ||
air_flow.sdf | ||
air_pressure.sdf | ||
air_speed.sdf | ||
altimeter.sdf | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<element name="air_flow" required="0"> | ||
<description>These elements are specific to an air flow sensor. This sensor emulates an ultrasonic airflow sensor which determines the airspeed and direction based on the doppler effect.</description> | ||
|
||
<element name="speed" required="0"> | ||
<description> | ||
Noise parameters for the speed data. | ||
</description> | ||
<include filename="noise.sdf" required="0"/> | ||
</element> | ||
|
||
<element name="direction" required="0"> | ||
<description> | ||
Noise parameters for the direction data. | ||
</description> | ||
<include filename="noise.sdf" required="0"/> | ||
</element> | ||
|
||
</element> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.