Skip to content

Commit 2dd8f38

Browse files
committed
rename StatePublisherDescription to PublisherDescription
1 parent b3ab4d6 commit 2dd8f38

File tree

9 files changed

+127
-68
lines changed

9 files changed

+127
-68
lines changed

controller_manager_msgs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ set(msg_files
1616
msg/HandleName.msg
1717
msg/HardwareComponentState.msg
1818
msg/HardwareInterface.msg
19-
msg/StatePublisherDescription.msg
19+
msg/PublisherDescription.msg
2020
)
2121
set(srv_files
2222
srv/ConfigureController.srv
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
string ns # the namespace the Publisher is in
2+
controller_manager_msgs/HandleName name # the full qualified name (prefix_name + interface_name) of the Publishers interface
3+
string publisher_topic # the topic via which the values/commands are published.

controller_manager_msgs/msg/StatePublisherDescription.msg

Lines changed: 0 additions & 3 deletions
This file was deleted.

controller_manager_msgs/srv/RegisterSubControllerManager.srv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
string sub_controller_manager_namespace
1515
string sub_controller_manager_name
16-
controller_manager_msgs/StatePublisherDescription[] state_publishers
16+
controller_manager_msgs/PublisherDescription[] state_publishers
17+
controller_manager_msgs/PublisherDescription[] command_state_publishers
1718
---
19+
controller_manager_msgs/PublisherDescription[] command_state_publishers
1820
bool ok
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
#ifndef DISTRIBUTED_CONTROL__STATE_PUBLISHER_DESCRIPTION_HPP_
22
#define DISTRIBUTED_CONTROL__STATE_PUBLISHER_DESCRIPTION_HPP_
33

4-
#include "controller_manager_msgs/msg/state_publisher_description.hpp"
4+
#include "controller_manager_msgs/msg/publisher_description.hpp"
55

66
#include "rclcpp/rclcpp.hpp"
77

88
namespace distributed_control
99
{
1010

11-
class StatePublisherDescription final
11+
class PublisherDescription final
1212
{
1313
public:
14-
explicit StatePublisherDescription(
15-
const controller_manager_msgs::msg::StatePublisherDescription & description)
14+
explicit PublisherDescription(
15+
const controller_manager_msgs::msg::PublisherDescription & description)
1616
: namespace_(description.ns),
1717
prefix_name_(description.name.prefix_name),
1818
interface_name_(description.name.interface_name),
19-
topic_name_(description.state_publisher_topic)
19+
topic_name_(description.publisher_topic)
2020
{
2121
}
2222

23-
StatePublisherDescription() = delete;
23+
PublisherDescription() = delete;
2424

25-
StatePublisherDescription(const StatePublisherDescription & other) = default;
25+
PublisherDescription(const PublisherDescription & other) = default;
2626

27-
StatePublisherDescription(StatePublisherDescription && other) = default;
27+
PublisherDescription(PublisherDescription && other) = default;
2828

29-
~StatePublisherDescription() {}
29+
~PublisherDescription() {}
3030

3131
std::string get_namespace() const { return namespace_; }
3232

hardware_interface/include/hardware_interface/distributed_control_interface/state_publisher.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "hardware_interface/loaned_state_interface.hpp"
1111

12-
#include "controller_manager_msgs/msg/state_publisher_description.hpp"
12+
#include "controller_manager_msgs/msg/publisher_description.hpp"
1313

1414
#include "rclcpp/rclcpp.hpp"
1515
#include "rclcpp_lifecycle/lifecycle_node.hpp"
@@ -19,7 +19,7 @@
1919
namespace distributed_control
2020
{
2121

22-
class StatePublisher final
22+
class StatePublisher final
2323
{
2424
public:
2525
explicit StatePublisher(
@@ -50,7 +50,7 @@ class StatePublisher final
5050
std::string state_interface_interface_name() const;
5151

5252
STATE_PUBLISHER_PUBLIC
53-
controller_manager_msgs::msg::StatePublisherDescription create_description_msg() const;
53+
controller_manager_msgs::msg::PublisherDescription create_description_msg() const;
5454

5555
private:
5656
void publish_value_on_timer();

hardware_interface/include/hardware_interface/distributed_control_interface/sub_controller_manager_wrapper.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include <string>
66
#include <vector>
77

8-
#include "controller_manager_msgs/msg/state_publisher_description.hpp"
8+
#include "controller_manager_msgs/msg/publisher_description.hpp"
99

10-
#include "hardware_interface/distributed_control_interface/state_publisher_description.hpp"
10+
#include "hardware_interface/distributed_control_interface/publisher_description.hpp"
1111

1212
namespace distributed_control
1313
{
@@ -17,7 +17,7 @@ class SubControllerManagerWrapper final
1717
public:
1818
explicit SubControllerManagerWrapper(
1919
const std::string & ns, const std::string & name,
20-
const std::vector<controller_manager_msgs::msg::StatePublisherDescription> & state_publishers)
20+
const std::vector<controller_manager_msgs::msg::PublisherDescription> & state_publishers)
2121
: NAMESPACE_(ns),
2222
NAME_(name),
2323
state_publisher_descriptions_({state_publishers.begin(), state_publishers.end()})
@@ -36,7 +36,7 @@ class SubControllerManagerWrapper final
3636

3737
std::string get_name() const { return get_namespace() + "/" + get_controller_manager_name(); }
3838

39-
std::vector<StatePublisherDescription> get_state_publisher_descriptions() const
39+
std::vector<PublisherDescription> get_state_publisher_descriptions() const
4040
{
4141
return state_publisher_descriptions_;
4242
}
@@ -46,7 +46,7 @@ class SubControllerManagerWrapper final
4646
private:
4747
const std::string NAMESPACE_;
4848
const std::string NAME_;
49-
std::vector<StatePublisherDescription> state_publisher_descriptions_;
49+
std::vector<PublisherDescription> state_publisher_descriptions_;
5050
};
5151

5252
} // namespace distributed_control

hardware_interface/include/hardware_interface/handle.hpp

Lines changed: 100 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <string>
1919
#include <utility>
2020

21-
#include "hardware_interface/distributed_control_interface/state_publisher_description.hpp"
21+
#include "hardware_interface/distributed_control_interface/publisher_description.hpp"
2222
#include "hardware_interface/macros.hpp"
2323
#include "hardware_interface/visibility_control.h"
2424

@@ -151,41 +151,14 @@ class ReadOnlyHandle : public HandleInterface, ReadHandleInterface
151151
}
152152
};
153153

154-
class ReadWriteHandle : public HandleInterface, ReadHandleInterface, WriteHandleInterface
154+
class StateInterface : public ReadOnlyHandle
155155
{
156156
public:
157-
ReadWriteHandle(
158-
const std::string & prefix_name, const std::string & interface_name,
159-
double * value_ptr = nullptr)
160-
: HandleInterface(prefix_name, interface_name, value_ptr)
161-
{
162-
}
163-
164-
explicit ReadWriteHandle(const std::string & interface_name) : HandleInterface(interface_name) {}
165-
166-
explicit ReadWriteHandle(const char * interface_name) : HandleInterface(interface_name) {}
167-
168-
ReadWriteHandle(const ReadWriteHandle & other) = default;
169-
170-
ReadWriteHandle(ReadWriteHandle && other) = default;
171-
172-
ReadWriteHandle & operator=(const ReadWriteHandle & other) = default;
173-
174-
ReadWriteHandle & operator=(ReadWriteHandle && other) = default;
175-
176-
virtual ~ReadWriteHandle() = default;
157+
StateInterface(const StateInterface & other) = default;
177158

178-
double get_value() const override
179-
{
180-
THROW_ON_NULLPTR(value_ptr_);
181-
return *value_ptr_;
182-
}
159+
StateInterface(StateInterface && other) = default;
183160

184-
void set_value(double value) override
185-
{
186-
THROW_ON_NULLPTR(this->value_ptr_);
187-
*this->value_ptr_ = value;
188-
}
161+
using ReadOnlyHandle::ReadOnlyHandle;
189162
};
190163

191164
class DistributedReadOnlyHandle : public ReadOnlyHandle
@@ -194,8 +167,7 @@ class DistributedReadOnlyHandle : public ReadOnlyHandle
194167
// TODO(Manuel): We should pass the initial value via service call, so that the value_ of ReadOnlyHandle
195168
// is initialized with a feasible value.
196169
DistributedReadOnlyHandle(
197-
const distributed_control::StatePublisherDescription & description,
198-
const std::string & ns = "/")
170+
const distributed_control::PublisherDescription & description, const std::string & ns = "/")
199171
: ReadOnlyHandle(description.prefix_name(), description.interface_name(), &value_),
200172
topic_name_(description.topic_name()),
201173
namespace_(ns),
@@ -303,24 +275,51 @@ class DistributedReadOnlyHandle : public ReadOnlyHandle
303275
double value_;
304276
};
305277

306-
class StateInterface : public ReadOnlyHandle
278+
class DistributedStateInterface : public DistributedReadOnlyHandle
307279
{
308280
public:
309-
StateInterface(const StateInterface & other) = default;
281+
DistributedStateInterface(const DistributedStateInterface & other) = default;
310282

311-
StateInterface(StateInterface && other) = default;
283+
DistributedStateInterface(DistributedStateInterface && other) = default;
312284

313-
using ReadOnlyHandle::ReadOnlyHandle;
285+
using DistributedReadOnlyHandle::DistributedReadOnlyHandle;
314286
};
315287

316-
class DistributedStateInterface : public DistributedReadOnlyHandle
288+
class ReadWriteHandle : public HandleInterface, ReadHandleInterface, WriteHandleInterface
317289
{
318290
public:
319-
DistributedStateInterface(const DistributedStateInterface & other) = default;
291+
ReadWriteHandle(
292+
const std::string & prefix_name, const std::string & interface_name,
293+
double * value_ptr = nullptr)
294+
: HandleInterface(prefix_name, interface_name, value_ptr)
295+
{
296+
}
320297

321-
DistributedStateInterface(DistributedStateInterface && other) = default;
298+
explicit ReadWriteHandle(const std::string & interface_name) : HandleInterface(interface_name) {}
322299

323-
using DistributedReadOnlyHandle::DistributedReadOnlyHandle;
300+
explicit ReadWriteHandle(const char * interface_name) : HandleInterface(interface_name) {}
301+
302+
ReadWriteHandle(const ReadWriteHandle & other) = default;
303+
304+
ReadWriteHandle(ReadWriteHandle && other) = default;
305+
306+
ReadWriteHandle & operator=(const ReadWriteHandle & other) = default;
307+
308+
ReadWriteHandle & operator=(ReadWriteHandle && other) = default;
309+
310+
virtual ~ReadWriteHandle() = default;
311+
312+
double get_value() const override
313+
{
314+
THROW_ON_NULLPTR(value_ptr_);
315+
return *value_ptr_;
316+
}
317+
318+
void set_value(double value) override
319+
{
320+
THROW_ON_NULLPTR(this->value_ptr_);
321+
*this->value_ptr_ = value;
322+
}
324323
};
325324

326325
class CommandInterface : public ReadWriteHandle
@@ -338,6 +337,65 @@ class CommandInterface : public ReadWriteHandle
338337

339338
using ReadWriteHandle::ReadWriteHandle;
340339
};
340+
341+
class DistributedReadWriteHandle : public ReadWriteHandle
342+
{
343+
public:
344+
DistributedReadWriteHandle(
345+
const std::string & prefix_name, const std::string & interface_name,
346+
double * value_ptr = nullptr)
347+
: ReadWriteHandle(prefix_name, interface_name, value_ptr)
348+
{
349+
}
350+
351+
explicit DistributedReadWriteHandle(const std::string & interface_name)
352+
: ReadWriteHandle(interface_name)
353+
{
354+
}
355+
356+
explicit DistributedReadWriteHandle(const char * interface_name) : ReadWriteHandle(interface_name)
357+
{
358+
}
359+
360+
DistributedReadWriteHandle(const DistributedReadWriteHandle & other) = default;
361+
362+
DistributedReadWriteHandle(DistributedReadWriteHandle && other) = default;
363+
364+
DistributedReadWriteHandle & operator=(const DistributedReadWriteHandle & other) = default;
365+
366+
DistributedReadWriteHandle & operator=(DistributedReadWriteHandle && other) = default;
367+
368+
virtual ~DistributedReadWriteHandle() = default;
369+
370+
double get_value() const override
371+
{
372+
THROW_ON_NULLPTR(value_ptr_);
373+
return *value_ptr_;
374+
}
375+
376+
void set_value(double value) override
377+
{
378+
THROW_ON_NULLPTR(this->value_ptr_);
379+
*this->value_ptr_ = value;
380+
}
381+
};
382+
383+
class DistributedCommandInterface : public DistributedReadWriteHandle
384+
{
385+
public:
386+
/// CommandInterface copy constructor is actively deleted.
387+
/**
388+
* Command interfaces are having a unique ownership and thus
389+
* can't be copied in order to avoid simultaneous writes to
390+
* the same resource.
391+
*/
392+
DistributedCommandInterface(const DistributedCommandInterface & other) = delete;
393+
394+
DistributedCommandInterface(DistributedCommandInterface && other) = default;
395+
396+
using DistributedReadWriteHandle::DistributedReadWriteHandle;
397+
};
398+
341399
} // namespace hardware_interface
342400

343401
#endif // HARDWARE_INTERFACE__HANDLE_HPP_

hardware_interface/src/hardware_interface/distributed_control_interface/state_publisher.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ std::string StatePublisher::state_interface_interface_name() const
6262
return loaned_state_interface_ptr_->get_interface_name();
6363
}
6464

65-
controller_manager_msgs::msg::StatePublisherDescription StatePublisher::create_description_msg()
66-
const
65+
controller_manager_msgs::msg::PublisherDescription StatePublisher::create_description_msg() const
6766
{
68-
auto msg = controller_manager_msgs::msg::StatePublisherDescription();
67+
auto msg = controller_manager_msgs::msg::PublisherDescription();
6968
// we want a unique name for every StatePublisher. This gets relevant in the central ControllerManager
7069
// where multiple sub ControllerManager are registering. Therefor we add the namespace to the prefix.
7170
// However since that e.g. joint1/positions becomes /sub_namespace/joint1/position
7271
msg.ns = get_namespace();
7372
msg.name.prefix_name = state_interface_prefix_name();
7473
msg.name.interface_name = state_interface_interface_name();
75-
msg.state_publisher_topic = topic_name_relative_to_namespace();
74+
msg.publisher_topic = topic_name_relative_to_namespace();
7675

7776
return msg;
7877
}

0 commit comments

Comments
 (0)