-
Notifications
You must be signed in to change notification settings - Fork 827
Windsensor Model #909
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
9
commits into
PX4:main
Choose a base branch
from
flycloudline:pr-windsensor-model
base: main
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
Windsensor Model #909
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5f318e3
FT Technologies Wind Sensor Plugin Added
5e27a9e
Windsensor bitmask correction in HIL_SENSOR
565c9dc
Noise added to wind sensor model
d1fa5a4
Added .vscode to gitignore
a692768
Uncommented section when sending it over mavlink
47a91a1
Send windsensor data over mavlink
94b8133
Windsensor naming changed to airflow sensor
1f59a4e
Fix missed cherry-pick conflict
93d3362
Removed Old windsensor function
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
Build/ | ||
build/ | ||
.vscode/ | ||
scripts/schemas | ||
.DS_Store | ||
*~ | ||
|
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,119 @@ | ||
/**************************************************************************** | ||
* | ||
* Copyright (c) 2020 PX4 Development Team. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* 3. Neither the name PX4 nor the names of its contributors may be | ||
* used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS | ||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************/ | ||
/** | ||
* @brief WindSensor Plugin | ||
* | ||
* This plugin publishes WindSensor sensor data | ||
* | ||
* @author Henry Kotze <henry@flycloudline.com> | ||
*/ | ||
|
||
#ifndef _GAZEBO_WINDSENSOR_PLUGIN_HH_ | ||
#define _GAZEBO_WINDSENSOR_PLUGIN_HH_ | ||
|
||
#include <math.h> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <queue> | ||
#include <random> | ||
|
||
#include <sdf/sdf.hh> | ||
#include <common.h> | ||
#include <random> | ||
|
||
#include <gazebo/common/Plugin.hh> | ||
#include <gazebo/gazebo.hh> | ||
#include <gazebo/util/system.hh> | ||
#include <gazebo/transport/transport.hh> | ||
#include <gazebo/msgs/msgs.hh> | ||
#include <gazebo/physics/physics.hh> | ||
#include <ignition/math.hh> | ||
|
||
#include <gazebo/sensors/SensorTypes.hh> | ||
#include <gazebo/sensors/Sensor.hh> | ||
|
||
#include <WindSensor.pb.h> | ||
#include <Wind.pb.h> | ||
|
||
namespace gazebo | ||
{ | ||
|
||
typedef const boost::shared_ptr<const physics_msgs::msgs::Wind> WindPtr; | ||
|
||
class GAZEBO_VISIBLE WindSensorPlugin : public SensorPlugin | ||
{ | ||
public: | ||
WindSensorPlugin(); | ||
virtual ~WindSensorPlugin(); | ||
|
||
protected: | ||
virtual void Load(sensors::SensorPtr _parent, sdf::ElementPtr _sdf); | ||
virtual void OnUpdate(const common::UpdateInfo&); | ||
virtual void OnSensorUpdate(); | ||
|
||
private: | ||
void WindVelocityCallback(WindPtr& msg); | ||
|
||
physics::ModelPtr model_; | ||
physics::WorldPtr world_; | ||
physics::LinkPtr link_; | ||
sensors::SensorPtr parentSensor_; | ||
|
||
transport::NodePtr node_handle_; | ||
transport::SubscriberPtr wind_sub_; | ||
transport::PublisherPtr windsensor_pub_; | ||
event::ConnectionPtr updateSensorConnection_; | ||
event::ConnectionPtr updateConnection_; | ||
|
||
// linear velocity | ||
ignition::math::Vector3d vel_a_; | ||
// angular velocity | ||
ignition::math::Vector3d ang_a_; | ||
|
||
common::Time last_time_; | ||
std::string namespace_; | ||
std::string link_name_; | ||
std::string model_name_; | ||
std::string windsensor_topic_; | ||
|
||
std::normal_distribution<float> gauss_dir_; | ||
std::normal_distribution<float> gauss_speed_; | ||
std::default_random_engine generator_; | ||
|
||
ignition::math::Vector3d wind_; | ||
float wind_direction_; | ||
float wind_speed_; | ||
|
||
}; // class GAZEBO_VISIBLE WindSensorPlugin | ||
} // namespace gazebo | ||
#endif // _GAZEBO_WINDSENSOR_PLUGIN_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
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,15 @@ | ||
<?xml version="1.0"?> | ||
<model> | ||
<name>windsensor</name> | ||
<version>1.0</version> | ||
<sdf version='1.6'>windsensor.sdf</sdf> | ||
|
||
<author> | ||
<name>Henry Kotze</name> | ||
<email>henry@flycloudline.com</email> | ||
</author> | ||
|
||
<description> | ||
FT Technologies ultra sonic wind sensor model | ||
</description> | ||
</model> |
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,30 @@ | ||
<?xml version="1.0" ?> | ||
<sdf version="1.6"> | ||
<model name="windsensor"> | ||
<link name="link"> | ||
<pose>0 0 0 0 0 0</pose> | ||
<visual name="visual"> | ||
<geometry> | ||
<cylinder> | ||
<radius>0.01</radius> | ||
<length>0.1</length> | ||
</cylinder> | ||
</geometry> | ||
<material> | ||
<script> | ||
<name>Gazebo/Black</name> | ||
</script> | ||
</material> | ||
</visual> | ||
<sensor name='windsensor' type='gps'> | ||
<pose>0 0 0 0 0 0</pose> | ||
<update_rate>5.0</update_rate> | ||
<always_on>true</always_on> | ||
<visualize>false</visualize> | ||
<plugin name='gazebo_windsensor_plugin' filename='libgazebo_windsensor_plugin.so'> | ||
<robotNamespace/> | ||
</plugin> | ||
</sensor> | ||
</link> | ||
</model> | ||
</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,9 @@ | ||
syntax = "proto2"; | ||
package sensor_msgs.msgs; | ||
|
||
message WindSensor | ||
{ | ||
required int64 time_usec = 1; | ||
required double wind_speed = 2; | ||
required double wind_direction = 3; | ||
} |
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.