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
00031
00032
00033
00034
00038 #include <ros/ros.h>
00039 #include <sensor_msgs/JointState.h>
00040
00041 int main(int argc, char** argv)
00042 {
00043 ros::init(argc, argv, "joint_position_controller_test_node");
00044 ros::NodeHandle nh;
00045
00046
00047 ros::Publisher pub_joint_states_cmd = nh.advertise<sensor_msgs::JointState>("/joint_states_cmd", 1);
00048 sensor_msgs::JointState joint_states_cmd;
00049
00050 unsigned int switcher = 0;
00051 ros::Rate loop_rate(0.5);
00052
00053 while(nh.ok())
00054 {
00055 joint_states_cmd.position.clear();
00056
00057 switch (switcher)
00058 {
00059 case 0:
00060 for(unsigned int i = 0; i < 24; ++i)
00061 {
00062 joint_states_cmd.position.push_back(0.0);
00063 }
00064 switcher = 1;
00065 break;
00066
00067 case 1:
00068 for(unsigned int i = 0; i < 24; ++i)
00069 {
00070 joint_states_cmd.position.push_back(0.2);
00071 }
00072 switcher = 2;
00073 break;
00074
00075 case 2:
00076 for(unsigned int i = 0; i < 24; ++i)
00077 {
00078 joint_states_cmd.position.push_back(0.5);
00079 }
00080 switcher = 3;
00081 break;
00082
00083 case 3:
00084 for(unsigned int i = 0; i < 24; ++i)
00085 {
00086 joint_states_cmd.position.push_back(0.2);
00087 }
00088 switcher = 4;
00089 break;
00090
00091 case 4:
00092 for(unsigned int i = 0; i < 24; ++i)
00093 {
00094 joint_states_cmd.position.push_back(0.1);
00095 }
00096 switcher = 0;
00097 break;
00098
00099 default:
00100 for(unsigned int i = 0; i < 24; ++i)
00101 {
00102 joint_states_cmd.position.push_back(0.0);
00103 }
00104 switcher = 0;
00105 }
00106 joint_states_cmd.header.stamp = ros::Time::now();
00107 pub_joint_states_cmd.publish(joint_states_cmd);
00108
00109 loop_rate.sleep();
00110 }
00111 return 0;
00112 }