Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <ros/ros.h>
00031 #include <geometry_msgs/Twist.h>
00032
00033 int main(int argc, char **argv)
00034 {
00035 ros::init(argc, argv, "test_trajectory");
00036 ros::NodeHandle nh;
00037 ros::Publisher publisher = nh.advertise<geometry_msgs::Twist>("cmd_vel", 1);
00038 geometry_msgs::Twist twist;
00039
00040 publisher.publish(twist);
00041 ros::Duration(5.0).sleep();
00042
00043 double speed = 3.0;
00044 double interval = 3.0;
00045
00046 twist.linear.z = 2.0;
00047 publisher.publish(twist);
00048 ros::Duration(interval).sleep();
00049
00050 twist.linear.z = 0.0;
00051 publisher.publish(twist);
00052 ros::Duration(interval).sleep();
00053
00054 twist.linear.x = speed;
00055 publisher.publish(twist);
00056 ros::Duration(interval).sleep();
00057
00058 twist.linear.x = 0.0;
00059 publisher.publish(twist);
00060 ros::Duration(interval).sleep();
00061
00062 twist.linear.y = speed;
00063 publisher.publish(twist);
00064 ros::Duration(interval).sleep();
00065
00066 twist.linear.y = 0.0;
00067 publisher.publish(twist);
00068 ros::Duration(interval).sleep();
00069
00070 twist.linear.x = -speed;
00071 publisher.publish(twist);
00072 ros::Duration(interval).sleep();
00073
00074 twist.linear.x = 0.0;
00075 publisher.publish(twist);
00076 ros::Duration(interval).sleep();
00077
00078 twist.linear.y = -speed;
00079 publisher.publish(twist);
00080 ros::Duration(interval).sleep();
00081
00082 twist.linear.y = 0.0;
00083 publisher.publish(twist);
00084 ros::Duration(interval).sleep();
00085
00086 twist.linear.z = -1.0;
00087 publisher.publish(twist);
00088 ros::Duration(interval).sleep();
00089
00090 twist.linear.z = 0.0;
00091 publisher.publish(twist);
00092 ros::Duration(interval).sleep();
00093
00094 return 0;
00095 }