fp.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <string.h>
00003 #include <stdio.h>
00004 #include <math.h>
00005 #include <stdlib.h>
00006 #include <Ivy/ivy.h>
00007 #include <Ivy/ivyloop.h>
00008 #include "quad_can_driver/Thrust.h"
00009 #include <Ivy/timer.h>
00010 
00011 quad_can_driver::Thrust thrust_msg;
00012 ros::Publisher fp_message;
00013 
00014 /* 
00015  * Broadcast Thrust information of quadrotor
00016  */
00017  
00018 void FPCallback (IvyClientPtr app, void* data , int argc, char **argv){
00019     double thrust;
00020         
00021     sscanf(argv[0],"%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %lf %*d",&thrust);
00022 
00023     thrust_msg.header.stamp = ros::Time::now();
00024     thrust_msg.thrust=thrust;
00025     ROS_INFO("RCThrust: %f",thrust);
00026 
00027     fp_message.publish(thrust_msg);
00028 }
00029 
00030 void ROSCallback (TimerId id, void *user_data, unsigned long delta){
00031         if (!ros::ok()){
00032                 IvyStop();
00033                 exit(0);
00034         }
00035 }
00036 
00037 int main(int argc, char **argv){
00038         
00039         // Initializing ROS
00040     ros::init(argc, argv, "quad_fp");
00041         ros::NodeHandle nh("~");
00042         
00043     fp_message = nh.advertise<quad_can_driver::Thrust>("RCThrust", 1000);
00044 
00045         // Initializing Ivy
00046     IvyInit ("quad_fp", "'Quad FP' is READY!", 0, 0, 0, 0);
00047         IvyStart("127.255.255.255");
00048         TimerRepeatAfter (TIMER_LOOP, 500, ROSCallback, 0);
00049         
00050         // Binding Messages
00051     IvyBindMsg(FPCallback, 0, "ROTORCRAFT_FP(.*)");
00052         
00053         IvyMainLoop();
00054         
00055         return 0;
00056 }


quad_fp
Author(s): Henrique
autogenerated on Mon Jan 6 2014 11:48:18