Skip to content

Commit 0fb33c9

Browse files
committed
Fix lintern issues
1 parent 4358128 commit 0fb33c9

10 files changed

+189
-265
lines changed

pendulum_bringup/launch/controller_bringup.launch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Carlos San Vicente
1+
# Copyright 2021 Carlos San Vicente
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

pendulum_bringup/launch/driver_bringup.launch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Carlos San Vicente
1+
# Copyright 2021 Carlos San Vicente
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

pendulum_bringup/launch/pendulum_bringup.launch.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import os
16-
1715
from launch import LaunchDescription
18-
from launch_ros.substitutions import FindPackageShare
1916
from launch.actions import IncludeLaunchDescription
2017
from launch.launch_description_sources import PythonLaunchDescriptionSource
18+
from launch_ros.substitutions import FindPackageShare
19+
2120

2221
def generate_launch_description():
2322
# Get the bringup directory

pendulum_bringup/launch/pendulum_bringup_rviz.launch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Carlos San Vicente
1+
# Copyright 2021 Carlos San Vicente
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

pendulum_bringup/launch/rviz.launch.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Carlos San Vicente
1+
# Copyright 2021 Carlos San Vicente
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
from launch import LaunchDescription
1818
from launch.actions import DeclareLaunchArgument
1919
from launch.conditions import IfCondition
20-
import launch.substitutions
2120
from launch.substitutions import LaunchConfiguration
2221
from launch_ros.actions import Node
2322
from launch_ros.substitutions import FindPackageShare
@@ -33,10 +32,6 @@ def generate_launch_description():
3332
robot_desc = infp.read()
3433
rsp_params = {'robot_description': robot_desc}
3534

36-
# Set parameter file path
37-
param_file_path = os.path.join(bringup_dir, 'params', 'pendulum.param.yaml')
38-
param_file = launch.substitutions.LaunchConfiguration('params', default=[param_file_path])
39-
4035
# Set rviz config path
4136
rviz_cfg_path = os.path.join(bringup_dir, 'rviz/pendulum.rviz')
4237

pendulum_utils/include/pendulum_utils/RealtimeObject.hpp

+54-38
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020

2121
// Code taken from: https://github.com/hogliux/farbot
2222

23-
#pragma once
23+
#ifndef PENDULUM_UTILS__REALTIMEOBJECT_HPP_
24+
#define PENDULUM_UTILS__REALTIMEOBJECT_HPP_
2425

2526
#include <atomic>
2627
#include <memory>
2728
#include <mutex>
29+
#include <utility>
2830

2931
#include "pendulum_utils/detail/RealtimeObject.tcc"
3032

@@ -44,30 +46,37 @@ enum class ThreadType
4446
};
4547

4648
//==============================================================================
47-
/** Useful class to synchronise access to an object from multiple threads with the additional feature that one
48-
* designated thread will never wait to get access to the object. */
49-
template <typename T, RealtimeObjectOptions Options>
49+
/** Useful class to synchronise access to an object from multiple threads with the additional
50+
* feature that one designated thread will never wait to get access to the object. */
51+
template<typename T, RealtimeObjectOptions Options>
5052
class RealtimeObject
5153
{
5254
public:
5355
/** Creates a default constructed T */
5456
RealtimeObject() = default;
5557

5658
/** Creates a copy of T */
57-
explicit RealtimeObject(const T & obj) : mImpl(obj) {}
59+
explicit RealtimeObject(const T & obj)
60+
: mImpl(obj) {}
5861

5962
/** Moves T into this realtime wrapper */
60-
explicit RealtimeObject(T && obj) : mImpl(std::move(obj)) {}
63+
explicit RealtimeObject(T && obj)
64+
: mImpl(std::move(obj)) {}
6165

6266
~RealtimeObject() = default;
6367

6468
/** Create T by calling T's constructor which takes args */
65-
template <typename... Args>
66-
static RealtimeObject create(Args && ... args) { return Impl::create(std::forward<Args>(args)...); }
69+
template<typename ... Args>
70+
static RealtimeObject create(Args && ... args)
71+
{
72+
return Impl::create(std::forward<Args>(args)...);
73+
}
6774

6875
//==============================================================================
69-
using RealtimeAcquireReturnType = std::conditional_t<Options == RealtimeObjectOptions::nonRealtimeMutatable, const T, T>;
70-
using NonRealtimeAcquireReturnType = std::conditional_t<Options == RealtimeObjectOptions::realtimeMutatable, const T, T>;
76+
using RealtimeAcquireReturnType =
77+
std::conditional_t<Options == RealtimeObjectOptions::nonRealtimeMutatable, const T, T>;
78+
using NonRealtimeAcquireReturnType =
79+
std::conditional_t<Options == RealtimeObjectOptions::realtimeMutatable, const T, T>;
7180

7281
//==============================================================================
7382
/** Returns a reference to T. Use this method on the real-time thread.
@@ -78,20 +87,23 @@ class RealtimeObject
7887
*
7988
* This method is wait- and lock-free.
8089
*/
81-
RealtimeAcquireReturnType& realtimeAcquire() noexcept { return mImpl.realtimeAcquire(); }
90+
RealtimeAcquireReturnType & realtimeAcquire() noexcept {return mImpl.realtimeAcquire();}
8291

8392
/** Releases the lock on T previously acquired by realtimeAcquire.
8493
*
8594
* This method is wait- and lock-free.
8695
*/
87-
void realtimeRelease() noexcept { mImpl.realtimeRelease(); }
96+
void realtimeRelease() noexcept {mImpl.realtimeRelease();}
8897

8998
/** Replace the underlying value with a new instance of T by forwarding
9099
* the method's arguments to T's constructor
91100
*/
92-
template <RealtimeObjectOptions O = Options, typename... Args>
101+
template<RealtimeObjectOptions O = Options, typename ... Args>
93102
std::enable_if_t<O == RealtimeObjectOptions::realtimeMutatable, std::void_t<Args...>>
94-
realtimeReplace(Args && ... args) noexcept { mImpl.realtimeReplace(std::forward<Args>(args)...); }
103+
realtimeReplace(Args && ... args) noexcept
104+
{
105+
mImpl.realtimeReplace(std::forward<Args>(args)...);
106+
}
95107

96108
//==============================================================================
97109
/** Returns a reference to T. Use this method on the non real-time thread.
@@ -102,60 +114,64 @@ class RealtimeObject
102114
*
103115
* This method uses a lock should not be used on a realtime thread.
104116
*/
105-
NonRealtimeAcquireReturnType& nonRealtimeAcquire() { return mImpl.nonRealtimeAcquire(); }
117+
NonRealtimeAcquireReturnType & nonRealtimeAcquire() {return mImpl.nonRealtimeAcquire();}
106118

107119
/** Releases the lock on T previously acquired by nonRealtimeAcquire.
108120
*
109121
* This method uses both a lock and a spin loop and should not be used
110122
* on a realtime thread.
111123
*/
112-
void nonRealtimeRelease() { mImpl.nonRealtimeRelease(); }
124+
void nonRealtimeRelease() {mImpl.nonRealtimeRelease();}
113125

114126
/** Replace the underlying value with a new instance of T by forwarding
115127
* the method's arguments to T's constructor
116128
*/
117-
template <RealtimeObjectOptions O = Options, typename... Args>
129+
template<RealtimeObjectOptions O = Options, typename ... Args>
118130
std::enable_if_t<O == RealtimeObjectOptions::nonRealtimeMutatable, std::void_t<Args...>>
119-
nonRealtimeReplace(Args && ... args) { mImpl.nonRealtimeReplace(std::forward<Args>(args)...); }
131+
nonRealtimeReplace(Args && ... args) {mImpl.nonRealtimeReplace(std::forward<Args>(args)...);}
120132

121133
//==============================================================================
122134
/** Instead of calling acquire and release manually, you can also use this RAII
123135
* version which calls acquire automatically on construction and release when
124136
* destructed.
125137
*/
126-
template <ThreadType threadType>
127-
class ScopedAccess : public std::conditional_t<Options == RealtimeObjectOptions::realtimeMutatable,
138+
template<ThreadType threadType>
139+
class ScopedAccess
140+
: public std::conditional_t<Options == RealtimeObjectOptions::realtimeMutatable,
128141
detail::RealtimeMutatable<T>,
129-
detail::NonRealtimeMutatable<T>>::template ScopedAccess<threadType == ThreadType::realtime>
142+
detail::NonRealtimeMutatable<T>>::template ScopedAccess<threadType == ThreadType::realtime>
130143
{
131-
public:
132-
explicit ScopedAccess (RealtimeObject& parent)
133-
: Impl::template ScopedAccess<threadType == ThreadType::realtime> (parent.mImpl) {}
144+
public:
145+
explicit ScopedAccess(RealtimeObject & parent)
146+
: Impl::template ScopedAccess<threadType == ThreadType::realtime>(parent.mImpl) {}
134147

135148
#if DOXYGEN
136149
// Various ways to get access to the underlying object.
137-
// Non-const method are only supported on the realtime
138-
// or non-realtime thread as indicated by the Options
139-
// template argument
140-
T* get() noexcept;
141-
const T* get() const noexcept;
142-
T &operator *() noexcept;
143-
const T &operator *() const noexcept;
144-
T* operator->() noexcept;
145-
const T* operator->() const noexcept;
150+
// Non-const method are only supported on the realtime
151+
// or non-realtime thread as indicated by the Options
152+
// template argument
153+
T * get() noexcept;
154+
const T * get() const noexcept;
155+
T & operator*() noexcept;
156+
const T & operator*() const noexcept;
157+
T * operator->() noexcept;
158+
const T * operator->() const noexcept;
146159
#endif
147160

148161
//==============================================================================
149-
ScopedAccess(const ScopedAccess&) = delete;
162+
ScopedAccess(const ScopedAccess &) = delete;
150163
ScopedAccess(ScopedAccess &&) = delete;
151-
ScopedAccess& operator=(const ScopedAccess&) = delete;
152-
ScopedAccess& operator=(ScopedAccess&&) = delete;
164+
ScopedAccess & operator=(const ScopedAccess &) = delete;
165+
ScopedAccess & operator=(ScopedAccess &&) = delete;
153166
};
167+
154168
private:
155169
using Impl = std::conditional_t<Options == RealtimeObjectOptions::realtimeMutatable,
156170
detail::RealtimeMutatable<T>,
157-
detail::NonRealtimeMutatable<T>>;
171+
detail::NonRealtimeMutatable<T>>;
158172
Impl mImpl;
159173
};
160174

161-
}
175+
} // namespace farbot
176+
177+
#endif // PENDULUM_UTILS__REALTIMEOBJECT_HPP_

0 commit comments

Comments
 (0)