$search
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2011, Yaskawa America, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions are met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * * Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * * Neither the name of the Yaskawa America, Inc., nor the names 00016 * of its contributors may be used to endorse or promote products derived 00017 * from this software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00023 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00029 * POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 00032 #include "ros/ros.h" 00033 #include "std_msgs/String.h" 00034 #include "trajectory_msgs/JointTrajectory.h" 00035 00036 #include <sstream> 00037 00038 using std::cout; 00039 using std::cin; 00040 using std::endl; 00041 00042 int main(int argc, char **argv) 00043 // Publishes trajectory to joint_cmd topic to be received by interface node 00044 { 00045 const int NUMPOINTS = 100; 00046 int traj_points[NUMPOINTS][8] = {{0, 0, -90000, 0, 0, 0, 0, 0}, 00047 {200, 200, -90200, 200, 200, 200, 200, 0}, 00048 {400, 400, -90400, 400, 400, 400, 400, 0}, 00049 {600, 600, -90600, 600, 600, 600, 600, 0}, 00050 {800, 800, -90800, 800, 800, 800, 800, 0}, 00051 {1000, 1000, -91000, 1000, 1000, 1000, 1000, 0}, 00052 {1200, 1200, -91200, 1200, 1200, 1200, 1200, 0}, 00053 {1400, 1400, -91400, 1400, 1400, 1400, 1400, 0}, 00054 {1600, 1600, -91600, 1600, 1600, 1600, 1600, 0}, 00055 {1800, 1800, -91800, 1800, 1800, 1800, 1800, 0}, 00056 {2000, 2000, -92000, 2000, 2000, 2000, 2000, 0}, 00057 {2200, 2200, -92200, 2200, 2200, 2200, 2200, 0}, 00058 {2400, 2400, -92400, 2400, 2400, 2400, 2400, 0}, 00059 {2600, 2600, -92600, 2600, 2600, 2600, 2600, 0}, 00060 {2800, 2800, -92800, 2800, 2800, 2800, 2800, 0}, 00061 {3000, 3000, -93000, 3000, 3000, 3000, 3000, 0}, 00062 {3200, 3200, -93200, 3200, 3200, 3200, 3200, 0}, 00063 {3400, 3400, -93400, 3400, 3400, 3400, 3400, 0}, 00064 {3600, 3600, -93600, 3600, 3600, 3600, 3600, 0}, 00065 {3800, 3800, -93800, 3800, 3800, 3800, 3800, 0}, 00066 {4000, 4000, -94000, 4000, 4000, 4000, 4000, 0}, 00067 {4200, 4200, -94200, 4200, 4200, 4200, 4200, 0}, 00068 {4400, 4400, -94400, 4400, 4400, 4400, 4400, 0}, 00069 {4600, 4600, -94600, 4600, 4600, 4600, 4600, 0}, 00070 {4800, 4800, -94800, 4800, 4800, 4800, 4800, 0}, 00071 {5000, 5000, -95000, 5000, 5000, 5000, 5000, 0}, 00072 {5200, 5200, -95200, 5200, 5200, 5200, 5200, 0}, 00073 {5400, 5400, -95400, 5400, 5400, 5400, 5400, 0}, 00074 {5600, 5600, -95600, 5600, 5600, 5600, 5600, 0}, 00075 {5800, 5800, -95800, 5800, 5800, 5800, 5800, 0}, 00076 {6000, 6000, -96000, 6000, 6000, 6000, 6000, 0}, 00077 {6200, 6200, -96200, 6200, 6200, 6200, 6200, 0}, 00078 {6400, 6400, -96400, 6400, 6400, 6400, 6400, 0}, 00079 {6600, 6600, -96600, 6600, 6600, 6600, 6600, 0}, 00080 {6800, 6800, -96800, 6800, 6800, 6800, 6800, 0}, 00081 {7000, 7000, -97000, 7000, 7000, 7000, 7000, 0}, 00082 {7200, 7200, -97200, 7200, 7200, 7200, 7200, 0}, 00083 {7400, 7400, -97400, 7400, 7400, 7400, 7400, 0}, 00084 {7600, 7600, -97600, 7600, 7600, 7600, 7600, 0}, 00085 {7800, 7800, -97800, 7800, 7800, 7800, 7800, 0}, 00086 {8000, 8000, -98000, 8000, 8000, 8000, 8000, 0}, 00087 {8200, 8200, -98200, 8200, 8200, 8200, 8200, 0}, 00088 {8400, 8400, -98400, 8400, 8400, 8400, 8400, 0}, 00089 {8600, 8600, -98600, 8600, 8600, 8600, 8600, 0}, 00090 {8800, 8800, -98800, 8800, 8800, 8800, 8800, 0}, 00091 {9000, 9000, -99000, 9000, 9000, 9000, 9000, 0}, 00092 {9200, 9200, -99200, 9200, 9200, 9200, 9200, 0}, 00093 {9400, 9400, -99400, 9400, 9400, 9400, 9400, 0}, 00094 {9600, 9600, -99600, 9600, 9600, 9600, 9600, 0}, 00095 {9800, 9800, -99800, 9800, 9800, 9800, 9800, 0}, 00096 {10000, 10000, -100000, 10000, 10000, 10000, 10000, 0}, 00097 {10200, 10200, -100200, 10200, 10200, 10200, 10200, 0}, 00098 {10400, 10400, -100400, 10400, 10400, 10400, 10400, 0}, 00099 {10600, 10600, -100600, 10600, 10600, 10600, 10600, 0}, 00100 {10800, 10800, -100800, 10800, 10800, 10800, 10800, 0}, 00101 {11000, 11000, -101000, 11000, 11000, 11000, 11000, 0}, 00102 {11200, 11200, -101200, 11200, 11200, 11200, 11200, 0}, 00103 {11400, 11400, -101400, 11400, 11400, 11400, 11400, 0}, 00104 {11600, 11600, -101600, 11600, 11600, 11600, 11600, 0}, 00105 {11800, 11800, -101800, 11800, 11800, 11800, 11800, 0}, 00106 {12000, 12000, -102000, 12000, 12000, 12000, 12000, 0}, 00107 {12200, 12200, -102200, 12200, 12200, 12200, 12200, 0}, 00108 {12400, 12400, -102400, 12400, 12400, 12400, 12400, 0}, 00109 {12600, 12600, -102600, 12600, 12600, 12600, 12600, 0}, 00110 {12800, 12800, -102800, 12800, 12800, 12800, 12800, 0}, 00111 {13000, 13000, -103000, 13000, 13000, 13000, 13000, 0}, 00112 {13200, 13200, -103200, 13200, 13200, 13200, 13200, 0}, 00113 {13400, 13400, -103400, 13400, 13400, 13400, 13400, 0}, 00114 {13600, 13600, -103600, 13600, 13600, 13600, 13600, 0}, 00115 {13800, 13800, -103800, 13800, 13800, 13800, 13800, 0}, 00116 {14000, 14000, -104000, 14000, 14000, 14000, 14000, 0}, 00117 {14200, 14200, -104200, 14200, 14200, 14200, 14200, 0}, 00118 {14400, 14400, -104400, 14400, 14400, 14400, 14400, 0}, 00119 {14600, 14600, -104600, 14600, 14600, 14600, 14600, 0}, 00120 {14800, 14800, -104800, 14800, 14800, 14800, 14800, 0}, 00121 {15000, 15000, -105000, 15000, 15000, 15000, 15000, 0}, 00122 {15200, 15200, -105200, 15200, 15200, 15200, 15200, 0}, 00123 {15400, 15400, -105400, 15400, 15400, 15400, 15400, 0}, 00124 {15600, 15600, -105600, 15600, 15600, 15600, 15600, 0}, 00125 {15800, 15800, -105800, 15800, 15800, 15800, 15800, 0}, 00126 {16000, 16000, -106000, 16000, 16000, 16000, 16000, 0}, 00127 {16200, 16200, -106200, 16200, 16200, 16200, 16200, 0}, 00128 {16400, 16400, -106400, 16400, 16400, 16400, 16400, 0}, 00129 {16600, 16600, -106600, 16600, 16600, 16600, 16600, 0}, 00130 {16800, 16800, -106800, 16800, 16800, 16800, 16800, 0}, 00131 {17000, 17000, -107000, 17000, 17000, 17000, 17000, 0}, 00132 {17200, 17200, -107200, 17200, 17200, 17200, 17200, 0}, 00133 {17400, 17400, -107400, 17400, 17400, 17400, 17400, 0}, 00134 {17600, 17600, -107600, 17600, 17600, 17600, 17600, 0}, 00135 {17800, 17800, -107800, 17800, 17800, 17800, 17800, 0}, 00136 {18000, 18000, -108000, 18000, 18000, 18000, 18000, 0}, 00137 {18200, 18200, -108200, 18200, 18200, 18200, 18200, 0}, 00138 {18400, 18400, -108400, 18400, 18400, 18400, 18400, 0}, 00139 {18600, 18600, -108600, 18600, 18600, 18600, 18600, 0}, 00140 {18800, 18800, -108800, 18800, 18800, 18800, 18800, 0}, 00141 {19000, 19000, -109000, 19000, 19000, 19000, 19000, 0}, 00142 {19200, 19200, -109200, 19200, 19200, 19200, 19200, 0}, 00143 {19400, 19400, -109400, 19400, 19400, 19400, 19400, 0}, 00144 {19600, 19600, -109600, 19600, 19600, 19600, 19600, 0}, 00145 {19800, 19800, -109800, 19800, 19800, 19800, 19800, 0}}; 00146 00147 ros::init(argc, argv, "traj_pub"); 00148 ros::NodeHandle n; 00149 ros::Publisher joint_cmd_pub = n.advertise<trajectory_msgs::JointTrajectory>("joint_cmd", 1000); 00150 ros::Rate loop_rate(.5); // Publish trajectory at 1 Hz 00151 00152 trajectory_msgs::JointTrajectory traj; 00153 00154 traj.joint_names.push_back("S"); 00155 traj.joint_names.push_back("L"); 00156 traj.joint_names.push_back("U"); 00157 traj.joint_names.push_back("R"); 00158 traj.joint_names.push_back("B"); 00159 traj.joint_names.push_back("T"); 00160 traj.joint_names.push_back("E"); 00161 traj.joint_names.push_back("8th axis"); 00162 00163 traj.header.stamp = ros::Time::now() + ros::Duration(1.0); 00164 00165 traj.points.resize(NUMPOINTS); 00166 00167 for (int i = 0; i < NUMPOINTS; i++) 00168 { 00169 traj.points[i].positions.resize(8); 00170 for (short j = 0; j < 8; j++) 00171 { 00172 traj.points[i].positions[j] = traj_points[i][j]; 00173 } 00174 traj.points[i].velocities.resize(1); 00175 traj.points[i].velocities[0] = 2000; 00176 traj.points[i].time_from_start = ros::Duration(i); 00177 } 00178 00179 /* 00180 traj.points.resize(2); 00181 int i = 0; 00182 00183 traj.header.stamp = ros::Time::now() + ros::Duration(1.0); 00184 00185 traj.points[i].positions.resize(8); 00186 traj.points[i].positions[0] = 0; 00187 traj.points[i].positions[1] = 0; 00188 traj.points[i].positions[2] = -90000; 00189 traj.points[i].positions[3] = 0; 00190 traj.points[i].positions[4] = 0; 00191 traj.points[i].positions[5] = 0; 00192 traj.points[i].positions[6] = 0; 00193 traj.points[i].positions[7] = 0; 00194 00195 traj.points[i].velocities.resize(1); 00196 traj.points[i].velocities[0] = 0; 00197 00198 traj.points[i].time_from_start = ros::Duration(1.0); 00199 00200 i++; 00201 00202 traj.points[i].positions.resize(8); 00203 traj.points[i].positions[0] = 200; 00204 traj.points[i].positions[1] = 200; 00205 traj.points[i].positions[2] = -90200; 00206 traj.points[i].positions[3] = 200; 00207 traj.points[i].positions[4] = 200; 00208 traj.points[i].positions[5] = 200; 00209 traj.points[i].positions[6] = 200; 00210 traj.points[i].positions[7] = 200; 00211 00212 traj.points[i].velocities.resize(1); 00213 traj.points[i].velocities[0] = 0; 00214 00215 traj.points[i].time_from_start = ros::Duration(2.0); 00216 */ 00217 00218 while (ros::ok()) 00219 { 00220 joint_cmd_pub.publish(traj); 00221 cout << "Trajectory sent" << endl; 00222 loop_rate.sleep(); 00223 } 00224 00225 return 0; 00226 }