joint_position_controller_test_node.cpp
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Modified BSD License)
00003  *
00004  *  Copyright (c) 2011, PAL Robotics, S.L.
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
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of PAL Robotics, S.L. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
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   // publisher for joint states commands
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 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


joint_position_controller
Author(s): Marcus Liebhardt , Adolfo Rodríguez Tsouroukdissian , Hilario Tome
autogenerated on Thu Jun 27 2013 16:12:18