Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include <ros/ros.h>
00009 #include <std_msgs/Empty.h>
00010 #include <geometry_msgs/Twist.h>
00011
00012 geometry_msgs::Twist twist_msg;
00013 geometry_msgs::Twist twist_msg_hover;
00014 geometry_msgs::Twist twist_msg_pshover;
00015 std_msgs::Empty emp_msg;
00016
00017
00018 int main(int argc, char** argv)
00019 {
00020
00021 printf("Manual Test Node Starting");
00022 ros::init(argc, argv,"ARDrone_manual_test");
00023 ros::NodeHandle node;
00024 ros::Rate loop_rate(50);
00025
00026 ros::Publisher pub_empty_land;
00027 ros::Publisher pub_twist;
00028 ros::Publisher pub_empty_takeoff;
00029 ros::Publisher pub_empty_reset;
00030 double time;
00031
00032
00033 twist_msg_hover.linear.x=0.0;
00034 twist_msg_hover.linear.y=0.0;
00035 twist_msg_hover.linear.z=0.0;
00036 twist_msg_hover.angular.x=0.0;
00037 twist_msg_hover.angular.y=0.0;
00038 twist_msg_hover.angular.z=0.0;
00039
00040
00041 twist_msg_pshover.linear.x=0.00001;
00042 twist_msg_pshover.linear.y=0.0;
00043 twist_msg_pshover.linear.z=0.0;
00044 twist_msg_pshover.angular.x=0.0;
00045 twist_msg_pshover.angular.y=0.0;
00046 twist_msg_pshover.angular.z=0.0;
00047
00048
00049 float fly_time=9.0;
00050 float land_time=5.0;
00051 float kill_time =2.0;
00052
00053 twist_msg.linear.x=0.0;
00054 twist_msg.linear.y=-0.0001;
00055 twist_msg.linear.z=0.0;
00056 twist_msg.angular.x=0.0;
00057 twist_msg.angular.y=0.0;
00058 twist_msg.angular.z=0.0;
00059
00060
00061
00062 pub_twist = node.advertise<geometry_msgs::Twist>("/cmd_vel", 1);
00063 pub_empty_takeoff = node.advertise<std_msgs::Empty>("/ardrone/takeoff", 1);
00064 pub_empty_land = node.advertise<std_msgs::Empty>("/ardrone/land", 1);
00065 pub_empty_reset = node.advertise<std_msgs::Empty>("/ardrone/reset", 1);
00066
00067
00068 time =(double)ros::Time::now().toSec();
00069 ROS_INFO("Starting ARdrone_test loop");
00070
00071
00072 while (ros::ok()) {
00073
00074 if ( (double)ros::Time::now().toSec()< time+5.0){
00075
00076 pub_empty_takeoff.publish(emp_msg);
00077 pub_twist.publish(twist_msg_hover);
00078 ROS_INFO("Taking off");
00079 }
00080
00081 else if ( (double)ros::Time::now().toSec()> time+fly_time+land_time+kill_time){
00082
00083 ROS_INFO("Closing Node");
00084 pub_empty_reset.publish(emp_msg);
00085 break;
00086
00087 }
00088
00089 else if ( ((double)ros::Time::now().toSec()> time+fly_time+land_time)){
00090
00091 pub_twist.publish(twist_msg_hover);
00092 pub_empty_land.publish(emp_msg);
00093 ROS_INFO("Landing");
00094 }
00095
00096 else
00097 {
00098
00099 pub_twist.publish(twist_msg_hover);
00100 ROS_INFO("Flying");
00101 }
00102
00103 ros::spinOnce();
00104 loop_rate.sleep();
00105
00106 }
00107
00108 }