DART  6.10.1
MujocoModel.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2021, The DART development contributors
3  * All rights reserved.
4  *
5  * The list of contributors can be found at:
6  * https://github.com/dartsim/dart/blob/master/LICENSE
7  *
8  * This file is provided under the following "BSD-style" License:
9  * Redistribution and use in source and binary forms, with or
10  * without modification, are permitted provided that the following
11  * conditions are met:
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef DART_UTILS_MJCF_DETAIL_MUJOCOMODEL_HPP_
34 #define DART_UTILS_MJCF_DETAIL_MUJOCOMODEL_HPP_
35 
36 #include <tinyxml2.h>
37 
39 #include "dart/common/Uri.hpp"
48 
49 namespace dart {
50 namespace utils {
51 namespace MjcfParser {
52 namespace detail {
53 
55 class MujocoModel final
56 {
57 public:
58  MujocoModel() = default;
59 
65  Errors read(
66  const common::Uri& uri,
67  const common::ResourceRetrieverPtr& retrieverOrNull = nullptr);
68 
70  const std::string& getModel() const;
71 
73  const Compiler& getCompiler() const;
74 
76  const Option& getOption() const;
77 
79  const Size& getSize() const;
80 
82  const Asset& getAsset() const;
83 
85  const Worldbody& getWorldbody() const;
86 
88  const Equality& getEquality() const;
89 
90 private:
91  Errors read(
92  tinyxml2::XMLElement* element,
93  const common::Uri& baseUri,
94  const common::ResourceRetrieverPtr& retriever);
95 
97  std::string mModel{"MuJoCo Model"};
98 
106 };
107 
108 } // namespace detail
109 } // namespace MjcfParser
110 } // namespace utils
111 } // namespace dart
112 
113 #endif // #ifndef DART_UTILS_MJCF_DETAIL_MUJOCOMODEL_HPP_
Main class to parse MJCF model file.
Definition: MujocoModel.hpp:56
const Equality & getEquality() const
Returns the parsed <equality> element.
Definition: MujocoModel.cpp:258
const Asset & getAsset() const
Returns the parsed <asset> element.
Definition: MujocoModel.cpp:246
Worldbody mWorldbody
Definition: MujocoModel.hpp:104
const Option & getOption() const
Returns the parsed <option> element.
Definition: MujocoModel.cpp:234
Option mOption
Definition: MujocoModel.hpp:100
std::string mModel
The name of the model.
Definition: MujocoModel.hpp:97
Errors read(const common::Uri &uri, const common::ResourceRetrieverPtr &retrieverOrNull=nullptr)
Reads MJCF XML file.
Definition: MujocoModel.cpp:181
const Size & getSize() const
Returns the parsed <size> element.
Definition: MujocoModel.cpp:240
Size mSize
Definition: MujocoModel.hpp:101
Compiler mCompiler
Definition: MujocoModel.hpp:99
Asset mAsset
Definition: MujocoModel.hpp:103
Defaults mDefaults
Definition: MujocoModel.hpp:102
const Compiler & getCompiler() const
Returns the parsed <compiler> element.
Definition: MujocoModel.cpp:228
const Worldbody & getWorldbody() const
Returns the parsed <worldbody> element.
Definition: MujocoModel.cpp:252
const std::string & getModel() const
Returns the name of the model.
Definition: MujocoModel.cpp:222
Equality mEquality
Definition: MujocoModel.hpp:105
Definition: Worldbody.hpp:54
std::shared_ptr< ResourceRetriever > ResourceRetrieverPtr
Definition: ResourceRetriever.hpp:76
std::vector< Error > Errors
Definition: Error.hpp:85
Definition: BulletCollisionDetector.cpp:65
The Uri struct provides URI parsing and merging functionality based on RFC 3986.
Definition: Uri.hpp:87