Skip to content

Commit 02dbd50

Browse files
committed
Fixed Linting Errors
Signed-off-by: CursedRock17 <[email protected]>
1 parent f9bd579 commit 02dbd50

File tree

2 files changed

+178
-129
lines changed

2 files changed

+178
-129
lines changed
Lines changed: 123 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
// Copyright 2023 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
#ifndef RCLCPP__PARAMETER_DESCRIPTOR_WRAPPER_HPP_
216
#define RCLCPP__PARAMETER_DESCRIPTOR_WRAPPER_HPP_
317

418
// Standard library includes
519
#include <functional>
620
#include <utility>
721
#include <memory>
22+
#include <string>
823

924
// Additional ROS libraries needed
1025
#include "rcl_interfaces/msg/list_parameters_result.hpp"
@@ -27,103 +42,121 @@ namespace rclcpp
2742
class ParameterDescription
2843
{
2944
public:
30-
// List of classes the builder manages
31-
ParameterDescription();
32-
33-
// Our Main build methods which will construct the base class
34-
rcl_interfaces::msg::ParameterDescriptor build() const;
35-
36-
//Builder Methods - Describes the instances in a parameter_descriptionobject
37-
ParameterDescription& SetName(const std::string& name);
38-
ParameterDescription& SetType(std::uint8_t type);
39-
ParameterDescription& SetDescriptionText(const std::string& description);
40-
ParameterDescription& SetAdditionalConstraints(const std::string& constraints);
41-
ParameterDescription& SetReadOnly(bool read_only);
42-
ParameterDescription& SetDynamicTyping(bool dynamic_typing);
43-
44-
// Need the current node in order to begin the configuraiton state for it via the declare_parameter function which setups up the Node
45-
template<typename ParameterType>
46-
ParameterDescription& DeclareParameter(ParameterType default_value, rclcpp::Node::SharedPtr required_node_ptr)
45+
// List of classes the builder manages
46+
ParameterDescription();
47+
48+
// Our Main build methods which will construct the base class
49+
rcl_interfaces::msg::ParameterDescriptor build() const;
50+
51+
// Builder Methods:
52+
// Describes the instances in a parameter_description object
53+
ParameterDescription& SetName(const std::string& name);
54+
ParameterDescription& SetType(std::uint8_t type);
55+
ParameterDescription& SetDescriptionText(const std::string& description);
56+
ParameterDescription& SetAdditionalConstraints(const std::string& constraints);
57+
ParameterDescription& SetReadOnly(bool read_only);
58+
ParameterDescription& SetDynamicTyping(bool dynamic_typing);
59+
60+
// Need the current node in order to begin the configuration state
61+
// for it via the declare_parameter function which setups the Node
62+
template<typename ParameterType>
63+
ParameterDescription&
64+
DeclareParameter(ParameterType default_value, rclcpp::Node::SharedPtr required_node_ptr)
65+
{
66+
required_node_ptr->declare_parameter<ParameterType>(parameter_descriptor.name, default_value, parameter_descriptor);
67+
return *this;
68+
}
69+
70+
template<typename ParameterType>
71+
ParameterDescription& DeclareParameter
72+
(ParameterType default_value,
73+
rclcpp_lifecycle::LifecycleNode::SharedPtr required_node_ptr)
74+
{
75+
required_node_ptr->declare_parameter<ParameterType>
76+
(parameter_descriptor.name, default_value, parameter_descriptor);
77+
return *this;
78+
}
79+
80+
// Simplification Methods:
81+
// The user should be able to set up ranges easily, they should then be able to call a function
82+
// this function sets up the specifics for this class
83+
// Here we will have a difference between generic types and templated types
84+
ParameterDescription& SetFloatingPointDescriptionRange
85+
(float min = 0.0f, float max = 1.0f, float step = 0.0f);
86+
// We will again need access to the current development node to declare its parameters
87+
template<typename ParameterType>
88+
ParameterDescription& SetFloatingPointDescriptionRange
89+
(rclcpp::Node::SharedPtr currentNode, const std::string& name,
90+
ParameterType default_value, float min = 0.0f,
91+
float max = 1.0f, float step = 0.0f)
92+
{
93+
parameter_descriptor.floating_point_range.resize(1);
94+
parameter_descriptor.floating_point_range.at(0).from_value = min;
95+
parameter_descriptor.floating_point_range.at(0).to_value = max;
96+
parameter_descriptor.floating_point_range.at(0).step = step;
97+
98+
// For this function we can outright declare the parameters using the specified type
99+
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
100+
101+
return *this;
102+
}
103+
104+
template<typename ParameterType>
105+
ParameterDescription& SetFloatingPointDescriptionRange
106+
(rclcpp_lifecycle::LifecycleNode::SharedPtr currentNode,
107+
const std::string& name, ParameterType default_value,
108+
float min = 0.0f, float max = 1.0f, float step = 0.0f)
47109
{
48-
required_node_ptr->declare_parameter<ParameterType>(m_name, default_value, parameter_descriptor);
49-
return *this;
110+
parameter_descriptor.floating_point_range.resize(1);
111+
parameter_descriptor.floating_point_range.at(0).from_value = min;
112+
parameter_descriptor.floating_point_range.at(0).to_value = max;
113+
parameter_descriptor.floating_point_range.at(0).step = step;
114+
115+
// For this function we can outright declare the parameters using the specified type
116+
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
117+
118+
return *this;
50119
}
51120

52-
template<typename ParameterType>
53-
ParameterDescription& DeclareParameter(ParameterType default_value, rclcpp_lifecycle::LifecycleNode::SharedPtr required_node_ptr)
121+
ParameterDescription& SetIntegerDescriptionRange(int min = 0, int max = 1, int step = 0);
122+
// We will again need access to the current development node to declare its parameters
123+
template<typename ParameterType>
124+
ParameterDescription& SetIntegerDescriptionRange
125+
(rclcpp::Node::SharedPtr currentNode, const std::string& name,
126+
ParameterType default_value, int min = 0, int max = 1, int step = 0)
54127
{
55-
required_node_ptr->declare_parameter<ParameterType>(m_name, default_value, parameter_descriptor);
56-
return *this;
128+
parameter_descriptor.integer_range.resize(1);
129+
parameter_descriptor.integer_range.at(0).from_value = min;
130+
parameter_descriptor.integer_range.at(0).to_value = max;
131+
parameter_descriptor.integer_range.at(0).step = step;
132+
133+
// For this version of the function we can outright declare the parameters using the specified type
134+
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
135+
136+
return *this;
57137
}
58138

59-
// Simplification Methods - The user should be able to set up ranges easily, they should then be able to call a function which sets up the specifics for this class (The floating point range for parameter description)
60-
// Here we will have a difference between generic types and templated types
61-
// Also we can use default values for min, max, and float. The other option is to utilize SetMin methods and similar and check if we have a range, if not, then we should resize one
62-
ParameterDescription& SetFloatingPointDescriptionRange(float min = 0.0f, float max = 1.0f, float step = 0.0f);
63-
// We will again need access to the current development node to declare its parameters
64-
template<typename ParameterType>
65-
ParameterDescription& SetFloatingPointDescriptionRange(rclcpp::Node::SharedPtr currentNode, const std::string& name, ParameterType default_value, float min = 0.0f, float max = 1.0f, float step = 0.0f)
66-
{
67-
parameter_descriptor.floating_point_range.resize(1);
68-
parameter_descriptor.floating_point_range.at(0).from_value = min;
69-
parameter_descriptor.floating_point_range.at(0).to_value = max;
70-
parameter_descriptor.floating_point_range.at(0).step = step;
71-
72-
// For this version of the function we can outright declare the parameters using the specified type
73-
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
74-
75-
return *this;
76-
}
77-
78-
template<typename ParameterType>
79-
ParameterDescription& SetFloatingPointDescriptionRange(rclcpp_lifecycle::LifecycleNode::SharedPtr currentNode, const std::string& name, ParameterType default_value, float min = 0.0f, float max = 1.0f, float step = 0.0f)
80-
{
81-
parameter_descriptor.floating_point_range.resize(1);
82-
parameter_descriptor.floating_point_range.at(0).from_value = min;
83-
parameter_descriptor.floating_point_range.at(0).to_value = max;
84-
parameter_descriptor.floating_point_range.at(0).step = step;
85-
86-
// For this version of the function we can outright declare the parameters using the specified type
87-
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
88-
89-
return *this;
90-
}
91-
92-
ParameterDescription& SetIntegerDescriptionRange(int min = 0, int max = 1, int step = 0);
93-
// We will again need access to the current development node to declare its parameters
94-
template<typename ParameterType>
95-
ParameterDescription& SetIntegerDescriptionRange(rclcpp::Node::SharedPtr currentNode, const std::string& name, ParameterType default_value, int min = 0, int max = 1, int step = 0)
96-
{
97-
parameter_descriptor.integer_range.resize(1);
98-
parameter_descriptor.integer_range.at(0).from_value = min;
99-
parameter_descriptor.integer_range.at(0).to_value = max;
100-
parameter_descriptor.integer_range.at(0).step = step;
101-
102-
// For this version of the function we can outright declare the parameters using the specified type
103-
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
104-
105-
return *this;
106-
}
107-
108-
// We will again need access to the current development node to declare its parameters
109-
template<typename ParameterType>
110-
ParameterDescription& SetIntegerDescriptionRange(rclcpp_lifecycle::LifecycleNode currentNode, const std::string& name, ParameterType default_value, int min = 0, int max = 1, int step = 0)
111-
{
112-
parameter_descriptor.integer_range.resize(1);
113-
parameter_descriptor.integer_range.at(0).from_value = min;
114-
parameter_descriptor.integer_range.at(0).to_value = max;
115-
parameter_descriptor.integer_range.at(0).step = step;
116-
117-
// For this version of the function we can outright declare the parameters using the specified type
118-
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
119-
120-
return *this;
121-
}
139+
// We will again need access to the current development node to declare its parameters
140+
template<typename ParameterType>
141+
ParameterDescription& SetIntegerDescriptionRange
142+
(rclcpp_lifecycle::LifecycleNode currentNode, const std::string& name,
143+
ParameterType default_value, int min = 0, int max = 1, int step = 0)
144+
{
145+
parameter_descriptor.integer_range.resize(1);
146+
parameter_descriptor.integer_range.at(0).from_value = min;
147+
parameter_descriptor.integer_range.at(0).to_value = max;
148+
parameter_descriptor.integer_range.at(0).step = step;
149+
150+
// For this function we can outright declare the parameters using the specified type
151+
currentNode->declare_parameter<ParameterType>(name, default_value, parameter_descriptor);
152+
153+
return *this;
154+
}
122155
private:
123-
// The main descriptor object we're meant to initialize and adjust
124-
rcl_interfaces::msg::ParameterDescriptor parameter_descriptor = {};
156+
// The main descriptor object we're meant to initialize and adjust
157+
rcl_interfaces::msg::ParameterDescriptor parameter_descriptor = {};
125158
};
126159

127-
} // namespace rclcpp
160+
} // namespace rclcpp
128161

129-
#endif // headerguards for parameter_descriptor
162+
#endif // RCLCPP__PARAMETER_DESCRIPTOR_WRAPPER_HPP_
Lines changed: 55 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,95 @@
1-
1+
// Copyright 2023 Open Source Robotics Foundation, Inc.
2+
// v
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.
215

316
#include "../../include/rclcpp/parameter_descriptor_wrapper.hpp"
417

5-
namespace rclcpp {
18+
namespace rclcpp
19+
{
620

721
ParameterDescription::ParameterDescription()
822
{
9-
// Copies all the information in ParameterDescriptor.msg - https://github.com/ros2/rcl_interfaces/blob/rolling/rcl_interfaces/msg/ParameterDescriptor.msg
10-
// Need to set this in the constructor, but it doesn't necessarily need to be used
11-
parameter_descriptor.type{rcl_interfaces::msg::ParameterType::PARAMETER_NOT_SET};
23+
// Copies all the information in ParameterDescriptor.message
24+
// Need to set this in the constructor, but it doesn't necessarily need to be used
25+
parameter_descriptor.type{rcl_interfaces::msg::ParameterType::PARAMETER_NOT_SET};
1226
}
1327

1428
// ParameterDescription - ParameterDescription
1529
// First the build methods to connect to the base class in the builder
1630
rcl_interfaces::msg::ParameterDescriptor ParameterDescription::build() const
1731
{
18-
// Return some some sort message
19-
return parameter_descriptor;
32+
// Return some some sort message
33+
return parameter_descriptor;
2034
}
2135

2236
// Builder methods which set up the original class
23-
// They all follow the same format of initing the value given within the base class, then returning this current class
24-
ParameterDescription& ParameterDescription::SetName(const std::string& name)
37+
// They all follow the same format of initing the value given within the base class
38+
// then returning the current class
39+
ParameterDescription & ParameterDescription::SetName(const std::string & name)
2540
{
26-
parameter_descriptor.name = name;
27-
return *this;
41+
parameter_descriptor.name = name;
42+
return *this;
2843
}
2944

30-
ParameterDescription& ParameterDescription::SetType(std::uint8_t type)
45+
ParameterDescription & ParameterDescription::SetType(std::uint8_t type)
3146
{
32-
parameter_descriptor.type = type;
33-
return *this;
47+
parameter_descriptor.type = type;
48+
return *this;
3449
}
3550

36-
ParameterDescription& ParameterDescription::SetDescriptionText(const std::string& description)
51+
ParameterDescription & ParameterDescription::SetDescriptionText(const std::string & description)
3752
{
38-
parameter_descriptor.description = description;
39-
return *this;
53+
parameter_descriptor.description = description;
54+
return *this;
4055
}
4156

42-
ParameterDescription& ParameterDescription::SetAdditionalConstraints(const std::string& constraints)
57+
ParameterDescription & ParameterDescription::SetAdditionalConstraints(const std::string & constraints)
4358
{
44-
parameter_descriptor.constraints = constraints;
45-
return *this;
59+
parameter_descriptor.constraints = constraints;
60+
return *this;
4661
}
4762

48-
ParameterDescription& ParameterDescription::SetReadOnly(bool read_only)
63+
ParameterDescription & ParameterDescription::SetReadOnly(bool read_only)
4964
{
50-
parameter_descriptor.read_only = read_only;
51-
return *this;
65+
parameter_descriptor.read_only = read_only;
66+
return *this;
5267
}
5368

54-
ParameterDescription& ParameterDescription::SetDynamicTyping(bool dynamic_typing)
69+
ParameterDescription & ParameterDescription::SetDynamicTyping(bool dynamic_typing)
5570
{
56-
parameter_descriptor.dynamic_typing = dynamic_typing;
57-
return *this;
71+
parameter_descriptor.dynamic_typing = dynamic_typing;
72+
return *this;
5873
}
5974

6075
// Here is the Specific range function for this parameter description
61-
ParameterDescription& ParameterDescription::SetFloatingPointDescriptionRange(float min, float max, float step)
76+
ParameterDescription & ParameterDescription::SetFloatingPointDescriptionRange
77+
(float min, float max, float step)
6278
{
63-
parameter_descriptor.floating_point_range.resize(1);
64-
parameter_descriptor.floating_point_range.at(0).from_value = min;
65-
parameter_descriptor.floating_point_range.at(0).to_value = max;
66-
parameter_descriptor.floating_point_range.at(0).step = step;
67-
return *this;
79+
parameter_descriptor.floating_point_range.resize(1);
80+
parameter_descriptor.floating_point_range.at(0).from_value = min;
81+
parameter_descriptor.floating_point_range.at(0).to_value = max;
82+
parameter_descriptor.floating_point_range.at(0).step = step;
83+
return *this;
6884
}
6985

70-
ParameterDescription& ParameterDescription::SetIntegerDescriptionRange(int min, int max, int step)
86+
ParameterDescription & ParameterDescription::SetIntegerDescriptionRange(int min, int max, int step)
7187
{
72-
parameter_descriptor.integer_range.resize(1);
73-
parameter_descriptor.integer_range.at(0).from_value = min;
74-
parameter_descriptor.integer_range.at(0).to_value = max;
75-
parameter_descriptor.integer_range.at(0).step = step;
76-
return *this;
88+
parameter_descriptor.integer_range.resize(1);
89+
parameter_descriptor.integer_range.at(0).from_value = min;
90+
parameter_descriptor.integer_range.at(0).to_value = max;
91+
parameter_descriptor.integer_range.at(0).step = step;
92+
return *this;
7793
}
7894

79-
} // rclcpp namespace
95+
} // namespace rclcpp

0 commit comments

Comments
 (0)