Debian Codegraph @

.deprecated/articulated_model/model_config.h

raw
1 /*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011-2014, Willow Garage, Inc.
5 * Copyright (c) 2014-2016, Open Source Robotics Foundation
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
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 * * Neither the name of Open Source Robotics Foundation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36 /** \author Dalibor Matura, Jia Pan */
37
38 #ifndef FCL_ARTICULATED_MODEL_MODEL_CONFIG_H
39 #define FCL_ARTICULATED_MODEL_MODEL_CONFIG_H
40
41 #include <string>
42 #include <map>
43 #include <memory>
44 #include "fcl/common/data_types.h"
45 #include "fcl/articulated_model/joint_config.h"
46
47 namespace fcl
48 {
49
50 template <typename S>
51 class ModelConfig
52 {
53 public:
54 ModelConfig();
55
56 ModelConfig(const ModelConfig& model_cfg);
57
58 ModelConfig(std::map<std::string, std::shared_ptr<Joint> > joints_map);
59
60 JointConfig getJointConfigByJointName(const std::string& joint_name) const;
61 JointConfig& getJointConfigByJointName(const std::string& joint_name);
62
63 JointConfig getJointConfigByJoint(std::shared_ptr<Joint> joint) const;
64 JointConfig& getJointConfigByJoint(std::shared_ptr<Joint> joint);
65
66 std::map<std::string, JointConfig> getJointCfgsMap() const
67 { return joint_cfgs_map_; }
68
69 private:
70 std::map<std::string, JointConfig> joint_cfgs_map_;
71 };
72
73 //============================================================================//
74 // //
75 // Implementations //
76 // //
77 //============================================================================//
78
79 //==============================================================================
80 template <typename S>
81 ModelConfig<S>::ModelConfig()
82 {
83 // Do nothing
84 }
85
86 //==============================================================================
87 template <typename S>
88 ModelConfig<S>::ModelConfig(const ModelConfig& model_cfg) :
89 joint_cfgs_map_(model_cfg.joint_cfgs_map_)
90 {}
91
92 //==============================================================================
93 template <typename S>
94 ModelConfig<S>::ModelConfig(std::map<std::string, std::shared_ptr<Joint> > joints_map)
95 {
96 std::map<std::string, std::shared_ptr<Joint> >::iterator it;
97 for(it = joints_map.begin(); it != joints_map.end(); ++it)
98 joint_cfgs_map_[it->first] = JointConfig(it->second);
99 }
100
101 //==============================================================================
102 template <typename S>
103 JointConfig ModelConfig<S>::getJointConfigByJointName(const std::string& joint_name) const
104 {
105 std::map<std::string, JointConfig>::const_iterator it = joint_cfgs_map_.find(joint_name);
106 assert(it != joint_cfgs_map_.end());
107
108 return it->second;
109 }
110
111 //==============================================================================
112 template <typename S>
113 JointConfig& ModelConfig<S>::getJointConfigByJointName(const std::string& joint_name)
114 {
115 std::map<std::string, JointConfig>::iterator it = joint_cfgs_map_.find(joint_name);
116 assert(it != joint_cfgs_map_.end());
117
118 return it->second;
119 }
120
121 //==============================================================================
122 template <typename S>
123 JointConfig ModelConfig<S>::getJointConfigByJoint(std::shared_ptr<Joint> joint) const
124 {
125 return getJointConfigByJointName(joint->getName());
126 }
127
128 //==============================================================================
129 template <typename S>
130 JointConfig& ModelConfig<S>::getJointConfigByJoint(std::shared_ptr<Joint> joint)
131 {
132 return getJointConfigByJointName(joint->getName());
133 }
134
135 } // namespace fcl
136
137 #endif