Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <ros/ros.h>
00014 #include <sensor_msgs/JointState.h>
00015 #include <stdlib.h>
00016
00017 int main(int argc, char **argv) {
00018 if (argc != 7) {
00019 std::cerr << "Usage: " << argv[0] << "<topic> <qdot1> <qdot2> <qdot3> <qdot4> <qdot5>" << std::endl;
00020 std::cerr << "Units are radians/simulated_time. Time scale to be implemented." << std::endl;
00021 exit(0);
00022 }
00023 std::string topic(argv[1]);
00024
00025 ros::init(argc, argv, "setJointVelocity");
00026 ros::NodeHandle nh;
00027 ros::Publisher velocity_pub;
00028 velocity_pub=nh.advertise<sensor_msgs::JointState>(topic,1);
00029 ros::Rate rate(30);
00030
00031 double qdot[5];
00032 for (int i=0; i<5; i++) qdot[i]=atof(argv[i+2]);
00033
00034 while (ros::ok()) {
00035
00036 sensor_msgs::JointState js;
00037 js.name.push_back(std::string("Slew"));
00038 js.velocity.push_back(qdot[0]);
00039 js.name.push_back(std::string("Shoulder"));
00040 js.velocity.push_back(qdot[1]);
00041 js.name.push_back(std::string("Elbow"));
00042 js.velocity.push_back(qdot[2]);
00043 js.name.push_back(std::string("JawRotate"));
00044 js.velocity.push_back(qdot[3]);
00045 js.name.push_back(std::string("JawOpening"));
00046 js.velocity.push_back(qdot[4]);
00047
00048 velocity_pub.publish(js);
00049
00050 ros::spinOnce();
00051 rate.sleep();
00052 }
00053
00054 return 0;
00055 }