mvsim_node_main.cpp
Go to the documentation of this file.
00001 
00004 #include "mvsim/mvsim_node_core.h"
00005 
00006 /*------------------------------------------------------------------------------
00007  * main()
00008  * Main function to set up ROS node.
00009  *----------------------------------------------------------------------------*/
00010 
00011 int main(int argc, char** argv)
00012 {
00013         // Set up ROS.
00014         ros::init(argc, argv, "mvsim");
00015         ros::NodeHandle n;
00016 
00017         // Create a "Node" object.
00018         MVSimNode node(n);
00019 
00020         // Declare variables that can be modified by launch file or command line.
00021         int rate;
00022         std::string world_file;
00023 
00024         // Initialize node parameters from launch file or command line.
00025         // Use a private node handle so that multiple instances of the node can be
00026         // run simultaneously
00027         // while using different parameters.
00028         ros::NodeHandle private_node_handle_("~");
00029         private_node_handle_.param("simul_rate", rate, 100);
00030         private_node_handle_.param("world_file", world_file, std::string(""));
00031 
00032         // Init world model:
00033         if (!world_file.empty()) node.loadWorldModel(world_file);
00034 
00035         // Set up a dynamic reconfigure server.
00036         // Do this before parameter server, else some of the parameter server
00037         // values can be overwritten.
00038         dynamic_reconfigure::Server<mvsim::mvsimNodeConfig> dr_srv;
00039         dynamic_reconfigure::Server<mvsim::mvsimNodeConfig>::CallbackType cb;
00040         cb = boost::bind(&MVSimNode::configCallback, &node, _1, _2);
00041         dr_srv.setCallback(cb);
00042 
00043         // Create a publisher and name the topic.
00044         // ros::Publisher pub_message =
00045         // n.advertise<node_example::NodeExampleData>("example", 10);
00046         // Name the topic, message queue, callback function with class name, and
00047         // object containing callback function.
00048         // ros::Subscriber sub_message = n.subscribe("example", 1000,
00049         // &NodeExample::messageCallback, node_example);
00050 
00051         // Tell ROS how fast to run this node.
00052         ros::Rate r(rate);
00053 
00054         // Main loop.
00055         while (n.ok())
00056         {
00057                 node.spin();
00058                 ros::spinOnce();
00059                 r.sleep();
00060         }
00061 
00062         return 0;
00063 
00064 }  // end main()


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 22:08:35