mock_state_publisher.cpp
Go to the documentation of this file.
00001 
00011 #include <lfd_common/state.h>
00012 #include <ros/ros.h>
00013 #include <time.h>
00014 
00015 using namespace std;
00016 
00024 int main(int argc, char **argv)
00025 {
00026   // initialize ROS and the node
00027   ros::init(argc, argv, "mock_state_publisher");
00028   // a handle for this ROS node
00029   ros::NodeHandle node;
00030 
00031   // published topics
00032   ros::Publisher update_state = node.advertise<lfd_common::state> ("state_listener", 1);
00033 
00034   // used to create random states
00035   srand(time(NULL));
00036 
00037   ROS_INFO("Mock State Publisher Initialized");
00038 
00039   // publish states continuously
00040   while (ros::ok())
00041   {
00042     // 3 dimensional state vector all in range [0,25)
00043     lfd_common::state s;
00044     for (int i = 0; i < 3; i++)
00045       s .state_vector.push_back(rand() % 25);
00046     update_state.publish(s);
00047     ros::spinOnce();
00048   }
00049 
00050   return EXIT_SUCCESS;
00051 }


cba
Author(s): Russell Toris
autogenerated on Thu Jan 2 2014 11:23:56