32 int main(
int argc,
char** argv)
36 printf(
"usage is `rosrun ncd_parser ncd_parser filename.alog`\n");
77 ROS_INFO (
"Shutting down NCDParser");
82 std::ifstream aLogFile;
85 if(!aLogFile.is_open())
93 for (
int i = 0; i < 210; i++)
95 getline(aLogFile, line);
101 while (getline(aLogFile, line))
104 std::vector<std::string> tokens;
108 if (tokens.size() < 4)
continue;
111 if (strtod(tokens[0].c_str(), NULL) <=
start_)
continue;
114 if (strtod(tokens[0].c_str(), NULL) >
end_ &&
end_ != -1)
116 std::cout << strtod(tokens[0].c_str(), NULL) <<
", " <<
end_ << std::endl;
117 ROS_INFO(
"Reached specified end time.");
122 if (tokens[1].compare(
"LMS_LASER_2D_LEFT") == 0)
124 else if (tokens[1].compare(
"LMS_LASER_2D_RIGHT") == 0)
126 else if (tokens[1].compare(
"ODOMETRY_POSE") == 0)
146 const std::string& laserFrame,
151 sensor_msgs::LaserScan scan;
156 scan.header.frame_id = laserFrame;
164 scan.intensities =
extractArray(tokens[3],
"Reflectance=[181]");
177 std::vector<float> xytheta =
extractArray(tokens[3],
"Pose=[3x1]");
178 double x = xytheta[0];
179 double y = xytheta[1];
181 double theta = xytheta[2];
190 rotation.
setRPY (roll, pitch, theta);
208 std::vector <std::string> &tokens,
209 std::string sentinel)
211 std::string::size_type lastPos = str.find_first_not_of (sentinel, 0);
212 std::string::size_type pos = str.find_first_of (sentinel, lastPos);
214 while (std::string::npos != pos || std::string::npos != lastPos)
216 std::string stringToken = str.substr (lastPos, pos - lastPos);
217 tokens.push_back (stringToken);
218 lastPos = str.find_first_not_of (sentinel, pos);
219 pos = str.find_first_of (sentinel, lastPos);
225 int n0 = s.find(pattern);
226 int n1 = s.find(
"{", n0);
227 int n2 = s.find(
"}", n1);
228 std::string valueList = s.substr(n1+1, n2-n1-1);
230 std::vector<float>
values;
231 std::vector<std::string> s_values;
234 for (
unsigned int i = 0; i < s_values.size(); i++)
235 values.push_back(strtod(s_values[i].c_str(), NULL));
242 int n1 = s.find(pattern);
243 int n2 = s.find(
",", n1);
244 std::string s_value = s.substr(n1+pattern.length(), n2-n1-pattern.length());
245 return strtod(s_value.c_str(), NULL);
259 rotation.
setRPY (roll, pitch, yaw);
277 rotation.
setRPY (roll, pitch, yaw);
tf::TransformBroadcaster tfBroadcaster_
void publish(const boost::shared_ptr< M > &message) const
std::vector< double > values
const std::string odomFrame_
tf::Transform worldToOdom_
double extractValue(std::string s, std::string pattern)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
const std::string leftLaserFrame_
TFSIMD_FORCE_INLINE const tfScalar & y() const
TFSIMD_FORCE_INLINE void setValue(const tfScalar &x, const tfScalar &y, const tfScalar &z)
ros::Publisher leftLaserPublisher_
void publishLaserMessage(const std::vector< std::string > &tokens, const std::string &laserFrame, const ros::Publisher &publisher)
void tokenize(const std::string &str, std::vector< std::string > &tokens, std::string sentinel)
std::vector< float > extractArray(std::string s, std::string pattern)
void setRPY(const tfScalar &roll, const tfScalar &pitch, const tfScalar &yaw)
int main(int argc, char **argv)
void createOdomToRightLaserTf()
void createOdomToLeftLaserTf()
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
TFSIMD_FORCE_INLINE const tfScalar & z() const
tf::Transform odomToRightLaser_
const std::string worldFrame_
bool getParam(const std::string &key, std::string &s) const
ros::Publisher rightLaserPublisher_
void publishTfMessages(const std::vector< std::string > &tokens)
NCDParser(char *filename)
tf::Transform odomToLeftLaser_
const std::string rightLaserFrame_