63 #include <boost/algorithm/string.hpp>
72 "sINVALID",
"sRN",
"sRA",
"sMN",
"sAN",
"sMA",
"sWN",
"sWA",
"sEN",
"sEA",
"sSN",
"sFA"
80 {
"", sINVALID}, {
"sINVALID", sINVALID}, {
"sRN", sRN}, {
"sRA", sRA}, {
"sMN", sMN}, {
"sAN", sAN}, {
"sMA", sMA}, {
"sWN", sWN}, {
"sWA", sWA}, {
"sEN", sEN}, {
"sEA", sEA}, {
"sSN", sSN}, {
"sFA", sFA}
101 const std::string & command_name,
const std::vector<std::string> & parameter)
103 sick_scan::SickLocColaTelegramMsg cola_telegram;
104 cola_telegram.header.stamp =
ROS::now();
105 cola_telegram.command_type = command_type;
106 cola_telegram.command_name = command_name;
107 cola_telegram.parameter = parameter;
108 return cola_telegram;
133 std::string cola_ascii_cmd;
134 if (
cola_ascii.size() > s_cola_ascii_start_tag.size() + s_cola_ascii_end_tag.size()
135 &&
cola_ascii.substr(0, s_cola_ascii_start_tag.size()) == s_cola_ascii_start_tag
138 cola_ascii_cmd =
cola_ascii.substr(s_cola_ascii_start_tag.size(),
cola_ascii.size() - s_cola_ascii_start_tag.size() - s_cola_ascii_end_tag.size());
145 std::vector<std::string> cola_parts;
146 boost::split(cola_parts, cola_ascii_cmd, boost::algorithm::is_space());
147 if(cola_parts.size() < 2)
149 ROS_WARN_STREAM(
"## ERROR Parse error in ColaParser::decodeColaTelegram(\"" << cola_ascii_cmd <<
"\"): to few arguments, at least command_type and command_name required");
150 return createColaTelegram(sINVALID,
"");
154 if(command_type == sINVALID)
156 ROS_WARN_STREAM(
"## ERROR Parse error in ColaParser::decodeColaTelegram(\"" << cola_ascii_cmd <<
"\"): invalid command_type \"" << cola_parts[0] <<
"\"");
157 return createColaTelegram(sINVALID,
"");
160 if(cola_parts[1].empty())
162 ROS_WARN_STREAM(
"## ERROR Parse error in ColaParser::decodeColaTelegram(\"" << cola_ascii_cmd <<
"\"): invalid command_name \"" << cola_parts[1] <<
"\"");
163 return createColaTelegram(sINVALID,
"");
166 sick_scan::SickLocColaTelegramMsg cola_telegram = createColaTelegram(command_type, cola_parts[1]);
167 if(cola_parts.size() > 2)
169 cola_telegram.parameter.reserve(cola_parts.size() - 2);
170 for(
size_t n = 2; n < cola_parts.size(); n++)
171 cola_telegram.parameter.push_back(cola_parts[n]);
173 return cola_telegram;
184 assert(cola_telegram.command_type > sINVALID && cola_telegram.command_type < MAX_COLA_COMMAND_NUMBER);
191 for(
size_t n = 0; n < cola_telegram.parameter.size(); n++)
193 if( n == 0 || parameter_is_ascii)
209 const std::vector<std::string> & parameter,
bool parameter_is_ascii)
211 return encodeColaTelegram(createColaTelegram(command_type, command_name, parameter), parameter_is_ascii);
222 return s_command_type_string[command_type];
233 std::map<std::string, sick_scan::ColaParser::COLA_SOPAS_COMMAND>::const_iterator iter_command_type = s_command_type_map.find(sopas_command);
250 base = ((cola_arg.find_first_of(
"+-") != std::string::npos) ? 10 : 16);
251 return std::stoi(cola_arg, 0, base);
253 catch(
const std::exception & exc)
255 ROS_WARN_STREAM(
"## ERROR ColaParser::convertColaArg(" << cola_arg <<
") failed, exception " << exc.what());
272 base = ((cola_arg.find_first_of(
"+-") != std::string::npos) ? 10 : 16);
273 return (uint32_t)std::stoul(cola_arg, 0, base);
275 catch(
const std::exception & exc)
277 ROS_WARN_STREAM(
"## ERROR ColaParser::convertColaArg(" << cola_arg <<
") failed, exception " << exc.what());