123 #include <std_msgs/Float32.h>
124 #include <std_msgs/Float64.h>
125 #include <std_msgs/Int8.h>
126 #include <std_msgs/Int16.h>
127 #include <std_msgs/Int32.h>
128 #include <std_msgs/Int64.h>
129 #include <std_msgs/UInt8.h>
130 #include <std_msgs/UInt16.h>
131 #include <std_msgs/UInt32.h>
132 #include <std_msgs/UInt64.h>
133 #include <std_msgs/Bool.h>
134 #include <boost/algorithm/string.hpp>
135 #include <sensor_msgs/Joy.h>
136 #include <h4r_x52_joyext/x52_led_color.h>
154 template <
typename T>
171 return this->second < other.second;
187 axis_or_button(axis_or_button),
190 std::vector<std::string> separatedSetup;
191 boost::split(separatedSetup, setup, boost::is_any_of(
"|"));
194 for (i = 0; i < separatedSetup.size(); ++i)
198 if(separatedSetup[i].size()!=1)
200 ROS_ERROR(
"Faulty setup string part, expected 'O','G','Y' or 'R' got %s",separatedSetup[i].c_str());
205 switch(separatedSetup[i][0])
224 ROS_ERROR(
"Faulty setup string part, expected 'O','G','Y' or 'R' got %s",separatedSetup[i].c_str());
231 std::istringstream ss(separatedSetup[i]);
235 if(ss.bad() || ss.fail() || !ss.eof())
237 ROS_ERROR(
"Error in setup string: %s",separatedSetup[i].c_str());
241 this->
ranges.insert(pair);
246 ROS_ERROR(
"Error in setup string, missing led setting for upper end!");
248 pair.second=std::numeric_limits<T>::max();
249 this->
ranges.insert(pair);
251 h4r_x52_joyext::x52_led_color ledmsg;
252 if(led<0 || led>(
int)ledmsg.color_leds.size())
254 ROS_ERROR(
"LED number out of range!");
261 pub=n->advertise< h4r_x52_joyext::x52_led_color >(
"led",1);
268 for (
typename std::set<PairSortMod>::iterator it =
ranges.begin(); it !=
ranges.end(); ++it)
272 h4r_x52_joyext::x52_led_color msg;
273 msg.color_leds[this->
led]=it->first;
290 ROS_ERROR(
"Axis %i not available for that Joystick!",
axis_button);
301 ROS_ERROR(
"Button %i not available for that Joystick!",
axis_button);
306 template <
class MSGPTR>
314 template <
class MSG,
class MSGPTR>
333 int main(
int argc,
char **argv)
335 ros::init(argc, argv,
"value2buttonColor");
336 ros::NodeHandle n(
"~");
346 n.param<
int>(
"joy_axis_button", axis_button, 0);
347 n.param<
bool>(
"joy_axis_or_button", axis_or_button, 0);
348 n.param<
int>(
"color_led",led, 0);
349 ROS_DEBUG(
"LED -> %i",led);
353 n.param<std::string>(
"setup_string", setup,
"O|-0.5|G|0|Y|0.5|R");
357 #define casem(CASE,TYPE,TYPEROS)\
360 PublishLED< TYPE > obj(&n,setup,led,axis_button,axis_or_button);\
361 obj.start<std_msgs::TYPEROS, std_msgs:: TYPEROS## ConstPtr>();\
387 ROS_ERROR(
"Unkown Input Type!");
void Callback(const MSGPTR &msg)
void progressValue(T value)
void JoyCallback(const sensor_msgs::JoyConstPtr &msg)
PublishLED(ros::NodeHandle *n, std::string setup, int led, int axis, bool axis_or_button)
bool operator<(const PairSortMod &other) const
std::set< PairSortMod > ranges