30 double x = msg->magnetic_field.x;
31 double y = msg->magnetic_field.y;
32 double z = msg->magnetic_field.z;
35 double yaw =
atan2(y, x);
36 double pitch =
atan2(-z, sqrt(x * x + y * y));
42 geometry_msgs::PoseStamped pose_msg;
43 pose_msg.header = msg->header;
45 pose_msg.pose.position.x = 0;
46 pose_msg.pose.position.y = 0;
47 pose_msg.pose.position.z = 0;
56 geometry_msgs::Point p;
63 visualization_msgs::Marker pts_msg;
65 pts_msg.header.stamp = msg->header.stamp;
66 pts_msg.type = visualization_msgs::Marker::POINTS;
67 pts_msg.action = visualization_msgs::Marker::ADD;
70 pts_msg.scale.x = 0.1;
71 pts_msg.scale.y = pts_msg.scale.x;
72 pts_msg.scale.z = pts_msg.scale.x;
73 pts_msg.color.a = 1.0;
74 pts_msg.color.r = 0.0;
75 pts_msg.color.g = 1.0;
76 pts_msg.color.b = 0.0;
91 geometry_msgs::PoseStamped pose;
92 pose.header = msg->header;
94 pose.pose.orientation = msg->attitude;
101 int main(
int argc,
char **argv)
static tf::Quaternion createQuaternionFromRPY(double roll, double pitch, double yaw)
void magCallback(const sensor_msgs::MagneticFieldConstPtr &msg)
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
float atan2(float y, float x)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TFSIMD_FORCE_INLINE const tfScalar & y() const
ROSCPP_DECL void spin(Spinner &spinner)
static void quaternionTFToMsg(const Quaternion &bt, geometry_msgs::Quaternion &msg)
This file defines a simple PID controller to be used by other classes to implement a PID control loop...
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
TFSIMD_FORCE_INLINE const tfScalar & z() const
int main(int argc, char **argv)
void attCallback(const rosflight_msgs::AttitudeConstPtr &msg)
std::vector< geometry_msgs::Point > pts_list_