32 #pragma GCC diagnostic ignored "-Wwrite-strings" 38 #include <eigen3/Eigen/Core> 61 ROS_FATAL(
"A ROS node for Gazebo has not been initialized, unable to load plugin");
64 ROS_INFO(
"Loaded the ROSflight SIL plugin");
74 if (_sdf->HasElement(
"namespace"))
75 namespace_ = _sdf->GetElement(
"namespace")->Get<std::string>();
77 gzerr <<
"[ROSflight_SIL] Please specify a namespace.\n";
80 gzmsg <<
"loading parameters from " <<
namespace_ <<
" ns\n";
82 if (_sdf->HasElement(
"linkName"))
83 link_name_ = _sdf->GetElement(
"linkName")->Get<std::string>();
85 gzerr <<
"[ROSflight_SIL] Please specify a linkName of the forces and moments plugin.\n";
88 gzthrow(
"[ROSflight_SIL] Couldn't find specified link \"" <<
link_name_ <<
"\".");
91 if (_sdf->HasElement(
"mavType"))
93 mav_type_ = _sdf->GetElement(
"mavType")->Get<std::string>();
98 gzerr <<
"[rosflight_sim] Please specify a value for parameter \"mavType\".\n";
106 gzthrow(
"unknown or unsupported mav type\n");
128 Eigen::Matrix3d NWU_to_NED;
129 NWU_to_NED << 1, 0, 0, 0, -1, 0, 0, 0, -1;
141 state.
t = _info.simTime.Double();
148 link_->AddRelativeForce(force);
149 link_->AddRelativeTorque(torque);
157 link_->ResetPhysicsStates();
164 Eigen::Vector3d wind;
165 wind << msg.x, msg.y, msg.z;
176 nav_msgs::Odometry truth;
197 truth.pose.pose.orientation.y *= -1.0;
198 truth.pose.pose.orientation.z *= -1.0;
199 truth.pose.pose.position.y *= -1.0;
200 truth.pose.pose.position.z *= -1.0;
201 truth.twist.twist.linear.y *= -1.0;
202 truth.twist.twist.linear.z *= -1.0;
203 truth.twist.twist.angular.y *= -1.0;
204 truth.twist.twist.angular.z *= -1.0;
225 return eig_quat.toRotationMatrix();
GZ_REGISTER_MODEL_PLUGIN(GazeboRosElevator)
ros::Publisher truth_NWU_pub_
#define GZ_COMPAT_GET_Z(VECTOR)
void publish(const boost::shared_ptr< M > &message) const
gazebo::math::Vector3 GazeboVector
virtual void set_wind(Eigen::Vector3d wind)=0
ROSCPP_DECL bool isInitialized()
const int * get_outputs() const
#define GZ_COMPAT_GET_X(VECTOR)
Eigen::Matrix3d rotation_to_eigen_from_gazebo(GazeboQuaternion vec)
Eigen::Vector3d vec3_to_eigen_from_gazebo(GazeboVector vec)
#define GZ_COMPAT_GET_RELATIVE_ANGULAR_VEL(LINK_PTR)
void gazebo_setup(gazebo::physics::LinkPtr link, gazebo::physics::WorldPtr world, gazebo::physics::ModelPtr model, ros::NodeHandle *nh, std::string mav_type)
Eigen::Matrix< double, 6, 1 > forces_
#define GZ_COMPAT_GET_WORLD_COG_POSE(LINK_PTR)
MAVForcesAndMoments * mav_dynamics_
GazeboVector vec3_to_gazebo_from_eigen(Eigen::Vector3d vec)
gazebo::math::Pose GazeboPose
#define GZ_COMPAT_GET_W(VECTOR)
#define GZ_COMPAT_GET_ROT(POSE)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
rosflight_firmware::ROSflight firmware_
gazebo::physics::WorldPtr world_
void Load(gazebo::physics::ModelPtr _model, sdf::ElementPtr _sdf) override
virtual Eigen::Matrix< double, 6, 1 > updateForcesAndTorques(Current_State x, const int act_cmds[])=0
void OnUpdate(const gazebo::common::UpdateInfo &_info)
gazebo::event::ConnectionPtr updateConnection_
#define GZ_COMPAT_DISCONNECT_WORLD_UPDATE_BEGIN(CONNECTION)
#define GZ_COMPAT_GET_POS(POSE)
ros::Publisher truth_NED_pub_
gazebo::physics::LinkPtr link_
void windCallback(const geometry_msgs::Vector3 &msg)
#define GZ_COMPAT_GET_SIM_TIME(WORLD_PTR)
#define GZ_COMPAT_GET_Y(VECTOR)
#define GZ_COMPAT_GET_RELATIVE_LINEAR_VEL(LINK_PTR)
gazebo::physics::ModelPtr model_
gazebo::math::Quaternion GazeboQuaternion