Gazebo Msgs

API Reference

10.1.1
JointType.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17#ifndef GZ_MSGS_CONVERT_JOINTTYPE_HH_
18#define GZ_MSGS_CONVERT_JOINTTYPE_HH_
19
20// Message Headers
21#include "gz/msgs/joint.pb.h"
22
23// Data Headers
24#include <string>
25
26namespace gz::msgs {
27// Inline bracket to help doxygen filtering.
28inline namespace GZ_MSGS_VERSION_NAMESPACE {
29
31inline msgs::Joint::Type ConvertJointType(const std::string &_str)
32{
33 msgs::Joint::Type result = msgs::Joint::REVOLUTE;
34 if (_str == "revolute")
35 {
36 result = msgs::Joint::REVOLUTE;
37 }
38 else if (_str == "revolute2")
39 {
40 result = msgs::Joint::REVOLUTE2;
41 }
42 else if (_str == "prismatic")
43 {
44 result = msgs::Joint::PRISMATIC;
45 }
46 else if (_str == "universal")
47 {
48 result = msgs::Joint::UNIVERSAL;
49 }
50 else if (_str == "ball")
51 {
52 result = msgs::Joint::BALL;
53 }
54 else if (_str == "screw")
55 {
56 result = msgs::Joint::SCREW;
57 }
58 else if (_str == "gearbox")
59 {
60 result = msgs::Joint::GEARBOX;
61 }
62 else if (_str == "fixed")
63 {
64 result = msgs::Joint::FIXED;
65 }
66 else if (_str == "continuous")
67 {
68 result = msgs::Joint::CONTINUOUS;
69 }
70 else
71 {
72 std::cerr << "Unrecognized JointType ["
73 << _str
74 << "], returning msgs::Joint::REVOLUTE"
75 << std::endl;
76 }
77 return result;
78}
79
81inline std::string ConvertJointType(const msgs::Joint::Type &_type)
82{
83 std::string result;
84 switch (_type)
85 {
86 case msgs::Joint::REVOLUTE:
87 {
88 result = "revolute";
89 break;
90 }
91 case msgs::Joint::REVOLUTE2:
92 {
93 result = "revolute2";
94 break;
95 }
96 case msgs::Joint::PRISMATIC:
97 {
98 result = "prismatic";
99 break;
100 }
101 case msgs::Joint::UNIVERSAL:
102 {
103 result = "universal";
104 break;
105 }
106 case msgs::Joint::BALL:
107 {
108 result = "ball";
109 break;
110 }
111 case msgs::Joint::SCREW:
112 {
113 result = "screw";
114 break;
115 }
116 case msgs::Joint::GEARBOX:
117 {
118 result = "gearbox";
119 break;
120 }
121 case msgs::Joint::FIXED:
122 {
123 result = "fixed";
124 break;
125 }
126 case msgs::Joint::CONTINUOUS:
127 {
128 result = "continuous";
129 break;
130 }
131 default:
132 {
133 result = "unknown";
134 std::cerr << "Unrecognized JointType ["
135 << _type
136 << "], returning 'unknown'"
137 << std::endl;
138 break;
139 }
140 }
141 return result;
142}
143
144} // namespce
145} // namespace gz::msgs
146
147#endif // GZ_MSGS_CONVERT_JOINTTYPE_HH_