32 double x = msg->magnetic_field.x;
33 double y = msg->magnetic_field.y;
34 double z = msg->magnetic_field.z;
37 double yaw = atan2(y, x);
38 double pitch = atan2(-z, sqrt(x*x + y*y));
41 tf::Quaternion q_v = tf::createQuaternionFromRPY(0, pitch, yaw);
44 geometry_msgs::PoseStamped pose_msg;
45 pose_msg.header = msg->header;
47 pose_msg.pose.position.x = 0;
48 pose_msg.pose.position.y = 0;
49 pose_msg.pose.position.z = 0;
50 tf::quaternionTFToMsg(q_v, pose_msg.pose.orientation);
59 geometry_msgs::Point p;
66 visualization_msgs::Marker pts_msg;
68 pts_msg.header.stamp = msg->header.stamp;
69 pts_msg.type = visualization_msgs::Marker::POINTS;
70 pts_msg.action = visualization_msgs::Marker::ADD;
73 pts_msg.scale.x = 0.1;
74 pts_msg.scale.y = pts_msg.scale.x;
75 pts_msg.scale.z = pts_msg.scale.x;
76 pts_msg.color.a = 1.0;
77 pts_msg.color.r = 0.0;
78 pts_msg.color.g = 1.0;
79 pts_msg.color.b = 0.0;
81 for (uint32_t i = 0; i <
pts_list_.size(); ++i)
95 geometry_msgs::PoseStamped pose;
96 pose.header = msg->header;
98 pose.pose.orientation = msg->attitude;
105 int main(
int argc,
char** argv)
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())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
This file defines a simple PID controller to be used by other classes to implement a PID control loop...
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int main(int argc, char **argv)
void attCallback(const rosflight_msgs::AttitudeConstPtr &msg)
std::vector< geometry_msgs::Point > pts_list_