From 764d797e78ccdcf6357ab5ad14d2058b92913752 Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Wed, 15 Feb 2023 13:56:21 -0800 Subject: [PATCH 01/25] Setup 2 --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 018616e..8b3d744 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Ref: https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Creating-A cd ~ ``` -4. Go to src folder in your workspace +4. Go to src folder in your workspace. Change my_name_ws accordingly ```shell script cd my_name_ws/src/ @@ -55,6 +55,9 @@ sudo rosdep init rosdep update ``` +5. Open VSCode, got to the menu and select file, an then select open folder. This show our workspace in the VScode explorer + + ## Source Control Recommendations From 6cf756932a946fd01bf515b87d17bf12ee7c1a57 Mon Sep 17 00:00:00 2001 From: Carlos Reyes Date: Wed, 15 Feb 2023 17:40:47 -0500 Subject: [PATCH 02/25] SALUDO --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8b3d744..6e73623 100644 --- a/README.md +++ b/README.md @@ -69,3 +69,4 @@ rosdep update BUENOS DIAS :) +ADIOS From 165b125d2a378dc14b1987250aa08ccecead964e Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Wed, 15 Feb 2023 14:44:38 -0800 Subject: [PATCH 03/25] Created pkg lolito --- lolito/CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++++ lolito/package.xml | 18 ++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 lolito/CMakeLists.txt create mode 100644 lolito/package.xml diff --git a/lolito/CMakeLists.txt b/lolito/CMakeLists.txt new file mode 100644 index 0000000..b7d1cb2 --- /dev/null +++ b/lolito/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.5) +project(lolito) + +# Default to C99 +if(NOT CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 99) +endif() + +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +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) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # uncomment the line when a copyright and license is not present in all source files + #set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # uncomment the line when this package is not in a git repo + #set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/lolito/package.xml b/lolito/package.xml new file mode 100644 index 0000000..322108a --- /dev/null +++ b/lolito/package.xml @@ -0,0 +1,18 @@ + + + + lolito + 0.0.0 + TODO: Package description + roncanciovl + TODO: License declaration + + ament_cmake + + ament_lint_auto + ament_lint_common + + + ament_cmake + + From d0911435dc39d00353efdff249b78257d3b2a4c4 Mon Sep 17 00:00:00 2001 From: Carlos Reyes Date: Thu, 16 Feb 2023 08:28:48 -0500 Subject: [PATCH 04/25] willy loco --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e73623..716737f 100644 --- a/README.md +++ b/README.md @@ -69,4 +69,5 @@ rosdep update BUENOS DIAS :) -ADIOS +ADIOS +hola willy From 8b09edb0791ab3b3cabce483ad53d868ed3a8851 Mon Sep 17 00:00:00 2001 From: WILLY160116 Date: Thu, 16 Feb 2023 08:39:48 -0500 Subject: [PATCH 05/25] cambio pa reyes --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 716737f..2b722b3 100644 --- a/README.md +++ b/README.md @@ -71,3 +71,4 @@ rosdep update BUENOS DIAS :) ADIOS hola willy +HOla reyes From 467b5d9436b59f6d0d06ffbe97449fe91008a89a Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Thu, 16 Feb 2023 05:46:53 -0800 Subject: [PATCH 06/25] readme update --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e73623..1050577 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,25 @@ sudo rosdep init rosdep update ``` -5. Open VSCode, got to the menu and select file, an then select open folder. This show our workspace in the VScode explorer +5. Open VSCode, got to the menu and select file, an then select open folder and select our workspace in home. This show our workspace in the VScode explorer + +6. In a terminal go to your workspace + +```shell script +colcon build +``` + +7. Sourve the overlay according to your distro + +```shell script +source /opt/ros/foxy/setup.bash +``` +8. + +```shell script +. install/local_setup.bash +``` + @@ -69,4 +87,3 @@ rosdep update BUENOS DIAS :) -ADIOS From b711e3a5f03fdc0583f4aba1990fcc658b4e4d52 Mon Sep 17 00:00:00 2001 From: Raul Urdaneta Date: Thu, 16 Feb 2023 09:08:35 -0500 Subject: [PATCH 07/25] alo --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2efc043..73310bc 100644 --- a/README.md +++ b/README.md @@ -90,3 +90,5 @@ BUENOS DIAS :) ADIOS hola willy HOla reyes + +Feliz cumpleaños willy :) From 3acfc1bf360338870a014dbd88d211880de34a0b Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Thu, 16 Feb 2023 06:53:16 -0800 Subject: [PATCH 08/25] New node --- lolito/package.xml | 4 +++- lolito/scripts/pubhen.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 lolito/scripts/pubhen.py diff --git a/lolito/package.xml b/lolito/package.xml index 322108a..b9a4cc7 100644 --- a/lolito/package.xml +++ b/lolito/package.xml @@ -6,7 +6,9 @@ TODO: Package description roncanciovl TODO: License declaration - + + rclpy + std_msgs ament_cmake ament_lint_auto diff --git a/lolito/scripts/pubhen.py b/lolito/scripts/pubhen.py new file mode 100644 index 0000000..fff0ae1 --- /dev/null +++ b/lolito/scripts/pubhen.py @@ -0,0 +1,39 @@ +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() \ No newline at end of file From ca90f0c4457c646331da394b442d9c7ad2421c79 Mon Sep 17 00:00:00 2001 From: Raul Urdaneta Date: Thu, 16 Feb 2023 09:53:29 -0500 Subject: [PATCH 09/25] lolito commit 1 --- lolito/Scripts/pub-raul.py | 40 ++++++++++++++++++++++++++++++++++++++ lolito/package.xml | 3 +++ 2 files changed, 43 insertions(+) create mode 100644 lolito/Scripts/pub-raul.py diff --git a/lolito/Scripts/pub-raul.py b/lolito/Scripts/pub-raul.py new file mode 100644 index 0000000..465a662 --- /dev/null +++ b/lolito/Scripts/pub-raul.py @@ -0,0 +1,40 @@ +#amigo bless kchon + +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 = 'Bless kchon %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() \ No newline at end of file diff --git a/lolito/package.xml b/lolito/package.xml index 322108a..ca9915a 100644 --- a/lolito/package.xml +++ b/lolito/package.xml @@ -7,6 +7,9 @@ roncanciovl TODO: License declaration + rclpy + std_msgs + ament_cmake ament_lint_auto From f99394a7ff52fa78aab2d39512e67a55edec4c2d Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Tue, 28 Feb 2023 06:35:07 -0800 Subject: [PATCH 10/25] Settings in environment --- README.md | 38 ++++++++++++++++ henry_pkg/henry_pkg/__init__.py | 0 henry_pkg/henry_pkg/fis.py | 33 ++++++++++++++ henry_pkg/henry_pkg/my_pub.py | 39 ++++++++++++++++ henry_pkg/package.xml | 21 +++++++++ henry_pkg/resource/henry_pkg | 0 henry_pkg/setup.cfg | 4 ++ henry_pkg/setup.py | 26 +++++++++++ henry_pkg/test/test_copyright.py | 23 ++++++++++ henry_pkg/test/test_flake8.py | 25 +++++++++++ henry_pkg/test/test_pep257.py | 23 ++++++++++ lolito/CMakeLists.txt | 12 +++++ lolito/lolito/__init__.py | 0 lolito/lolito/scripts/pubhen.py | 42 ++++++++++++++++++ lolito/package.xml | 5 ++- lolito/scripts/__init__.py | 0 requirements.txt | 76 ++++++++++++++++++++++++++++++++ 17 files changed, 365 insertions(+), 2 deletions(-) create mode 100644 henry_pkg/henry_pkg/__init__.py create mode 100644 henry_pkg/henry_pkg/fis.py create mode 100644 henry_pkg/henry_pkg/my_pub.py create mode 100644 henry_pkg/package.xml create mode 100644 henry_pkg/resource/henry_pkg create mode 100644 henry_pkg/setup.cfg create mode 100644 henry_pkg/setup.py create mode 100644 henry_pkg/test/test_copyright.py create mode 100644 henry_pkg/test/test_flake8.py create mode 100644 henry_pkg/test/test_pep257.py create mode 100644 lolito/lolito/__init__.py create mode 100755 lolito/lolito/scripts/pubhen.py create mode 100644 lolito/scripts/__init__.py create mode 100644 requirements.txt diff --git a/README.md b/README.md index 2efc043..b7446b8 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,44 @@ source /opt/ros/foxy/setup.bash ``` +## Virtual Environment Setup in Linux + +https://docs.ros.org/en/foxy/How-To-Guides/Using-Python-Packages.html + +```shell script +sudo apt install python3-pip +``` + +```shell script +sudo apt install python3-virtualenv +``` +### Make a virtual env and activate it + +From your workspace directory run this command + +```shell script +virtualenv -p python3 ./venv +``` +```shell script +source ./venv/bin/activate +``` + +Make sure that colcon doesn’t try to build the venv +```shell script +touch ./venv/COLCON_IGNORE +``` + + +Next, install the Python packages that you want in your virtual environment: + +if any requirement file is in the src folder, then install them for command line + +```shell script +pip install -r src/requirements.txt +``` + +Now you can build your workspace and run your python node that depends on packages installed in your virtual environment. + ## Source Control Recommendations diff --git a/henry_pkg/henry_pkg/__init__.py b/henry_pkg/henry_pkg/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/henry_pkg/henry_pkg/fis.py b/henry_pkg/henry_pkg/fis.py new file mode 100644 index 0000000..cebfbda --- /dev/null +++ b/henry_pkg/henry_pkg/fis.py @@ -0,0 +1,33 @@ +import numpy as np +import skfuzzy as fuzz +from skfuzzy import control as ctrl + +# New Antecedent/Consequent objects hold universe variables and membership +# functions +quality = ctrl.Antecedent(np.arange(0, 11, 1), 'quality') +service = ctrl.Antecedent(np.arange(0, 11, 1), 'service') +tip = ctrl.Consequent(np.arange(0, 26, 1), 'tip') + +# Auto-membership function population is possible with .automf(3, 5, or 7) +quality.automf(3) +service.automf(3) + +# Custom membership functions can be built interactively with a familiar, +# Pythonic API +tip['low'] = fuzz.trimf(tip.universe, [0, 0, 13]) +tip['medium'] = fuzz.trimf(tip.universe, [0, 13, 25]) +tip['high'] = fuzz.trimf(tip.universe, [13, 25, 25]) + +rule1 = ctrl.Rule(quality['poor'] | service['poor'], tip['low']) +rule2 = ctrl.Rule(service['average'], tip['medium']) +rule3 = ctrl.Rule(service['good'] | quality['good'], tip['high']) + +rule1.view() + +tipping_ctrl = ctrl.ControlSystem([rule1, rule2, rule3]) + +def main(args=None): + print() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/henry_pkg/henry_pkg/my_pub.py b/henry_pkg/henry_pkg/my_pub.py new file mode 100644 index 0000000..fff0ae1 --- /dev/null +++ b/henry_pkg/henry_pkg/my_pub.py @@ -0,0 +1,39 @@ +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() \ No newline at end of file diff --git a/henry_pkg/package.xml b/henry_pkg/package.xml new file mode 100644 index 0000000..5bc66fc --- /dev/null +++ b/henry_pkg/package.xml @@ -0,0 +1,21 @@ + + + + henry_pkg + 0.0.0 + TODO: Package description + roncanciovl + Apache License 2.0 + + rclpy + std_msgs + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/henry_pkg/resource/henry_pkg b/henry_pkg/resource/henry_pkg new file mode 100644 index 0000000..e69de29 diff --git a/henry_pkg/setup.cfg b/henry_pkg/setup.cfg new file mode 100644 index 0000000..6beb4db --- /dev/null +++ b/henry_pkg/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script-dir=$base/lib/henry_pkg +[install] +install-scripts=$base/lib/henry_pkg diff --git a/henry_pkg/setup.py b/henry_pkg/setup.py new file mode 100644 index 0000000..cf51f02 --- /dev/null +++ b/henry_pkg/setup.py @@ -0,0 +1,26 @@ +from setuptools import setup + +package_name = 'henry_pkg' + +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='roncanciovl', + maintainer_email='henryroncanciovelandia@gmail.com', + description='TODO: Package description', + license='Apache License 2.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'talker = henry_pkg.my_pub:main', + ], + }, +) diff --git a/henry_pkg/test/test_copyright.py b/henry_pkg/test/test_copyright.py new file mode 100644 index 0000000..cc8ff03 --- /dev/null +++ b/henry_pkg/test/test_copyright.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_copyright.main import main +import pytest + + +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/henry_pkg/test/test_flake8.py b/henry_pkg/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/henry_pkg/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/henry_pkg/test/test_pep257.py b/henry_pkg/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/henry_pkg/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/lolito/CMakeLists.txt b/lolito/CMakeLists.txt index b7d1cb2..0d8df9a 100644 --- a/lolito/CMakeLists.txt +++ b/lolito/CMakeLists.txt @@ -17,6 +17,18 @@ endif() # find dependencies find_package(ament_cmake REQUIRED) +find_package(ament_cmake_python REQUIRED) +find_package(rclpy REQUIRED) +find_package(std_msgs REQUIRED) + +ament_python_install_package(${PROJECT_NAME}) + +install(PROGRAMS + lolito/scripts/pubhen.py + DESTINATION lib/${PROJECT_NAME} +) + + # uncomment the following section in order to fill in # further dependencies manually. # find_package( REQUIRED) diff --git a/lolito/lolito/__init__.py b/lolito/lolito/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lolito/lolito/scripts/pubhen.py b/lolito/lolito/scripts/pubhen.py new file mode 100755 index 0000000..65e1fad --- /dev/null +++ b/lolito/lolito/scripts/pubhen.py @@ -0,0 +1,42 @@ + +#!/home/roncanciovl/ros2class_ws/venv/bin/python3 + +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() \ No newline at end of file diff --git a/lolito/package.xml b/lolito/package.xml index b9a4cc7..59c8ed8 100644 --- a/lolito/package.xml +++ b/lolito/package.xml @@ -7,10 +7,11 @@ roncanciovl TODO: License declaration + ament_cmake + ament_cmake_python rclpy std_msgs - ament_cmake - + ament_lint_auto ament_lint_common diff --git a/lolito/scripts/__init__.py b/lolito/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a504033 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,76 @@ +action-tutorials-py==0.9.4 +ament-copyright==0.9.7 +ament-cppcheck==0.9.7 +ament-cpplint==0.9.7 +ament-flake8==0.9.7 +ament-index-python==1.1.0 +ament-lint==0.9.7 +ament-lint-cmake==0.9.7 +ament-package==0.9.5 +ament-pep257==0.9.7 +ament-uncrustify==0.9.7 +ament-xmllint==0.9.7 +demo-nodes-py==0.9.4 +domain-coordinator==0.9.2 +examples-rclpy-executors==0.9.4 +examples-rclpy-minimal-action-client==0.9.4 +examples-rclpy-minimal-action-server==0.9.4 +examples-rclpy-minimal-client==0.9.4 +examples-rclpy-minimal-publisher==0.9.4 +examples-rclpy-minimal-service==0.9.4 +examples-rclpy-minimal-subscriber==0.9.4 +henry-pkg==0.0.0 +launch==0.10.10 +launch-ros==0.11.7 +launch-testing==0.10.10 +launch-testing-ros==0.11.7 +launch-xml==0.10.10 +launch-yaml==0.10.10 +networkx==3.0 +numpy==1.24.2 +osrf-pycommon==0.1.11 +quality-of-service-demo-py==0.9.4 +ros2action==0.9.12 +ros2bag==0.3.9 +ros2cli==0.9.12 +ros2component==0.9.12 +ros2doctor==0.9.12 +ros2interface==0.9.12 +ros2launch==0.11.7 +ros2lifecycle==0.9.12 +ros2multicast==0.9.12 +ros2node==0.9.12 +ros2param==0.9.12 +ros2pkg==0.9.12 +ros2run==0.9.12 +ros2service==0.9.12 +ros2topic==0.9.12 +rosidl-runtime-py==0.9.1 +rpyutils==0.2.0 +rqt==1.1.2 +rqt-action==0.4.9 +rqt-console==1.1.2 +rqt-graph==1.1.3 +rqt-gui==1.1.2 +rqt-gui-py==1.1.2 +rqt-moveit==1.0.1 +rqt-msg==1.0.5 +rqt-plot==1.1.1 +rqt-publisher==1.3.0 +rqt-py-console==1.0.2 +rqt-reconfigure==1.0.8 +rqt-robot-dashboard==0.5.8 +rqt-robot-monitor==1.0.5 +rqt-robot-steering==1.0.0 +rqt-runtime-monitor==1.0.0 +rqt-service-caller==1.0.5 +rqt-shell==1.0.2 +rqt-srv==1.0.3 +rqt-tf-tree==1.0.2 +rqt-top==1.0.2 +rqt-topic==1.3.0 +scikit-fuzzy==0.4.2 +scipy==1.10.1 +sros2==0.9.5 +teleop-twist-keyboard==2.3.2 +topic-monitor==0.9.4 From 439eb57c07e35b9cb4612fe9654165ee05ca5e9e Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Tue, 28 Feb 2023 06:36:10 -0800 Subject: [PATCH 11/25] Change location in files --- lolito/scripts/__init__.py | 0 lolito/scripts/pubhen.py | 39 -------------------------------------- 2 files changed, 39 deletions(-) delete mode 100644 lolito/scripts/__init__.py delete mode 100644 lolito/scripts/pubhen.py diff --git a/lolito/scripts/__init__.py b/lolito/scripts/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/lolito/scripts/pubhen.py b/lolito/scripts/pubhen.py deleted file mode 100644 index fff0ae1..0000000 --- a/lolito/scripts/pubhen.py +++ /dev/null @@ -1,39 +0,0 @@ -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() \ No newline at end of file From aa22d8acb94ff57dec4c4baf8d0705bceaa3c194 Mon Sep 17 00:00:00 2001 From: Raul Urdaneta Date: Wed, 1 Mar 2023 16:47:29 -0500 Subject: [PATCH 12/25] alo --- lolito/CMakeLists.txt | 10 +++++++++ lolito/Scripts/__init__.py | 0 lolito/Scripts/pub-raul.py | 3 ++- lolito/package.xml | 5 +++-- raul_pkg/package.xml | 21 ++++++++++++++++++ raul_pkg/raul_pkg/__init__.py | 0 raul_pkg/raul_pkg/pub_raul.py | 39 +++++++++++++++++++++++++++++++++ raul_pkg/raul_pkg/sub_raul.py | 37 +++++++++++++++++++++++++++++++ raul_pkg/resource/raul_pkg | 0 raul_pkg/setup.cfg | 4 ++++ raul_pkg/setup.py | 27 +++++++++++++++++++++++ raul_pkg/test/test_copyright.py | 23 +++++++++++++++++++ raul_pkg/test/test_flake8.py | 25 +++++++++++++++++++++ raul_pkg/test/test_pep257.py | 23 +++++++++++++++++++ 14 files changed, 214 insertions(+), 3 deletions(-) create mode 100644 lolito/Scripts/__init__.py create mode 100644 raul_pkg/package.xml create mode 100644 raul_pkg/raul_pkg/__init__.py create mode 100644 raul_pkg/raul_pkg/pub_raul.py create mode 100644 raul_pkg/raul_pkg/sub_raul.py create mode 100644 raul_pkg/resource/raul_pkg create mode 100644 raul_pkg/setup.cfg create mode 100644 raul_pkg/setup.py create mode 100644 raul_pkg/test/test_copyright.py create mode 100644 raul_pkg/test/test_flake8.py create mode 100644 raul_pkg/test/test_pep257.py diff --git a/lolito/CMakeLists.txt b/lolito/CMakeLists.txt index b7d1cb2..69d94d8 100644 --- a/lolito/CMakeLists.txt +++ b/lolito/CMakeLists.txt @@ -17,6 +17,16 @@ endif() # find dependencies find_package(ament_cmake REQUIRED) +find_package(ament_cmake_python REQUIRED) +find_package(rclpy REQUIRED) +find_package(std_msgs REQUIRED) + +ament_python_install_package(Scripts/) + +install(PROGRAMS + Scripts/pub-raul.py + DESTINATION lib/${PROJECT_NAME} +) # uncomment the following section in order to fill in # further dependencies manually. # find_package( REQUIRED) diff --git a/lolito/Scripts/__init__.py b/lolito/Scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lolito/Scripts/pub-raul.py b/lolito/Scripts/pub-raul.py index 465a662..89ca552 100644 --- a/lolito/Scripts/pub-raul.py +++ b/lolito/Scripts/pub-raul.py @@ -1,4 +1,5 @@ -#amigo bless kchon +#!usr/bin/env python3 + import rclpy from rclpy.node import Node diff --git a/lolito/package.xml b/lolito/package.xml index ca9915a..cb09290 100644 --- a/lolito/package.xml +++ b/lolito/package.xml @@ -7,10 +7,11 @@ roncanciovl TODO: License declaration - rclpy - std_msgs ament_cmake + ament_cmake_python + rclpy + std_msgs ament_lint_auto ament_lint_common diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml new file mode 100644 index 0000000..00d62cd --- /dev/null +++ b/raul_pkg/package.xml @@ -0,0 +1,21 @@ + + + + raul_pkg + 0.0.0 + TODO: Package description + raul + Apache License 2.0 + + rclpy + std_msgs + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/raul_pkg/raul_pkg/__init__.py b/raul_pkg/raul_pkg/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/raul_pkg/raul_pkg/pub_raul.py b/raul_pkg/raul_pkg/pub_raul.py new file mode 100644 index 0000000..fff0ae1 --- /dev/null +++ b/raul_pkg/raul_pkg/pub_raul.py @@ -0,0 +1,39 @@ +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() \ No newline at end of file diff --git a/raul_pkg/raul_pkg/sub_raul.py b/raul_pkg/raul_pkg/sub_raul.py new file mode 100644 index 0000000..90b6807 --- /dev/null +++ b/raul_pkg/raul_pkg/sub_raul.py @@ -0,0 +1,37 @@ +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() \ No newline at end of file diff --git a/raul_pkg/resource/raul_pkg b/raul_pkg/resource/raul_pkg new file mode 100644 index 0000000..e69de29 diff --git a/raul_pkg/setup.cfg b/raul_pkg/setup.cfg new file mode 100644 index 0000000..8ca868b --- /dev/null +++ b/raul_pkg/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script-dir=$base/lib/raul_pkg +[install] +install-scripts=$base/lib/raul_pkg diff --git a/raul_pkg/setup.py b/raul_pkg/setup.py new file mode 100644 index 0000000..0917f9c --- /dev/null +++ b/raul_pkg/setup.py @@ -0,0 +1,27 @@ +from setuptools import setup + +package_name = 'raul_pkg' + +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='raul', + maintainer_email='alvaroraulurdanetag@gmail.com', + description='TODO: Package description', + license='Apache License 2.0', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'talker = raul_pkg.pub_raul:main', + 'listener = raul_pkg.sub_raul:main', + ], + }, +) diff --git a/raul_pkg/test/test_copyright.py b/raul_pkg/test/test_copyright.py new file mode 100644 index 0000000..cc8ff03 --- /dev/null +++ b/raul_pkg/test/test_copyright.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_copyright.main import main +import pytest + + +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/raul_pkg/test/test_flake8.py b/raul_pkg/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/raul_pkg/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/raul_pkg/test/test_pep257.py b/raul_pkg/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/raul_pkg/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' From c64bd45ae084dd51f9a5fa2509a46b6492a60aaf Mon Sep 17 00:00:00 2001 From: Carlos Reyes Date: Wed, 8 Mar 2023 16:36:51 -0500 Subject: [PATCH 13/25] a --- raul_pkg/raul_pkg/sub_raul.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raul_pkg/raul_pkg/sub_raul.py b/raul_pkg/raul_pkg/sub_raul.py index 90b6807..5ac9507 100644 --- a/raul_pkg/raul_pkg/sub_raul.py +++ b/raul_pkg/raul_pkg/sub_raul.py @@ -7,7 +7,7 @@ class MinimalSubscriber(Node): def __init__(self): - super().__init__('minimal_subscriber') + super().__init__('') self.subscription = self.create_subscription( String, 'topic', From 53a2db678b2e24ae03808bf6d09391795fd66507 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 9 Mar 2023 09:50:04 -0500 Subject: [PATCH 14/25] commit rpm2ls --- launch/python_parameters_launch.py | 16 ++++++++++++ raul_pkg/raul_pkg/pub_rpm.py | 39 ++++++++++++++++++++++++++++++ raul_pkg/raul_pkg/rpm2ls.py | 39 ++++++++++++++++++++++++++++++ raul_pkg/setup.py | 2 ++ 4 files changed, 96 insertions(+) create mode 100644 launch/python_parameters_launch.py create mode 100644 raul_pkg/raul_pkg/pub_rpm.py create mode 100644 raul_pkg/raul_pkg/rpm2ls.py diff --git a/launch/python_parameters_launch.py b/launch/python_parameters_launch.py new file mode 100644 index 0000000..ac990f4 --- /dev/null +++ b/launch/python_parameters_launch.py @@ -0,0 +1,16 @@ +from launch import LaunchDescription +from launch_ros.actions import Node + +def generate_launch_description(): + return LaunchDescription([ + Node( + package='raul_pkg', + executable='rpm2ls', + name='lineal_speed_joaquin', + output='screen', + emulate_tty=True, + parameters=[ + {'my_parameter': 'earth'} + ] + ) + ]) \ No newline at end of file diff --git a/raul_pkg/raul_pkg/pub_rpm.py b/raul_pkg/raul_pkg/pub_rpm.py new file mode 100644 index 0000000..1114778 --- /dev/null +++ b/raul_pkg/raul_pkg/pub_rpm.py @@ -0,0 +1,39 @@ +import rclpy +from rclpy.node import Node + +from std_msgs.msg import String + + +class MinimalPublisher(Node): + + def __init__(self): + super().__init__('Nodo_Raul') + self.publisher_ = self.create_publisher(String, 'RPM', 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 = str(3) + 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() \ No newline at end of file diff --git a/raul_pkg/raul_pkg/rpm2ls.py b/raul_pkg/raul_pkg/rpm2ls.py new file mode 100644 index 0000000..e9b3755 --- /dev/null +++ b/raul_pkg/raul_pkg/rpm2ls.py @@ -0,0 +1,39 @@ +import rclpy +from rclpy.node import Node +from std_msgs.msg import String + +WHEEL_RADIUS = 5 #en cm + +class MyNode(Node): + + def __init__(self): + super().__init__('node_lineal_speed') + self.declare_parameter('radius',WHEEL_RADIUS) + self.publisher_ = self.create_publisher(String, 'lineal_speed', 10) + self.subscription = self.create_subscription( + String, + 'RPM', + self.listener_callback, + 10) + self.subscription # prevent unused variable warning + + def listener_callback(self, msg): + #self.get_logger().info('I heard: "%s"' % msg.data) + radio = self.get_parameter('radius').value + numin=(float(msg.data)/60)*2*3.141516*radio + print(numin) + msg.data=str(numin) + self.publisher_.publish(msg) + +def main(args=None): + rclpy.init(args=args) + + my_node = MyNode() + + rclpy.spin(my_node) + + my_node.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() diff --git a/raul_pkg/setup.py b/raul_pkg/setup.py index 0917f9c..abe411e 100644 --- a/raul_pkg/setup.py +++ b/raul_pkg/setup.py @@ -22,6 +22,8 @@ 'console_scripts': [ 'talker = raul_pkg.pub_raul:main', 'listener = raul_pkg.sub_raul:main', + 'rpm2ls = raul_pkg.rpm2ls:main', + 'rpmpub = raul_pkg.pub_rpm:main' ], }, ) From a9eb53b4a7a31f3d896b1a700f97448852518aca Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 9 Mar 2023 10:06:32 -0500 Subject: [PATCH 15/25] alo --- {launch => raul_pkg/launch}/python_parameters_launch.py | 4 ++-- raul_pkg/setup.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) rename {launch => raul_pkg/launch}/python_parameters_launch.py (87%) diff --git a/launch/python_parameters_launch.py b/raul_pkg/launch/python_parameters_launch.py similarity index 87% rename from launch/python_parameters_launch.py rename to raul_pkg/launch/python_parameters_launch.py index ac990f4..e6831e1 100644 --- a/launch/python_parameters_launch.py +++ b/raul_pkg/launch/python_parameters_launch.py @@ -10,7 +10,7 @@ def generate_launch_description(): output='screen', emulate_tty=True, parameters=[ - {'my_parameter': 'earth'} + {'radius': 0.5} ] - ) + ) ]) \ No newline at end of file diff --git a/raul_pkg/setup.py b/raul_pkg/setup.py index abe411e..d3ebf01 100644 --- a/raul_pkg/setup.py +++ b/raul_pkg/setup.py @@ -1,4 +1,6 @@ from setuptools import setup +import os +from glob import glob package_name = 'raul_pkg' @@ -7,6 +9,7 @@ version='0.0.0', packages=[package_name], data_files=[ + (os.path.join('share', package_name), glob('launch/*launch.[pxy][yma]*')), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ('share/' + package_name, ['package.xml']), From 7366e7f3c61eb0640593456de48ba64785f0573e Mon Sep 17 00:00:00 2001 From: Raul Date: Wed, 15 Mar 2023 10:57:24 -0500 Subject: [PATCH 16/25] con params --- raul_pkg/launch/python_parameters_launch.py | 22 ++++++++++++++++++++- raul_pkg/package.xml | 1 + raul_pkg/raul_pkg/pub_rpm.py | 9 ++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/raul_pkg/launch/python_parameters_launch.py b/raul_pkg/launch/python_parameters_launch.py index e6831e1..8b1831b 100644 --- a/raul_pkg/launch/python_parameters_launch.py +++ b/raul_pkg/launch/python_parameters_launch.py @@ -12,5 +12,25 @@ def generate_launch_description(): parameters=[ {'radius': 0.5} ] - ) + ), + Node( + package='raul_pkg', + executable='rpm2ls', + name='lineal_speed_juan', + output='screen', + emulate_tty=True, + parameters=[ + {'radius': 0.3} + ] + ), + Node( + package='raul_pkg', + executable='rpmpub', + name='rpm_pub', + output='screen', + emulate_tty=True, + parameters=[ + {'rpms':5} + ] + ) ]) \ No newline at end of file diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml index 00d62cd..be97c6d 100644 --- a/raul_pkg/package.xml +++ b/raul_pkg/package.xml @@ -9,6 +9,7 @@ rclpy std_msgs + ros2launch ament_copyright ament_flake8 diff --git a/raul_pkg/raul_pkg/pub_rpm.py b/raul_pkg/raul_pkg/pub_rpm.py index 1114778..d4bb6d2 100644 --- a/raul_pkg/raul_pkg/pub_rpm.py +++ b/raul_pkg/raul_pkg/pub_rpm.py @@ -3,19 +3,22 @@ from std_msgs.msg import String +RPMS = 3 class MinimalPublisher(Node): def __init__(self): - super().__init__('Nodo_Raul') + super().__init__('Nodo_RPM') + self.declare_parameter('rpms',RPMS) self.publisher_ = self.create_publisher(String, 'RPM', 10) - timer_period = 0.5 # seconds + timer_period = 1 # seconds self.timer = self.create_timer(timer_period, self.timer_callback) self.i = 0 def timer_callback(self): + rpmenv = self.get_parameter('rpms').value msg = String() - msg.data = str(3) + msg.data = str(rpmenv) self.publisher_.publish(msg) self.get_logger().info('Publishing: "%s"' % msg.data) self.i += 1 From 4cd5bfdc01b1663d09ba8ac87a344a74780e3826 Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Wed, 15 Mar 2023 14:52:54 -0700 Subject: [PATCH 17/25] Added sub cahnges --- raul_pkg/raul_pkg/sub_raul.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raul_pkg/raul_pkg/sub_raul.py b/raul_pkg/raul_pkg/sub_raul.py index 5ac9507..1e546d4 100644 --- a/raul_pkg/raul_pkg/sub_raul.py +++ b/raul_pkg/raul_pkg/sub_raul.py @@ -7,10 +7,10 @@ class MinimalSubscriber(Node): def __init__(self): - super().__init__('') + super().__init__('node_Raul') self.subscription = self.create_subscription( String, - 'topic', + 'lineal_speed', self.listener_callback, 10) self.subscription # prevent unused variable warning From ee5ce8001811616cd2e6ba3640081349edaa2136 Mon Sep 17 00:00:00 2001 From: Henry Roncancio Date: Wed, 15 Mar 2023 22:10:38 -0700 Subject: [PATCH 18/25] Created pkg lolito_interfaces --- henry_pkg/henry_pkg/server.py | 55 ++++++++++++++++++++++++++ henry_pkg/package.xml | 9 +++++ henry_pkg/setup.py | 1 + lolito_interfaces/CMakeLists.txt | 44 +++++++++++++++++++++ lolito_interfaces/package.xml | 26 ++++++++++++ lolito_interfaces/srv/CaptureImage.srv | 3 ++ 6 files changed, 138 insertions(+) create mode 100644 henry_pkg/henry_pkg/server.py create mode 100644 lolito_interfaces/CMakeLists.txt create mode 100644 lolito_interfaces/package.xml create mode 100644 lolito_interfaces/srv/CaptureImage.srv diff --git a/henry_pkg/henry_pkg/server.py b/henry_pkg/henry_pkg/server.py new file mode 100644 index 0000000..cfd482f --- /dev/null +++ b/henry_pkg/henry_pkg/server.py @@ -0,0 +1,55 @@ +import rclpy +from rclpy.node import Node +from sensor_msgs.msg import Image +from lolito_interfaces.srv import CaptureImage + + +class ImageCaptureServer(Node): + def __init__(self): + super().__init__('image_capture_server') + self.srv = self.create_service(CaptureImage, 'capture_image', self.capture_image_callback) + + def capture_image_callback(self, request, response): + # Aquí es donde capturamos la imagen y la enviamos como respuesta + image = self.capture_image() + response.image = image + return response + + def capture_image(self): + # En este ejemplo, utilizamos la biblioteca OpenCV para capturar la imagen + import cv2 + + # Capturamos la imagen de la cámara web + cap = cv2.VideoCapture(0) + _, frame = cap.read() + + # Convertimos la imagen capturada a un mensaje ROS + msg = Image() + msg.header.frame_id = 'camera' + msg.encoding = 'bgr8' + msg.height, msg.width, _ = frame.shape + msg.step = 3 * msg.width + msg.data = frame.tobytes() + + # Liberamos la cámara web + cap.release() + + return msg + + +def main(args=None): + rclpy.init(args=args) + + node = ImageCaptureServer() + + try: + rclpy.spin(node) + except KeyboardInterrupt: + pass + + node.destroy_node() + rclpy.shutdown() + + +if __name__ == '__main__': + main() diff --git a/henry_pkg/package.xml b/henry_pkg/package.xml index 5bc66fc..abad098 100644 --- a/henry_pkg/package.xml +++ b/henry_pkg/package.xml @@ -9,8 +9,17 @@ rclpy std_msgs + sensor_msgs + example_interfaces + + rosidl_default_generators + rosidl_default_runtime + rosidl_interface_packages + + ament_copyright + ament_flake8 ament_pep257 python3-pytest diff --git a/henry_pkg/setup.py b/henry_pkg/setup.py index cf51f02..a3dc297 100644 --- a/henry_pkg/setup.py +++ b/henry_pkg/setup.py @@ -21,6 +21,7 @@ entry_points={ 'console_scripts': [ 'talker = henry_pkg.my_pub:main', + 'imageServer = henry_pkg.server:main', ], }, ) diff --git a/lolito_interfaces/CMakeLists.txt b/lolito_interfaces/CMakeLists.txt new file mode 100644 index 0000000..aef6e8c --- /dev/null +++ b/lolito_interfaces/CMakeLists.txt @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.5) +project(lolito_interfaces) + +# Default to C99 +if(NOT CMAKE_C_STANDARD) + set(CMAKE_C_STANDARD 99) +endif() + +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +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) +find_package(sensor_msgs REQUIRED) +find_package(rosidl_default_generators REQUIRED) + +rosidl_generate_interfaces(${PROJECT_NAME} + "srv/CaptureImage.srv" + DEPENDENCIES sensor_msgs # Add packages that above messages depend on, in this case geometry_msgs for Sphere.msg +) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +ament_export_dependencies(rosidl_default_runtime) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # uncomment the line when a copyright and license is not present in all source files + #set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # uncomment the line when this package is not in a git repo + #set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() diff --git a/lolito_interfaces/package.xml b/lolito_interfaces/package.xml new file mode 100644 index 0000000..d5e7244 --- /dev/null +++ b/lolito_interfaces/package.xml @@ -0,0 +1,26 @@ + + + + lolito_interfaces + 0.0.0 + TODO: Package description + roncanciovl + TODO: License declaration + ament_cmake + sensor_msgs + + rosidl_default_generators + + rosidl_default_runtime + + rosidl_interface_packages + + + + ament_lint_auto + ament_lint_common + + + ament_cmake + + diff --git a/lolito_interfaces/srv/CaptureImage.srv b/lolito_interfaces/srv/CaptureImage.srv new file mode 100644 index 0000000..f0cd11e --- /dev/null +++ b/lolito_interfaces/srv/CaptureImage.srv @@ -0,0 +1,3 @@ +bool req +--- +sensor_msgs/Image my_image \ No newline at end of file From 93dc2f8059b0045d30aa7451b658d53027ddc7d3 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 16 Mar 2023 08:26:25 -0500 Subject: [PATCH 19/25] alo2 --- raul_pkg/package.xml | 9 +++++++++ raul_pkg/raul_pkg/server.py | 27 +++++++++++++++++++++++++++ raul_pkg/setup.py | 3 ++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 raul_pkg/raul_pkg/server.py diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml index be97c6d..4e468ac 100644 --- a/raul_pkg/package.xml +++ b/raul_pkg/package.xml @@ -11,6 +11,15 @@ std_msgs ros2launch + cv_bridge + cv_bridge + image_transport + image_transport + sensor_msgs + sensor_msgs + OpenCV + OpenCVs + ament_copyright ament_flake8 ament_pep257 diff --git a/raul_pkg/raul_pkg/server.py b/raul_pkg/raul_pkg/server.py new file mode 100644 index 0000000..0eea00e --- /dev/null +++ b/raul_pkg/raul_pkg/server.py @@ -0,0 +1,27 @@ +import rclpy +from rclpy.node import Node +from sensor_msgs.msg import Image +from cv_bridge import CvBridge +import cv2 + +class ImageServer(Node): + def __init__(self): + super().__init__('image_server') + self.srv = self.create_service(Image, 'image', self.request_callback) + self.bridge = CvBridge() + self.capture = cv2.VideoCapture(0) + + def request_callback(self, request, response): + ret, frame = self.capture.read() + response = self.bridge.cv2_to_imgmsg(frame, "bgr8") + return response + +def main(args=None): + rclpy.init(args=args) + image_server = ImageServer() + rclpy.spin(image_server) + image_server.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/raul_pkg/setup.py b/raul_pkg/setup.py index d3ebf01..f15368f 100644 --- a/raul_pkg/setup.py +++ b/raul_pkg/setup.py @@ -26,7 +26,8 @@ 'talker = raul_pkg.pub_raul:main', 'listener = raul_pkg.sub_raul:main', 'rpm2ls = raul_pkg.rpm2ls:main', - 'rpmpub = raul_pkg.pub_rpm:main' + 'rpmpub = raul_pkg.pub_rpm:main', + 'server = raul_pkg.server:main' ], }, ) From 60bd75b6650b369b25eeb23aa5f6db7582ccae06 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 16 Mar 2023 09:31:10 -0500 Subject: [PATCH 20/25] alo --- raul_pkg/package.xml | 2 ++ raul_pkg/raul_pkg/server.py | 56 +++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 14 deletions(-) diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml index 4e468ac..2c837d1 100644 --- a/raul_pkg/package.xml +++ b/raul_pkg/package.xml @@ -10,6 +10,8 @@ rclpy std_msgs ros2launch + sensor_msgs + llito_interfaces cv_bridge cv_bridge diff --git a/raul_pkg/raul_pkg/server.py b/raul_pkg/raul_pkg/server.py index 0eea00e..9e60d23 100644 --- a/raul_pkg/raul_pkg/server.py +++ b/raul_pkg/raul_pkg/server.py @@ -1,27 +1,55 @@ import rclpy from rclpy.node import Node from sensor_msgs.msg import Image -from cv_bridge import CvBridge -import cv2 +from lolito_interfaces.srv import CaptureImage -class ImageServer(Node): + +class ImageCaptureServer(Node): def __init__(self): - super().__init__('image_server') - self.srv = self.create_service(Image, 'image', self.request_callback) - self.bridge = CvBridge() - self.capture = cv2.VideoCapture(0) - - def request_callback(self, request, response): - ret, frame = self.capture.read() - response = self.bridge.cv2_to_imgmsg(frame, "bgr8") + super().__init__('image_capture_server') + self.srv = self.create_service(CaptureImage, 'capture_image', self.capture_image_callback) + + def capture_image_callback(self, request, response): + # Aquí es donde capturamos la imagen y la enviamos como respuesta + image = self.capture_image() + response.image = image return response + def capture_image(self): + # En este ejemplo, utilizamos la biblioteca OpenCV para capturar la imagen + import cv2 + + # Capturamos la imagen de la cámara web + cap = cv2.VideoCapture(0) + _, frame = cap.read() + + # Convertimos la imagen capturada a un mensaje ROS + msg = Image() + msg.header.frame_id = 'camera' + msg.encoding = 'bgr8' + msg.height, msg.width, _ = frame.shape + msg.step = 3 * msg.width + msg.data = frame.tobytes() + + # Liberamos la cámara web + cap.release() + + return msg + + def main(args=None): rclpy.init(args=args) - image_server = ImageServer() - rclpy.spin(image_server) - image_server.destroy_node() + + node = ImageCaptureServer() + + try: + rclpy.spin(node) + except KeyboardInterrupt: + pass + + node.destroy_node() rclpy.shutdown() + if __name__ == '__main__': main() \ No newline at end of file From c004fc66b2fcca64f16c8783536ee05795d70664 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 16 Mar 2023 12:18:06 -0500 Subject: [PATCH 21/25] alo --- raul_pkg/raul_pkg/client.py | 38 +++++++++++++++++++++++++++++++++++++ raul_pkg/raul_pkg/server.py | 9 ++++++--- raul_pkg/setup.py | 3 ++- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 raul_pkg/raul_pkg/client.py diff --git a/raul_pkg/raul_pkg/client.py b/raul_pkg/raul_pkg/client.py new file mode 100644 index 0000000..9cc63b7 --- /dev/null +++ b/raul_pkg/raul_pkg/client.py @@ -0,0 +1,38 @@ +import rclpy +from lolito_interfaces.srv import CaptureImage +from sensor_msgs.msg import Image +import cv2 +from cv_bridge import CvBridge + +def send_request(node): + client = node.create_client(CaptureImage, 'capture_image') + image_sub = node.create_subscription(Image, 'capture_image', handle_image, 10) + req = CaptureImage.Request() + + while not client.wait_for_service(timeout_sec=1.0): + node.get_logger().info('Servicio no disponible, esperando...') + + future = client.call_async(req) + rclpy.spin_until_future_complete(node, future) + + if future.result() is not None: + node.get_logger().info('Respuesta: %d' % future.result().sum) + else: + node.get_logger().info('Error en la solicitud') + +def handle_image(msg): + bridge = CvBridge() + image = bridge.imgmsg_to_cv2(msg, desired_encoding='passthrough') + cv2.imshow('Imagen recibida', image) + cv2.waitKey(0) + pass + +def main(args=None): + rclpy.init(args=args) + node = rclpy.create_node('client_raul') + send_request(node) + node.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/raul_pkg/raul_pkg/server.py b/raul_pkg/raul_pkg/server.py index 9e60d23..3cd6140 100644 --- a/raul_pkg/raul_pkg/server.py +++ b/raul_pkg/raul_pkg/server.py @@ -11,9 +11,12 @@ def __init__(self): def capture_image_callback(self, request, response): # Aquí es donde capturamos la imagen y la enviamos como respuesta - image = self.capture_image() - response.image = image - return response + if (request.req == True): + image = self.capture_image() + response.image = image + return response + + def capture_image(self): # En este ejemplo, utilizamos la biblioteca OpenCV para capturar la imagen diff --git a/raul_pkg/setup.py b/raul_pkg/setup.py index f15368f..5e13f71 100644 --- a/raul_pkg/setup.py +++ b/raul_pkg/setup.py @@ -27,7 +27,8 @@ 'listener = raul_pkg.sub_raul:main', 'rpm2ls = raul_pkg.rpm2ls:main', 'rpmpub = raul_pkg.pub_rpm:main', - 'server = raul_pkg.server:main' + 'server = raul_pkg.server:main', + 'client = raul_pkg.client:main' ], }, ) From d756759d17ee7a04476e889788556077cf7e3a4f Mon Sep 17 00:00:00 2001 From: Raul Date: Wed, 22 Mar 2023 17:55:08 -0500 Subject: [PATCH 22/25] alo --- raul_pkg/package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml index 2c837d1..8dc3956 100644 --- a/raul_pkg/package.xml +++ b/raul_pkg/package.xml @@ -11,7 +11,7 @@ std_msgs ros2launch sensor_msgs - llito_interfaces + lolito_interfaces cv_bridge cv_bridge From ddbcccb6aca6ef0c7a0f987c36408b68ee23d9b0 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 23 Mar 2023 08:09:47 -0500 Subject: [PATCH 23/25] alo --- raul_pkg/package.xml | 2 -- raul_pkg/setup.py | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml index 8dc3956..4e468ac 100644 --- a/raul_pkg/package.xml +++ b/raul_pkg/package.xml @@ -10,8 +10,6 @@ rclpy std_msgs ros2launch - sensor_msgs - lolito_interfaces cv_bridge cv_bridge diff --git a/raul_pkg/setup.py b/raul_pkg/setup.py index 5e13f71..367111c 100644 --- a/raul_pkg/setup.py +++ b/raul_pkg/setup.py @@ -27,8 +27,7 @@ 'listener = raul_pkg.sub_raul:main', 'rpm2ls = raul_pkg.rpm2ls:main', 'rpmpub = raul_pkg.pub_rpm:main', - 'server = raul_pkg.server:main', - 'client = raul_pkg.client:main' + 'server = raul_pkg.server:main' ], }, -) +) \ No newline at end of file From af27a5fafb1a4c160a92ccdfb736d5a1c9d4f5c7 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 23 Mar 2023 08:14:24 -0500 Subject: [PATCH 24/25] alo --- raul_pkg/package.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/raul_pkg/package.xml b/raul_pkg/package.xml index 4e468ac..47215ec 100644 --- a/raul_pkg/package.xml +++ b/raul_pkg/package.xml @@ -7,10 +7,6 @@ raul Apache License 2.0 - rclpy - std_msgs - ros2launch - cv_bridge cv_bridge image_transport @@ -18,13 +14,17 @@ sensor_msgs sensor_msgs OpenCV - OpenCVs - + OpenCV + rclpy + std_msgs + ros2launch ament_copyright ament_flake8 ament_pep257 python3-pytest + lolito_interfaces + sensor_msgs ament_python From 144f2c7aee9cb3425d26f64f5e725d0cd4c6aa41 Mon Sep 17 00:00:00 2001 From: Raul Date: Thu, 23 Mar 2023 08:21:05 -0500 Subject: [PATCH 25/25] alo --- raul_pkg/raul_pkg/server.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/raul_pkg/raul_pkg/server.py b/raul_pkg/raul_pkg/server.py index 3cd6140..7c82e51 100644 --- a/raul_pkg/raul_pkg/server.py +++ b/raul_pkg/raul_pkg/server.py @@ -1,22 +1,22 @@ +#Create a node server to receive a message and capture photo and send to client +# Path: src/willy_pkg/willy_pkg/probar.py +# Compare this snippet from src/willy_pkg/willy_pkg/foto_servidor.py: + import rclpy from rclpy.node import Node from sensor_msgs.msg import Image from lolito_interfaces.srv import CaptureImage - class ImageCaptureServer(Node): def __init__(self): - super().__init__('image_capture_server') + super().__init__('willy_server') self.srv = self.create_service(CaptureImage, 'capture_image', self.capture_image_callback) def capture_image_callback(self, request, response): # Aquí es donde capturamos la imagen y la enviamos como respuesta - if (request.req == True): - image = self.capture_image() - response.image = image - return response - - + image = self.capture_image() + response.image = image + return response def capture_image(self): # En este ejemplo, utilizamos la biblioteca OpenCV para capturar la imagen @@ -52,7 +52,6 @@ def main(args=None): node.destroy_node() rclpy.shutdown() - - + if __name__ == '__main__': - main() \ No newline at end of file + main()