From d23d11e0b6e8aba4adf37c7b2818084d587d0cf1 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 3 Mar 2023 10:15:52 +0000 Subject: [PATCH] initial commit --- cpp_pubsub/CMakeLists.txt | 38 +++++++++++++ cpp_pubsub/package.xml | 20 +++++++ cpp_pubsub/src/publisher_member_function.cpp | 56 +++++++++++++++++++ cpp_pubsub/src/subscriber_member_function.cpp | 45 +++++++++++++++ drone_sensors/CMakeLists.txt | 37 ++++++++++++ drone_sensors/package.xml | 21 +++++++ drone_sensors/src/height_sensor.cpp | 39 +++++++++++++ my_package/CMakeLists.txt | 35 ++++++++++++ my_package/package.xml | 18 ++++++ my_package/src/my_node.cpp | 10 ++++ my_package_py/my_package_py/__init__.py | 0 my_package_py/my_package_py/my_node_py.py | 6 ++ my_package_py/package.xml | 18 ++++++ my_package_py/resource/my_package_py | 0 my_package_py/setup.cfg | 4 ++ my_package_py/setup.py | 26 +++++++++ my_package_py/test/test_copyright.py | 25 +++++++++ my_package_py/test/test_flake8.py | 25 +++++++++ my_package_py/test/test_pep257.py | 23 ++++++++ py_pubsub/package.xml | 21 +++++++ py_pubsub/py_pubsub/__init__.py | 0 .../py_pubsub/publisher_member_function.py | 53 ++++++++++++++++++ .../py_pubsub/subscriber_member_function.py | 51 +++++++++++++++++ py_pubsub/resource/py_pubsub | 0 py_pubsub/setup.cfg | 4 ++ py_pubsub/setup.py | 27 +++++++++ py_pubsub/test/test_copyright.py | 25 +++++++++ py_pubsub/test/test_flake8.py | 25 +++++++++ py_pubsub/test/test_pep257.py | 23 ++++++++ 29 files changed, 675 insertions(+) create mode 100644 cpp_pubsub/CMakeLists.txt create mode 100644 cpp_pubsub/package.xml create mode 100644 cpp_pubsub/src/publisher_member_function.cpp create mode 100644 cpp_pubsub/src/subscriber_member_function.cpp create mode 100644 drone_sensors/CMakeLists.txt create mode 100644 drone_sensors/package.xml create mode 100644 drone_sensors/src/height_sensor.cpp create mode 100644 my_package/CMakeLists.txt create mode 100644 my_package/package.xml create mode 100644 my_package/src/my_node.cpp create mode 100644 my_package_py/my_package_py/__init__.py create mode 100644 my_package_py/my_package_py/my_node_py.py create mode 100644 my_package_py/package.xml create mode 100644 my_package_py/resource/my_package_py create mode 100644 my_package_py/setup.cfg create mode 100644 my_package_py/setup.py create mode 100644 my_package_py/test/test_copyright.py create mode 100644 my_package_py/test/test_flake8.py create mode 100644 my_package_py/test/test_pep257.py create mode 100644 py_pubsub/package.xml create mode 100644 py_pubsub/py_pubsub/__init__.py create mode 100644 py_pubsub/py_pubsub/publisher_member_function.py create mode 100644 py_pubsub/py_pubsub/subscriber_member_function.py create mode 100644 py_pubsub/resource/py_pubsub create mode 100644 py_pubsub/setup.cfg create mode 100644 py_pubsub/setup.py create mode 100644 py_pubsub/test/test_copyright.py create mode 100644 py_pubsub/test/test_flake8.py create mode 100644 py_pubsub/test/test_pep257.py diff --git a/cpp_pubsub/CMakeLists.txt b/cpp_pubsub/CMakeLists.txt new file mode 100644 index 00000000..f199cabc --- /dev/null +++ b/cpp_pubsub/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 3.8) +project(cpp_pubsub) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) + +add_executable(talker src/publisher_member_function.cpp) +ament_target_dependencies(talker rclcpp std_msgs) +add_executable(listener src/subscriber_member_function.cpp) +ament_target_dependencies(listener rclcpp std_msgs) + +install(TARGETS + talker + listener + DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/cpp_pubsub/package.xml b/cpp_pubsub/package.xml new file mode 100644 index 00000000..8553fb33 --- /dev/null +++ b/cpp_pubsub/package.xml @@ -0,0 +1,20 @@ + + + + cpp_pubsub + 0.0.0 + Example of publisher/subscriber nodes in ROS 2 for the 5G drone + ic + Apache License 2.0 + + ament_cmake + rclcpp + std_msgs + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/cpp_pubsub/src/publisher_member_function.cpp b/cpp_pubsub/src/publisher_member_function.cpp new file mode 100644 index 00000000..c8d2ebfe --- /dev/null +++ b/cpp_pubsub/src/publisher_member_function.cpp @@ -0,0 +1,56 @@ +// Copyright 2016 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include + +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +using namespace std::chrono_literals; + +/* This example creates a subclass of Node and uses std::bind() to register a + * member function as a callback from the timer. */ + +class MinimalPublisher : public rclcpp::Node +{ +public: + MinimalPublisher() + : Node("minimal_publisher"), count_(0) + { + publisher_ = this->create_publisher("topic", 10); + timer_ = this->create_wall_timer( + 500ms, std::bind(&MinimalPublisher::timer_callback, this)); + } + +private: + void timer_callback() + { + auto message = std_msgs::msg::String(); + message.data = "Hello, world! " + std::to_string(count_++); + RCLCPP_INFO(this->get_logger(), "Publishing: '%s'", message.data.c_str()); + publisher_->publish(message); + } + rclcpp::TimerBase::SharedPtr timer_; + rclcpp::Publisher::SharedPtr publisher_; + size_t count_; +}; + +int main(int argc, char * argv[]) +{ + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + return 0; +} diff --git a/cpp_pubsub/src/subscriber_member_function.cpp b/cpp_pubsub/src/subscriber_member_function.cpp new file mode 100644 index 00000000..1560403e --- /dev/null +++ b/cpp_pubsub/src/subscriber_member_function.cpp @@ -0,0 +1,45 @@ +// Copyright 2016 Open Source Robotics Foundation, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" +using std::placeholders::_1; + +class MinimalSubscriber : public rclcpp::Node +{ +public: + MinimalSubscriber() + : Node("minimal_subscriber") + { + subscription_ = this->create_subscription( + "topic", 10, std::bind(&MinimalSubscriber::topic_callback, this, _1)); + } + +private: + void topic_callback(const std_msgs::msg::String::SharedPtr msg) const + { + RCLCPP_INFO(this->get_logger(), "I heard: '%s'", msg->data.c_str()); + } + rclcpp::Subscription::SharedPtr subscription_; +}; + +int main(int argc, char * argv[]) +{ + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + return 0; +} diff --git a/drone_sensors/CMakeLists.txt b/drone_sensors/CMakeLists.txt new file mode 100644 index 00000000..7368ee75 --- /dev/null +++ b/drone_sensors/CMakeLists.txt @@ -0,0 +1,37 @@ +cmake_minimum_required(VERSION 3.8) +project(drone_sensors) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) + +# add executable so that the node can be run with ros2 run +add_executable(height_sensor src/height_sensor.cpp) +ament_target_dependencies(height_sensor rclcpp std_msgs) + +# add install targets section so ros2 run can find the executable +install(TARGETS +height_sensor +DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/drone_sensors/package.xml b/drone_sensors/package.xml new file mode 100644 index 00000000..a2ba2a45 --- /dev/null +++ b/drone_sensors/package.xml @@ -0,0 +1,21 @@ + + + + drone_sensors + 0.0.0 + package for the environment sensors of the 5G drone (height meter, object detection) + Sem van der Hoeven + Apache License 2.0 + + ament_cmake + + rclcpp + std_msgs + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/drone_sensors/src/height_sensor.cpp b/drone_sensors/src/height_sensor.cpp new file mode 100644 index 00000000..909c558a --- /dev/null +++ b/drone_sensors/src/height_sensor.cpp @@ -0,0 +1,39 @@ +#include //time measurement + +#include "rclcpp/rclcpp.hpp" +#include "std_msgs/msg/string.hpp" + +using namespace std::chrono_literals; + +class HeightSensorPublisher : public rclcpp::Node +{ + public: + HeightSensorPublisher() : Node("height_sensor_publisher") + { + publisher_ = this->create_publisher("height_sensor", 10); + timer_ = this->create_wall_timer( + 500ms, std::bind(&HeightSensorPublisher::timer_callback, this)); + + } + private: + void timer_callback() + { + auto message = std_msgs::msg::String(); + message.data = "Hello heigth sensor!"; + RCLCPP_INFO(this->get_logger(), "Publishing: %s", message.data.c_str()); + publisher_->publish(message); + } + rclcpp::TimerBase::SharedPtr timer_; + rclcpp::Publisher::SharedPtr publisher_; +}; + +int main(int argc, char *argv[]) +{ + rclcpp::init(argc,argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + + return 0; +} + + diff --git a/my_package/CMakeLists.txt b/my_package/CMakeLists.txt new file mode 100644 index 00000000..ac32ca48 --- /dev/null +++ b/my_package/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.8) +project(my_package) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +add_executable(my_node src/my_node.cpp) +target_include_directories(my_node PUBLIC + $ + $) +target_compile_features(my_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 + +install(TARGETS my_node + DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/my_package/package.xml b/my_package/package.xml new file mode 100644 index 00000000..4bf230fe --- /dev/null +++ b/my_package/package.xml @@ -0,0 +1,18 @@ + + + + my_package + 0.0.0 + TODO: Package description + ubuntu + TODO: License declaration + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/my_package/src/my_node.cpp b/my_package/src/my_node.cpp new file mode 100644 index 00000000..0248b108 --- /dev/null +++ b/my_package/src/my_node.cpp @@ -0,0 +1,10 @@ +#include + +int main(int argc, char ** argv) +{ + (void) argc; + (void) argv; + + printf("hello world my_package package\n"); + return 0; +} diff --git a/my_package_py/my_package_py/__init__.py b/my_package_py/my_package_py/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/my_package_py/my_package_py/my_node_py.py b/my_package_py/my_package_py/my_node_py.py new file mode 100644 index 00000000..ceb86f5c --- /dev/null +++ b/my_package_py/my_package_py/my_node_py.py @@ -0,0 +1,6 @@ +def main(): + print('Hi from my_package_py.') + + +if __name__ == '__main__': + main() diff --git a/my_package_py/package.xml b/my_package_py/package.xml new file mode 100644 index 00000000..cb3801eb --- /dev/null +++ b/my_package_py/package.xml @@ -0,0 +1,18 @@ + + + + my_package_py + 0.0.0 + TODO: Package description + ubuntu + TODO: License declaration + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/my_package_py/resource/my_package_py b/my_package_py/resource/my_package_py new file mode 100644 index 00000000..e69de29b diff --git a/my_package_py/setup.cfg b/my_package_py/setup.cfg new file mode 100644 index 00000000..8cc1be01 --- /dev/null +++ b/my_package_py/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/my_package_py +[install] +install_scripts=$base/lib/my_package_py diff --git a/my_package_py/setup.py b/my_package_py/setup.py new file mode 100644 index 00000000..564a8995 --- /dev/null +++ b/my_package_py/setup.py @@ -0,0 +1,26 @@ +from setuptools import setup + +package_name = 'my_package_py' + +setup( + name=package_name, + version='0.0.0', + packages=[package_name], + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='ubuntu', + maintainer_email='ubuntu@todo.todo', + description='TODO: Package description', + license='TODO: License declaration', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'my_node_py = my_package_py.my_node_py:main' + ], + }, +) diff --git a/my_package_py/test/test_copyright.py b/my_package_py/test/test_copyright.py new file mode 100644 index 00000000..97a39196 --- /dev/null +++ b/my_package_py/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/my_package_py/test/test_flake8.py b/my_package_py/test/test_flake8.py new file mode 100644 index 00000000..27ee1078 --- /dev/null +++ b/my_package_py/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/my_package_py/test/test_pep257.py b/my_package_py/test/test_pep257.py new file mode 100644 index 00000000..b234a384 --- /dev/null +++ b/my_package_py/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/py_pubsub/package.xml b/py_pubsub/package.xml new file mode 100644 index 00000000..b2dae22b --- /dev/null +++ b/py_pubsub/package.xml @@ -0,0 +1,21 @@ + + + + py_pubsub + 0.0.0 + Example of publisher/subscriber nodes in Python + ubuntu + Apache License 2.0 + + rclpy + std_msgs + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/py_pubsub/py_pubsub/__init__.py b/py_pubsub/py_pubsub/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/py_pubsub/py_pubsub/publisher_member_function.py b/py_pubsub/py_pubsub/publisher_member_function.py new file mode 100644 index 00000000..dfdb0320 --- /dev/null +++ b/py_pubsub/py_pubsub/publisher_member_function.py @@ -0,0 +1,53 @@ +# Copyright 2016 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import rclpy +from rclpy.node import Node + +from std_msgs.msg import String + + +class MinimalPublisher(Node): + + def __init__(self): + super().__init__('minimal_publisher') + self.publisher_ = self.create_publisher(String, 'topic', 10) + timer_period = 0.5 # seconds + self.timer = self.create_timer(timer_period, self.timer_callback) + self.i = 0 + + def timer_callback(self): + msg = String() + msg.data = 'Hello World: %d' % self.i + self.publisher_.publish(msg) + self.get_logger().info('Publishing: "%s"' % msg.data) + self.i += 1 + + +def main(args=None): + rclpy.init(args=args) + + minimal_publisher = MinimalPublisher() + + rclpy.spin(minimal_publisher) + + # Destroy the node explicitly + # (optional - otherwise it will be done automatically + # when the garbage collector destroys the node object) + minimal_publisher.destroy_node() + rclpy.shutdown() + + +if __name__ == '__main__': + main() diff --git a/py_pubsub/py_pubsub/subscriber_member_function.py b/py_pubsub/py_pubsub/subscriber_member_function.py new file mode 100644 index 00000000..78c72668 --- /dev/null +++ b/py_pubsub/py_pubsub/subscriber_member_function.py @@ -0,0 +1,51 @@ +# Copyright 2016 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import rclpy +from rclpy.node import Node + +from std_msgs.msg import String + + +class MinimalSubscriber(Node): + + def __init__(self): + super().__init__('minimal_subscriber') + self.subscription = self.create_subscription( + String, + 'topic', + self.listener_callback, + 10) + self.subscription # prevent unused variable warning + + def listener_callback(self, msg): + self.get_logger().info('I heard: "%s"' % msg.data) + + +def main(args=None): + rclpy.init(args=args) + + minimal_subscriber = MinimalSubscriber() + + rclpy.spin(minimal_subscriber) + + # Destroy the node explicitly + # (optional - otherwise it will be done automatically + # when the garbage collector destroys the node object) + minimal_subscriber.destroy_node() + rclpy.shutdown() + + +if __name__ == '__main__': + main() diff --git a/py_pubsub/resource/py_pubsub b/py_pubsub/resource/py_pubsub new file mode 100644 index 00000000..e69de29b diff --git a/py_pubsub/setup.cfg b/py_pubsub/setup.cfg new file mode 100644 index 00000000..3f886b98 --- /dev/null +++ b/py_pubsub/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script_dir=$base/lib/py_pubsub +[install] +install_scripts=$base/lib/py_pubsub diff --git a/py_pubsub/setup.py b/py_pubsub/setup.py new file mode 100644 index 00000000..ebc173ef --- /dev/null +++ b/py_pubsub/setup.py @@ -0,0 +1,27 @@ +from setuptools import setup + +package_name = 'py_pubsub' + +setup( + name=package_name, + version='0.0.0', + packages=[package_name], + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='ubuntu', + maintainer_email='ubuntu@todo.todo', + description='Example of publisher/subscriber nodes in Python', + license='Apache License 2.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'talker = py_pubsub.publisher_member_function:main', + 'listener = py_pubsub.subscriber_member_function:main', + ], + }, +) diff --git a/py_pubsub/test/test_copyright.py b/py_pubsub/test/test_copyright.py new file mode 100644 index 00000000..97a39196 --- /dev/null +++ b/py_pubsub/test/test_copyright.py @@ -0,0 +1,25 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_copyright.main import main +import pytest + + +# Remove the `skip` decorator once the source file(s) have a copyright header +@pytest.mark.skip(reason='No copyright header has been placed in the generated source file.') +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/py_pubsub/test/test_flake8.py b/py_pubsub/test/test_flake8.py new file mode 100644 index 00000000..27ee1078 --- /dev/null +++ b/py_pubsub/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/py_pubsub/test/test_pep257.py b/py_pubsub/test/test_pep257.py new file mode 100644 index 00000000..b234a384 --- /dev/null +++ b/py_pubsub/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings'