| 56 | |
| 57 | public: |
| 58 | LedController(const std::string& robotNamespace) : robotNamespace(robotNamespace) |
| 59 | { |
| 60 | // We need "libgazebo_ros_api.so" to be loaded |
| 61 | if (!ros::isInitialized()) |
| 62 | { |
| 63 | ROS_FATAL_NAMED("LedController", "Tried to load ROS plugin when ROS Gazebo API is not loaded. Please use gazebo_ros node to" |
| 64 | "launch Gazebo."); |
| 65 | } |
| 66 | |
| 67 | role = (ros::this_node::getName() == "/gazebo") ? Role::Server : Role::Client; |
| 68 | ROS_INFO_NAMED(("LedController_" + robotNamespace).c_str(), "LedController has started (as %s) in namespace '%s'", |
| 69 | role == Role::Client ? "client" : "server", robotNamespace.c_str()); |
| 70 | |
| 71 | nh.reset(new ros::NodeHandle(robotNamespace)); |
| 72 | |
| 73 | stateSubscriber = nh->subscribe<led_msgs::LEDStateArray>("led/state", 1, &LedController::handleLedsMsg, this); |
| 74 | }; |
| 75 | |
| 76 | ~LedController() |
| 77 | { |