test.cpp
Go to the documentation of this file.
00001 /*******************************************************
00002 *                    ROS Headers                       *
00003 ********************************************************/
00004 #include <ros/ros.h>
00005 #include <actionlib/client/simple_action_client.h>
00006 #include <actionlib/client/terminal_state.h>
00007 
00008 /*******************************************************
00009 *                   Service Headers                    *
00010 ********************************************************/
00011 #include "bwi_msgs/LEDClear.h"
00012 #include "bwi_msgs/LEDSetStatus.h"
00013 #include "bwi_msgs/LEDTestStrip.h"
00014 
00015 /*******************************************************
00016 *                   Action Headers                     *
00017 ********************************************************/
00018 #include "bwi_msgs/LEDControlAction.h"
00019 
00020 /*******************************************************
00021 *                   Message Headers                    *
00022 ********************************************************/
00023 #include "bwi_msgs/LEDActionResult.h"
00024 #include "bwi_msgs/LEDAnimations.h"
00025 #include "bwi_msgs/LEDStatus.h"
00026 #include "bwi_msgs/LEDTestType.h"
00027 
00028 using namespace std;
00029 
00030 int main (int argc, char **argv)
00031 {
00032   ros::init(argc, argv, "test_ledcom_server");
00033 
00034   ros::NodeHandle privateNode("~");
00035 
00036   int type;
00037   privateNode.param<int>("type",type,2);
00038 
00039   int timeout;
00040   privateNode.param<int>("timeout",timeout,10);
00041 
00042   actionlib::SimpleActionClient<bwi_msgs::LEDControlAction> ac("led_control_server", true);
00043 
00044   ROS_INFO("Waiting for action server to start.");
00045   ac.waitForServer();
00046 
00047   ROS_INFO_STREAM("Action server started, sending goal of type " << type << " and with a timeout of " << timeout << " seconds.");
00048   bwi_msgs::LEDControlGoal goal;
00049 
00050 
00051   switch(type){
00052 
00053     case 1: {
00054               goal.type.led_animations = bwi_msgs::LEDAnimations::LEFT_TURN;
00055               break;
00056             }
00057     case 2: {
00058               goal.type.led_animations = bwi_msgs::LEDAnimations::RIGHT_TURN;
00059               break;
00060             }
00061     case 3: {
00062               goal.type.led_animations = bwi_msgs::LEDAnimations::REVERSE;
00063               break;
00064             }
00065     case 4: {
00066               goal.type.led_animations = bwi_msgs::LEDAnimations::BLOCKED;
00067               break;
00068             }
00069     case 5: {
00070               goal.type.led_animations = bwi_msgs::LEDAnimations::UP;
00071               break;
00072             }
00073     case 6: {
00074               goal.type.led_animations = bwi_msgs::LEDAnimations::DOWN;
00075               break;
00076             }
00077     case 7: {
00078               goal.type.led_animations = bwi_msgs::LEDAnimations::NEED_ASSIST;
00079               break;
00080             }
00081   }
00082 
00083   goal.timeout = ros::Duration(timeout);
00084   ac.sendGoal(goal);
00085 
00086   ROS_INFO("Action received goal: %s",ac.getState().toString().c_str());
00087 
00088   // Prvents values from being cached
00089   privateNode.deleteParam("type");
00090   privateNode.deleteParam("timeout");
00091 
00092   return 0;
00093 }


segbot_led
Author(s): Pato Lankenau , Rolando Fernandez
autogenerated on Thu Jun 6 2019 21:37:07