TinyURDF 1.0.0
A Modern C++ Library for Parsing and Visualizing URDF Model Files
Loading...
Searching...
No Matches
pose_parser.h
Go to the documentation of this file.
1#ifndef INCLUDE_TINYURDF_POSE_POSE_PARSER_H_
2#define INCLUDE_TINYURDF_POSE_POSE_PARSER_H_
3
4// Copyright 2025 Wissem CHIHA
5
6#include <memory>
7#include "pose.h"
8#include "parser_base.h"
9#include "utils.h"
10
21class PoseParser : public ParserBase<Pose> {
22 public:
24 this->p_ = std::make_shared<Pose>();
25 }
26
27 void print(std::ostream& os) override {
28 os << "Parsed Pose = [";
29 p_->print(os);
30 os << "]";
31 }
32
33 bool empty() const override {
34 return false;
35 }
36
37 void clear() override {
38 p_->clear();
39 }
40
41 const char* getTypename() override {
42 return "pose";
43 }
44
45 bool isA(const char* name) override {
46 return isA(name);
47 }
48
49 void parse(const tinyxml2::XMLElement* xml) override {
51
52 const char* xyz_str = xml->Attribute("xyz");
53 const char* rpy_str = xml->Attribute("rpy");
54
55 if (xyz_str) {
56 double v[3];
57 str2array(xyz_str, v);
58 p_->setPosition(v[0], v[1], v[2]);
59 }
60
61 if (rpy_str) {
62 double r[3];
63 str2array(rpy_str, r);
64 p_->setRotation(r[0], r[1], r[2]);
65 }
66 }
67
68 std::shared_ptr<Pose> get() override {
69 return p_;
70 }
71
72 private:
73 std::shared_ptr<Pose> p_;
74};
75
76#endif // INCLUDE_TINYURDF_POSE_POSE_PARSER_H_
Definition parser_base.h:16
virtual void parse(const tinyxml2::XMLElement *xml)
Definition parser_base.h:27
Elementary parser for minimal pose description.
Definition pose_parser.h:21
void clear() override
Definition pose_parser.h:37
PoseParser()
Definition pose_parser.h:23
std::shared_ptr< Pose > get() override
Definition pose_parser.h:68
void parse(const tinyxml2::XMLElement *xml) override
Definition pose_parser.h:49
const char * getTypename() override
Definition pose_parser.h:41
bool empty() const override
Definition pose_parser.h:33
void print(std::ostream &os) override
Definition pose_parser.h:27
bool isA(const char *name) override
Definition pose_parser.h:45
void str2array(const char *str, double *arr)
Definition utils.cc:3