##

CessnaPlugin.hh
Go to the documentation of this file.
/*
* Copyright (C) 2015 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 GAZEBO_PLUGINS_CESSNAPLUGIN_HH_
#define GAZEBO_PLUGINS_CESSNAPLUGIN_HH_
#include <array>
#include <mutex>
#include <string>
#include <sdf/sdf.hh>
#include <ignition/transport/Node.hh>
#include <gazebo/common/PID.hh>
#include <gazebo/common/Plugin.hh>
#include <gazebo/common/UpdateInfo.hh>
#include <gazebo/msgs/msgs.hh>
#include <gazebo/physics/PhysicsTypes.hh>
#include <gazebo/transport/TransportTypes.hh>
namespace gazebo
{
class GAZEBO_VISIBLE CessnaPlugin : public ModelPlugin
{
public: CessnaPlugin();
public: ~CessnaPlugin();
// Documentation Inherited.
public: virtual void Load(physics::ModelPtr _model, sdf::ElementPtr _sdf);
private: bool FindJoint(const std::string &_sdfParam,
sdf::ElementPtr _sdf, physics::JointPtr &_joint);
private: void Update(const common::UpdateInfo &_info);
private: void OnControl(ConstCessnaPtr &_msg);
private: void UpdatePIDs(double _dt);
private: void PublishState();
private: static const unsigned int kLeftAileron = 0;
private: static const unsigned int kLeftFlap = 1;
private: static const unsigned int kRightAileron = 2;
private: static const unsigned int kRightFlap = 3;
private: static const unsigned int kElevators = 4;
private: static const unsigned int kRudder = 5;
private: static const unsigned int kPropeller = 6;
private: event::ConnectionPtr updateConnection;
private: transport::NodePtr node;
private: transport::SubscriberPtr controlSub;
private: transport::PublisherPtr statePub;
private: physics::ModelPtr model;
private: std::array<physics::JointPtr, 7> joints;
private: int32_t propellerMaxRpm = 2500;
private: std::array<float, 7> cmds;
private: common::PID propellerPID;
private: std::array<common::PID, 6> controlSurfacesPID;
private: gazebo::common::Time lastControllerUpdateTime;
private: std::mutex mutex;
// Place ignition::transport objects at the end of this file to
// guarantee they are destructed first.
private: ignition::transport::Node nodeIgn;
private: ignition::transport::Node::Publisher statePubIgn;
};
}
#endif
UpdateInfo.hh
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::CessnaPlugin
Allow moving the control surfaces of a Cessna C-172 plane.
Definition: CessnaPlugin.hh:64
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
TransportTypes.hh
Forward declarations for transport.
msgs.hh
gazebo::transport::SubscriberPtr
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
PhysicsTypes.hh
default namespace for gazebo
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::common::PID
Generic PID controller class. Generic proportiolnal-integral-derivative controller class that keeps t...
Definition: PID.hh:36
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::physics::JointPtr
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
gazebo::ModelPlugin
A plugin with access to physics::Model.
Definition: Plugin.hh:303
Plugin.hh
PID.hh
gazebo::common::UpdateInfo
Information for use in an update event.
Definition: UpdateInfo.hh:30
GAZEBO_VISIBLE
#define GAZEBO_VISIBLE
Definition: system.hh:59