Skip to content

Commit 069aea9

Browse files
authored
Fix formatting of the repo. (#82)
* add pre commit configuration * Updated clang-format * Added corrected files * Revert to master * Starting new CI configuration with pre-commit-hooks * Add clang format config - copied from ament-clang-format * Update action setup * Update version of hooks * Remove double pre-commit configuration * Update deprecated hook. * Update linters and formating configuration * Braces are allways in the new line * Updatd all line lengths to 100 * Add cpp lint option to ignore braces after else * Put clang-format first to reduce cpplint and cppcheck errors * Update build times and small error in setup * Reformat all repo files * Update configuration to ignore chnagelogs * Update python line length to 99
1 parent 6471232 commit 069aea9

17 files changed

+185
-196
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ repos:
4242
rev: 20.8b1
4343
hooks:
4444
- id: black
45-
args: ["--line-length=100"]
45+
args: ["--line-length=99"]
4646

4747
# PEP 257
4848
- repo: https://github.com/FalconSocial/pre-commit-mirrors-pep257
@@ -105,7 +105,7 @@ repos:
105105
stages: [commit]
106106
entry: ament_lint_cmake
107107
language: system
108-
files: CMakeLists.txt$
108+
files: CMakeLists\.txt$
109109

110110
# Copyright
111111
- repo: local
@@ -123,11 +123,13 @@ repos:
123123
hooks:
124124
- id: doc8
125125
args: ['--max-line-length=100', '--ignore=D001']
126+
exclude: CHANGELOG\.rst$
126127

127128
- repo: https://github.com/pre-commit/pygrep-hooks
128129
rev: v1.8.0
129130
hooks:
130131
- id: rst-backticks
132+
exclude: CHANGELOG\.rst$
131133
- id: rst-directive-colons
132134
- id: rst-inline-touching-normal
133135

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ information to effectively respond to your bug report or contribution.
1010
## Reporting Bugs/Feature Requests
1111
We welcome you to use the GitHub issue tracker to report bugs or suggest features.
1212

13-
When filing an issue, please check [existing open][issues], or [recently closed][closed-issues], issues to make sure
13+
When filing an issue, please check [existing open][issues], or [recently closed][closed-issues], issues to make sure
1414
somebody else hasn't already reported the issue.
1515
Please try to include as much information as you can. Details like these are incredibly useful:
1616

@@ -45,7 +45,7 @@ GitHub provides additional documentation on [forking a repository](https://help.
4545
## Finding contributions to work on
4646
Looking at the existing issues is a great way to find something to contribute on.
4747
As this project, by default, uses the default GitHub issue labels
48-
(enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'][help-wanted] issues
48+
(enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'][help-wanted] issues
4949
is a great place to start.
5050

5151

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This repository demonstrates the following `ros2_control` concepts:
3030

3131
* Creating of `*HardwareInterface` for a System, Sensor, and Actuator.
3232
* Creating a robot description in the form of URDF files
33-
* Loading the configuration and starting a robot using launch files
33+
* Loading the configuration and starting a robot using launch files
3434
* Control of two joints of *RRBot*
3535
* Using simulated robots and starting `ros_control` with Gazebo simulator
3636
* Implementing of controller switching strategy for a robot
@@ -62,20 +62,20 @@ git clone https://github.com/ros-controls/ros2_control_demos
6262
```
6363

6464
* Build everything, e.g. with:
65-
```
65+
```
6666
colcon build --symlink-install
6767
```
68-
68+
6969
* Do not forget to source `setup.bash` from the `install` folder!
70-
71-
70+
71+
7272
# Getting Started with ros2_control
7373

7474
Each of the described example cases from the roadmap has its own launch and URDF file.
7575

7676
## Starting example robots
7777

78-
Each example is started with a single launch file which starts up the robot hardware, loads controller configurations and it also opens `rviz2`.
78+
Each example is started with a single launch file which starts up the robot hardware, loads controller configurations and it also opens `rviz2`.
7979

8080
The `rviz2` setup can be recreated following these steps:
8181

doc/ros2_control_demo_robot_class_diagram.svg

Lines changed: 1 addition & 1 deletion
Loading

doc/ros2_control_new_robot.svg

Lines changed: 1 addition & 1 deletion
Loading

ros2_control_demo_hardware/include/ros2_control_demo_hardware/rrbot_system_position_only.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
1615
#ifndef ROS2_CONTROL_DEMO_HARDWARE__RRBOT_SYSTEM_POSITION_ONLY_HPP_
1716
#define ROS2_CONTROL_DEMO_HARDWARE__RRBOT_SYSTEM_POSITION_ONLY_HPP_
1817

@@ -21,18 +20,18 @@
2120
#include <vector>
2221

2322
#include "hardware_interface/base_interface.hpp"
24-
#include "hardware_interface/system_interface.hpp"
2523
#include "hardware_interface/handle.hpp"
2624
#include "hardware_interface/hardware_info.hpp"
25+
#include "hardware_interface/system_interface.hpp"
2726
#include "hardware_interface/types/hardware_interface_return_values.hpp"
2827
#include "hardware_interface/types/hardware_interface_status_values.hpp"
2928
#include "rclcpp/macros.hpp"
3029
#include "ros2_control_demo_hardware/visibility_control.h"
3130

3231
namespace ros2_control_demo_hardware
3332
{
34-
class RRBotSystemPositionOnlyHardware : public
35-
hardware_interface::BaseInterface<hardware_interface::SystemInterface>
33+
class RRBotSystemPositionOnlyHardware
34+
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
3635
{
3736
public:
3837
RCLCPP_SHARED_PTR_DEFINITIONS(RRBotSystemPositionOnlyHardware);

ros2_control_demo_hardware/src/rrbot_system_position_only.cpp

Lines changed: 60 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525

2626
namespace ros2_control_demo_hardware
2727
{
28-
2928
hardware_interface::return_type RRBotSystemPositionOnlyHardware::configure(
3029
const hardware_interface::HardwareInfo & info)
3130
{
32-
if (configure_default(info) != hardware_interface::return_type::OK) {
31+
if (configure_default(info) != hardware_interface::return_type::OK)
32+
{
3333
return hardware_interface::return_type::ERROR;
3434
}
3535

@@ -39,39 +39,42 @@ hardware_interface::return_type RRBotSystemPositionOnlyHardware::configure(
3939
hw_states_.resize(info_.joints.size(), std::numeric_limits<double>::quiet_NaN());
4040
hw_commands_.resize(info_.joints.size(), std::numeric_limits<double>::quiet_NaN());
4141

42-
for (const hardware_interface::ComponentInfo & joint : info_.joints) {
42+
for (const hardware_interface::ComponentInfo & joint : info_.joints)
43+
{
4344
// RRBotSystemPositionOnly has exactly one state and command interface on each joint
44-
if (joint.command_interfaces.size() != 1) {
45+
if (joint.command_interfaces.size() != 1)
46+
{
4547
RCLCPP_FATAL(
4648
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
47-
"Joint '%s' has %d command interfaces found. 1 expected.",
48-
joint.name.c_str(), joint.command_interfaces.size());
49+
"Joint '%s' has %d command interfaces found. 1 expected.", joint.name.c_str(),
50+
joint.command_interfaces.size());
4951
return hardware_interface::return_type::ERROR;
5052
}
5153

52-
if (joint.command_interfaces[0].name != hardware_interface::HW_IF_POSITION) {
54+
if (joint.command_interfaces[0].name != hardware_interface::HW_IF_POSITION)
55+
{
5356
RCLCPP_FATAL(
5457
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
55-
"Joint '%s' have %s command interfaces found. '%s' expected.",
56-
joint.name.c_str(), joint.command_interfaces[0].name.c_str(),
57-
hardware_interface::HW_IF_POSITION);
58+
"Joint '%s' have %s command interfaces found. '%s' expected.", joint.name.c_str(),
59+
joint.command_interfaces[0].name.c_str(), hardware_interface::HW_IF_POSITION);
5860
return hardware_interface::return_type::ERROR;
5961
}
6062

61-
if (joint.state_interfaces.size() != 1) {
63+
if (joint.state_interfaces.size() != 1)
64+
{
6265
RCLCPP_FATAL(
6366
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
64-
"Joint '%s' has %d state interface. 1 expected.",
65-
joint.name.c_str(), joint.state_interfaces.size());
67+
"Joint '%s' has %d state interface. 1 expected.", joint.name.c_str(),
68+
joint.state_interfaces.size());
6669
return hardware_interface::return_type::ERROR;
6770
}
6871

69-
if (joint.state_interfaces[0].name != hardware_interface::HW_IF_POSITION) {
72+
if (joint.state_interfaces[0].name != hardware_interface::HW_IF_POSITION)
73+
{
7074
RCLCPP_FATAL(
7175
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
72-
"Joint '%s' have %s state interface. '%s' expected.",
73-
joint.name.c_str(), joint.state_interfaces[0].name.c_str(),
74-
hardware_interface::HW_IF_POSITION);
76+
"Joint '%s' have %s state interface. '%s' expected.", joint.name.c_str(),
77+
joint.state_interfaces[0].name.c_str(), hardware_interface::HW_IF_POSITION);
7578
return hardware_interface::return_type::ERROR;
7679
}
7780
}
@@ -84,10 +87,10 @@ std::vector<hardware_interface::StateInterface>
8487
RRBotSystemPositionOnlyHardware::export_state_interfaces()
8588
{
8689
std::vector<hardware_interface::StateInterface> state_interfaces;
87-
for (uint i = 0; i < info_.joints.size(); i++) {
88-
state_interfaces.emplace_back(
89-
hardware_interface::StateInterface(
90-
info_.joints[i].name, hardware_interface::HW_IF_POSITION, &hw_states_[i]));
90+
for (uint i = 0; i < info_.joints.size(); i++)
91+
{
92+
state_interfaces.emplace_back(hardware_interface::StateInterface(
93+
info_.joints[i].name, hardware_interface::HW_IF_POSITION, &hw_states_[i]));
9194
}
9295

9396
return state_interfaces;
@@ -97,105 +100,99 @@ std::vector<hardware_interface::CommandInterface>
97100
RRBotSystemPositionOnlyHardware::export_command_interfaces()
98101
{
99102
std::vector<hardware_interface::CommandInterface> command_interfaces;
100-
for (uint i = 0; i < info_.joints.size(); i++) {
101-
command_interfaces.emplace_back(
102-
hardware_interface::CommandInterface(
103-
info_.joints[i].name, hardware_interface::HW_IF_POSITION, &hw_commands_[i]));
103+
for (uint i = 0; i < info_.joints.size(); i++)
104+
{
105+
command_interfaces.emplace_back(hardware_interface::CommandInterface(
106+
info_.joints[i].name, hardware_interface::HW_IF_POSITION, &hw_commands_[i]));
104107
}
105108

106109
return command_interfaces;
107110
}
108111

109-
110112
hardware_interface::return_type RRBotSystemPositionOnlyHardware::start()
111113
{
112-
RCLCPP_INFO(
113-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
114-
"Starting ...please wait...");
114+
RCLCPP_INFO(rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Starting ...please wait...");
115115

116-
for (int i = 0; i <= hw_start_sec_; i++) {
116+
for (int i = 0; i <= hw_start_sec_; i++)
117+
{
117118
rclcpp::sleep_for(std::chrono::seconds(1));
118119
RCLCPP_INFO(
119-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
120-
"%.1f seconds left...", hw_start_sec_ - i);
120+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "%.1f seconds left...",
121+
hw_start_sec_ - i);
121122
}
122123

123124
// set some default values when starting the first time
124-
for (uint i = 0; i < hw_states_.size(); i++) {
125-
if (std::isnan(hw_states_[i])) {
125+
for (uint i = 0; i < hw_states_.size(); i++)
126+
{
127+
if (std::isnan(hw_states_[i]))
128+
{
126129
hw_states_[i] = 0;
127130
hw_commands_[i] = 0;
128-
} else {
131+
}
132+
else
133+
{
129134
hw_commands_[i] = hw_states_[i];
130135
}
131136
}
132137

133138
status_ = hardware_interface::status::STARTED;
134139

135140
RCLCPP_INFO(
136-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
137-
"System Sucessfully started!");
141+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "System Successfully started!");
138142

139143
return hardware_interface::return_type::OK;
140144
}
141145

142146
hardware_interface::return_type RRBotSystemPositionOnlyHardware::stop()
143147
{
144-
RCLCPP_INFO(
145-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
146-
"Stopping ...please wait...");
148+
RCLCPP_INFO(rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Stopping ...please wait...");
147149

148-
for (int i = 0; i <= hw_stop_sec_; i++) {
150+
for (int i = 0; i <= hw_stop_sec_; i++)
151+
{
149152
rclcpp::sleep_for(std::chrono::seconds(1));
150153
RCLCPP_INFO(
151-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
152-
"%.1f seconds left...", hw_stop_sec_ - i);
154+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "%.1f seconds left...",
155+
hw_stop_sec_ - i);
153156
}
154157

155158
status_ = hardware_interface::status::STOPPED;
156159

157160
RCLCPP_INFO(
158-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
159-
"System sucessfully stopped!");
161+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "System successfully stopped!");
160162

161163
return hardware_interface::return_type::OK;
162164
}
163165

164166
hardware_interface::return_type RRBotSystemPositionOnlyHardware::read()
165167
{
166-
RCLCPP_INFO(
167-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
168-
"Reading...");
168+
RCLCPP_INFO(rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Reading...");
169169

170-
for (uint i = 0; i < hw_states_.size(); i++) {
170+
for (uint i = 0; i < hw_states_.size(); i++)
171+
{
171172
// Simulate RRBot's movement
172173
hw_states_[i] = hw_states_[i] + (hw_commands_[i] - hw_states_[i]) / hw_slowdown_;
173174
RCLCPP_INFO(
174-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
175-
"Got state %.5f for joint %d!", hw_states_[i], i);
175+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Got state %.5f for joint %d!",
176+
hw_states_[i], i);
176177
}
177-
RCLCPP_INFO(
178-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
179-
"Joints sucessfully read!");
178+
RCLCPP_INFO(rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Joints successfully read!");
180179

181180
return hardware_interface::return_type::OK;
182181
}
183182

184183
hardware_interface::return_type RRBotSystemPositionOnlyHardware::write()
185184
{
186-
RCLCPP_INFO(
187-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
188-
"Writing...");
185+
RCLCPP_INFO(rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Writing...");
189186

190-
for (uint i = 0; i < hw_commands_.size(); i++) {
187+
for (uint i = 0; i < hw_commands_.size(); i++)
188+
{
191189
// Simulate sending commands to the hardware
192190
RCLCPP_INFO(
193-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
194-
"Got command %.5f for joint %d!", hw_commands_[i], i);
191+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Got command %.5f for joint %d!",
192+
hw_commands_[i], i);
195193
}
196194
RCLCPP_INFO(
197-
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"),
198-
"Joints sucessfully written!");
195+
rclcpp::get_logger("RRBotSystemPositionOnlyHardware"), "Joints successfully written!");
199196

200197
return hardware_interface::return_type::OK;
201198
}
@@ -205,6 +202,4 @@ hardware_interface::return_type RRBotSystemPositionOnlyHardware::write()
205202
#include "pluginlib/class_list_macros.hpp"
206203

207204
PLUGINLIB_EXPORT_CLASS(
208-
ros2_control_demo_hardware::RRBotSystemPositionOnlyHardware,
209-
hardware_interface::SystemInterface
210-
)
205+
ros2_control_demo_hardware::RRBotSystemPositionOnlyHardware, hardware_interface::SystemInterface)

ros2_control_demo_robot/description/rrbot/rrbot.materials.xacro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,3 @@ https://github.com/ros-simulation/gazebo_ros_demos/blob/kinetic-devel/rrbot_desc
4242
</material>
4343

4444
</robot>
45-

ros2_control_demo_robot/description/rrbot/rrbot.urdf.xacro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,3 @@
202202
</xacro:macro>
203203

204204
</robot>
205-

ros2_control_demo_robot/description/rrbot/rrbot_system_position_only.ros2_control.xacro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@
2929
</xacro:macro>
3030

3131
</robot>
32-

0 commit comments

Comments
 (0)