Gazebo Msgs

API Reference

11.0.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#include <gz/msgs/config.hh>
21
22// Message Headers
23#include "gz/msgs/joint.pb.h"
24
25// Data Headers
26#include <string>
27
28namespace gz::msgs {
29// Inline bracket to help doxygen filtering.
30inline namespace GZ_MSGS_VERSION_NAMESPACE {
31
33inline msgs::Joint::Type ConvertJointType(const std::string &_str)
34{
35 msgs::Joint::Type result = msgs::Joint::REVOLUTE;
36 if (_str == "revolute")
37 {
38 result = msgs::Joint::REVOLUTE;
39 }
40 else if (_str == "revolute2")
41 {
42 result = msgs::Joint::REVOLUTE2;
43 }
44 else if (_str == "prismatic")
45 {
46 result = msgs::Joint::PRISMATIC;
47 }
48 else if (_str == "universal")
49 {
50 result = msgs::Joint::UNIVERSAL;
51 }
52 else if (_str == "ball")
53 {
54 result = msgs::Joint::BALL;
55 }
56 else if (_str == "screw")
57 {
58 result = msgs::Joint::SCREW;
59 }
60 else if (_str == "gearbox")
61 {
62 result = msgs::Joint::GEARBOX;
63 }
64 else if (_str == "fixed")
65 {
66 result = msgs::Joint::FIXED;
67 }
68 else if (_str == "continuous")
69 {
70 result = msgs::Joint::CONTINUOUS;
71 }
72 else
73 {
74 std::cerr << "Unrecognized JointType ["
75 << _str
76 << "], returning msgs::Joint::REVOLUTE"
77 << std::endl;
78 }
79 return result;
80}
81
83inline std::string ConvertJointType(const msgs::Joint::Type &_type)
84{
85 std::string result;
86 switch (_type)
87 {
88 case msgs::Joint::REVOLUTE:
89 {
90 result = "revolute";
91 break;
92 }
93 case msgs::Joint::REVOLUTE2:
94 {
95 result = "revolute2";
96 break;
97 }
98 case msgs::Joint::PRISMATIC:
99 {
100 result = "prismatic";
101 break;
102 }
103 case msgs::Joint::UNIVERSAL:
104 {
105 result = "universal";
106 break;
107 }
108 case msgs::Joint::BALL:
109 {
110 result = "ball";
111 break;
112 }
113 case msgs::Joint::SCREW:
114 {
115 result = "screw";
116 break;
117 }
118 case msgs::Joint::GEARBOX:
119 {
120 result = "gearbox";
121 break;
122 }
123 case msgs::Joint::FIXED:
124 {
125 result = "fixed";
126 break;
127 }
128 case msgs::Joint::CONTINUOUS:
129 {
130 result = "continuous";
131 break;
132 }
133 default:
134 {
135 result = "unknown";
136 std::cerr << "Unrecognized JointType ["
137 << _type
138 << "], returning 'unknown'"
139 << std::endl;
140 break;
141 }
142 }
143 return result;
144}
145
146} // namespce
147} // namespace gz::msgs
148
149#endif // GZ_MSGS_CONVERT_JOINTTYPE_HH_