telemetry_settings.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 <Ivy/timer.h>
00009 
00010 #define MILLISEC 1000.0
00011 
00012 /* 
00013  * Set telemetry to 'Scaled' mode.
00014  * Turn off Care-Free.
00015  * Set Modes 1/2 to MANUAL
00016  * Sends a command every $PERIOD seconds.
00017  * Parameters:  AC_ID;
00018  *                              PERIOD;                                 
00019  */
00020 
00021 int ac_id, period;
00022 
00023 void SettingCallback (TimerId id, void *user_data, unsigned long delta)
00024 {
00025         IvySendMsg ("ground_dl SETTING 0 %d 0",ac_id); // Telemetry -> Default
00026         IvySendMsg ("ground_dl SETTING 1 %d 3",ac_id); // Mode2 -> AP_MODE_ATTITUDE_DIRECT
00027         IvySendMsg ("ground_dl SETTING 2 %d 3",ac_id); // Mode1 -> AP_MODE_ATTITUDE_DIRECT
00028         IvySendMsg ("ground_dl SETTING 65 %d 0",ac_id); // Care_Free -> OFF
00029         
00030         if (!ros::ok()) {
00031                 IvyStop();
00032                 exit(0);
00033         }
00034 }
00035 
00036 int main(int argc, char **argv)
00037 {
00038         // Initializing ROS
00039         ros::init(argc, argv, "telemetry_settings");
00040         ros::NodeHandle nh("~");
00041         
00042         // Getting ROS Parameters
00043         if (!nh.getParam("ac_id", ac_id))
00044         {
00045                 ROS_FATAL("Failed to get param 'AC_ID'");
00046                 exit(0);
00047         }
00048         nh.param("period", period, 1);
00049         
00050         // Initializing Ivy
00051         IvyInit ("telemetry_settings", "'Telemetry Settings' is READY!", 0, 0, 0, 0);
00052         TimerRepeatAfter (TIMER_LOOP, period*MILLISEC, SettingCallback, 0);
00053         IvyStart("127.255.255.255");
00054         IvyMainLoop();
00055         return 0;
00056 }


telemetry_settings
Author(s): Henrique
autogenerated on Mon Jan 6 2014 11:48:12