Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <cstdio>
00033 #include <string>
00034 #include <sstream>
00035 #include <vector>
00036
00037 namespace costmap_2d
00038 {
00039
00044 std::vector<std::vector<float> > parseVVF(const std::string& input, std::string& error_return)
00045 {
00046 std::vector<std::vector<float> > result;
00047
00048 std::stringstream input_ss(input);
00049 int depth = 0;
00050 std::vector<float> current_vector;
00051 while (!!input_ss && !input_ss.eof())
00052 {
00053 switch (input_ss.peek())
00054 {
00055 case EOF:
00056 break;
00057 case '[':
00058 depth++;
00059 if (depth > 2)
00060 {
00061 error_return = "Array depth greater than 2";
00062 return result;
00063 }
00064 input_ss.get();
00065 current_vector.clear();
00066 break;
00067 case ']':
00068 depth--;
00069 if (depth < 0)
00070 {
00071 error_return = "More close ] than open [";
00072 return result;
00073 }
00074 input_ss.get();
00075 if (depth == 1)
00076 {
00077 result.push_back(current_vector);
00078 }
00079 break;
00080 case ',':
00081 case ' ':
00082 case '\t':
00083 input_ss.get();
00084 break;
00085 default:
00086 if (depth != 2)
00087 {
00088 std::stringstream err_ss;
00089 err_ss << "Numbers at depth other than 2. Char was '" << char(input_ss.peek()) << "'.";
00090 error_return = err_ss.str();
00091 return result;
00092 }
00093 float value;
00094 input_ss >> value;
00095 if (!!input_ss)
00096 {
00097 current_vector.push_back(value);
00098 }
00099 break;
00100 }
00101 }
00102
00103 if (depth != 0)
00104 {
00105 error_return = "Unterminated vector string.";
00106 }
00107 else
00108 {
00109 error_return = "";
00110 }
00111
00112 return result;
00113 }
00114
00115 }
costmap_2d
Author(s): Eitan Marder-Eppstein, David V. Lu!!, Dave Hershberger, contradict@gmail.com
autogenerated on Sun Mar 3 2019 03:46:15