Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Chen <brian.chen@openrobotics.org>
  • Loading branch information
ihasdapie committed Aug 24, 2022
1 parent 84db6c7 commit 0a94fa5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 42 deletions.
29 changes: 16 additions & 13 deletions rclpy/src/rclpy/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ class Client : public Destroyable, public std::enable_shared_from_this<Client>
* \param[in] pyqos QoSProfile python object for this client
* \param[in] clock Clock to use for service event timestamps
*/
Client(Node & node, py::object pysrv_type, const char * service_name, py::object pyqos,
Clock & clock)
: Client(
node, std::move(pysrv_type), service_name, std::move(pyqos),
rcl_publisher_get_default_options().qos, clock){}
Client(
Node & node, py::object pysrv_type, const char * service_name, py::object pyqos,
Clock & clock)
: Client(
node, std::move(pysrv_type), service_name, std::move(pyqos),
rcl_publisher_get_default_options().qos, clock) {}

/// Create a client
/**
Expand All @@ -71,12 +72,13 @@ class Client : public Destroyable, public std::enable_shared_from_this<Client>
* \param[in] pyqos_service_event_pub QoSProfile python object for the service event publisher
* \param[in] clock Clock to use for service event timestamps
*/
Client(Node & node, py::object pysrv_type, const char * service_name, py::object pyqos,
py::object pyqos_service_event_pub, Clock & clock)
: Client(
node, std::move(pysrv_type), service_name, std::move(pyqos),
pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast<rmw_qos_profile_t>(),
clock){}
Client(
Node & node, py::object pysrv_type, const char * service_name, py::object pyqos,
py::object pyqos_service_event_pub, Clock & clock)
: Client(
node, std::move(pysrv_type), service_name, std::move(pyqos),
pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast<rmw_qos_profile_t>(),
clock) {}

~Client() = default;

Expand Down Expand Up @@ -122,8 +124,9 @@ class Client : public Destroyable, public std::enable_shared_from_this<Client>
destroy() override;

private:
Client(Node & node, py::object pysrv_type, const char * service_name, py::object pyqos,
rmw_qos_profile_t pyqos_service_event_pub, Clock & clock);
Client(
Node & node, py::object pysrv_type, const char * service_name, py::object pyqos,
rmw_qos_profile_t pyqos_service_event_pub, Clock & clock);
Node node_;
std::shared_ptr<rcl_client_t> rcl_client_;
};
Expand Down
6 changes: 3 additions & 3 deletions rclpy/src/rclpy/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ Service::destroy()
}

Service::Service(
Node & node, py::object pysrv_type, std::string service_name, py::object pyqos_srv_profile,
rmw_qos_profile_t service_event_publisher_qos, Clock & clock)
Node & node, py::object pysrv_type, std::string service_name, py::object pyqos_srv_profile,
rmw_qos_profile_t service_event_publisher_qos, Clock & clock)
: node_(node)
{
auto *srv_type = static_cast<rosidl_service_type_support_t *>(
auto * srv_type = static_cast<rosidl_service_type_support_t *>(
common_get_type_support(pysrv_type));
if (nullptr == srv_type) {
throw py::error_already_set();
Expand Down
14 changes: 7 additions & 7 deletions rclpy/src/rclpy/service.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class Service : public Destroyable, public std::enable_shared_from_this<Service>
std::string service_name,
py::object pyqos_profile,
Clock & clock)
: Service(
node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_profile),
rcl_service_get_default_options().qos, clock){}
: Service(
node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_profile),
rcl_service_get_default_options().qos, clock) {}

/// Create a service server
/**
Expand All @@ -85,10 +85,10 @@ class Service : public Destroyable, public std::enable_shared_from_this<Service>
py::object pyqos_srv_profile,
py::object pyqos_service_event_pub,
Clock & clock)
: Service(
node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_srv_profile),
pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast<rmw_qos_profile_t>(),
clock){}
: Service(
node, std::move(pysrv_type), std::move(service_name), std::move(pyqos_srv_profile),
pyqos_service_event_pub.is_none() ? rcl_publisher_get_default_options().qos : pyqos_service_event_pub.cast<rmw_qos_profile_t>(),
clock) {}

Service(
Node & node, std::shared_ptr<rcl_service_t> rcl_service);
Expand Down
48 changes: 30 additions & 18 deletions rclpy/src/rclpy/service_introspection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,40 @@
#include "rcl/client.h"
#include "rcl/service.h"

namespace rclpy {
namespace rclpy
{

#include <cstdio>
void
define_service_introspection(py::module_ module)
{
py::module_ m2 = module.def_submodule("service_introspection",
"utilities for introspecting services");
m2.def("configure_service_events",
[](size_t srv, size_t node, bool opt) {
return rcl_service_introspection_configure_server_service_events(reinterpret_cast<rcl_service_t *>(srv), reinterpret_cast<rcl_node_t *>(node), opt);
});
m2.def("configure_client_events",
[](size_t clt, size_t node, bool opt) {
return rcl_service_introspection_configure_client_service_events(reinterpret_cast<rcl_client_t *>(clt), reinterpret_cast<rcl_node_t *>(node), opt);
});
m2.def("configure_service_message_payload", [](size_t srv, bool opt){
return rcl_service_introspection_configure_server_service_event_message_payload(reinterpret_cast<rcl_service_t *>(srv), opt);
});
m2.def("configure_client_message_payload", [](size_t clt, bool opt) {
return rcl_service_introspection_configure_client_service_event_message_payload(reinterpret_cast<rcl_client_t *>(clt), opt);
});
py::module_ m2 = module.def_submodule(
"service_introspection",
"utilities for introspecting services");
m2.def(
"configure_service_events",
[](size_t srv, size_t node, bool opt) {
return rcl_service_introspection_configure_server_service_events(
reinterpret_cast<
rcl_service_t *>(srv), reinterpret_cast<rcl_node_t *>(node), opt);
});
m2.def(
"configure_client_events",
[](size_t clt, size_t node, bool opt) {
return rcl_service_introspection_configure_client_service_events(
reinterpret_cast<rcl_client_t
*>(clt), reinterpret_cast<rcl_node_t *>(node), opt);
});
m2.def(
"configure_service_message_payload", [](size_t srv, bool opt){
return rcl_service_introspection_configure_server_service_event_message_payload(
reinterpret_cast<rcl_service_t *>(srv), opt);
});
m2.def(
"configure_client_message_payload", [](size_t clt, bool opt) {
return rcl_service_introspection_configure_client_service_event_message_payload(
reinterpret_cast<rcl_client_t *>(clt), opt);
});
m2.attr("RCL_SERVICE_INTROSPECTION_PUBLISH_CLIENT_PARAMETER") =
RCL_SERVICE_INTROSPECTION_PUBLISH_CLIENT_PARAMETER;
m2.attr("RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_PARAMETER") =
Expand All @@ -50,5 +62,5 @@ define_service_introspection(py::module_ module)
m2.attr("RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_EVENT_CONTENT_PARAMETER") =
RCL_SERVICE_INTROSPECTION_PUBLISH_SERVICE_EVENT_CONTENT_PARAMETER;
m2.attr("RCL_SERVICE_INTROSPECTION_TOPIC_POSTFIX") = RCL_SERVICE_INTROSPECTION_TOPIC_POSTFIX;
}
}
} // namespace rclpy
3 changes: 2 additions & 1 deletion rclpy/src/rclpy/service_introspection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

namespace py = pybind11;

namespace rclpy {
namespace rclpy
{

void
define_service_introspection(py::module_ module);
Expand Down

0 comments on commit 0a94fa5

Please sign in to comment.