diff --git a/README.md b/README.md index 2efc043..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,92 +0,0 @@ -# Robot-over-ROS2 -Robot implementation using Robot Operating System V2 - -PUblisher/subscriber nodes -HOLA -Test on branches -HOLA alo123 - -pruebita lolo -alosito el mejor -\n \\ AmigoblesssOG -pruebita otra 2 - -Test on branches - - -## Setup - -Ref: https://docs.ros.org/en/foxy/Tutorials/Beginner-Client-Libraries/Creating-A-Workspace/Creating-A-Workspace.html - -1. Create a workspace folder in home -2. Create a new folder named src inside your workspace -3. Go to home in a terminal: - -```shell script -cd ~ -``` - -4. Go to src folder in your workspace. Change my_name_ws accordingly - -```shell script -cd my_name_ws/src/ -``` - -Clone without folder instructions> https://stackoverflow.com/questions/17581379/git-clone-without-project-folder - -command example: -```shell script -git clone https://github.com/roncanciovl/Robot-over-ROS2.git . -``` - -4. Resolve dependencies according to your distro -```shell script -cd .. -rosdep install -i --from-path src --rosdistro foxy -y -``` -Return: All required rosdeps installed successfully - -This may requiere before - -```shell script -sudo rosdep init -``` -```shell script -rosdep update -``` - -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 -``` - - - - -## Source Control Recommendations - - -2. For new features, create a new branch. Name it according to the feature. You may add it to the github repo. - - - - - -BUENOS DIAS :) -ADIOS -hola willy -HOla reyes diff --git a/launch/Nodos.launch.py b/launch/Nodos.launch.py new file mode 100644 index 0000000..ab950b9 --- /dev/null +++ b/launch/Nodos.launch.py @@ -0,0 +1,26 @@ +import launch +import launch_ros.actions +import launch_ros.substitutions + +def generate_launch_description(): + node1 = launch_ros.actions.Node( + package='peruano_pkg', + executable='Rpm', + name='nodo1' + ) + node2 = launch_ros.actions.Node( + package='peruano_pkg', + executable='SupPub', + name='nodo2' + ) + node3 = launch_ros.actions.Node( + package='peruano_pkg', + executable='LinSpeed', + name='nodo3' + ) + + return launch.LaunchDescription([ + node1, + node2, + node3 + ]) \ No newline at end of file diff --git a/launch/Tarea.launch.py b/launch/Tarea.launch.py new file mode 100644 index 0000000..d665ba8 --- /dev/null +++ b/launch/Tarea.launch.py @@ -0,0 +1,20 @@ +import launch +import launch_ros.actions +import launch_ros.substitutions + +def generate_launch_description(): + node1 = launch_ros.actions.Node( + package='peruano_pkg', + executable='P1E', + name='nodo1' + ) + node2 = launch_ros.actions.Node( + package='peruano_pkg', + executable='P1R', + name='nodo2' + ) + + return launch.LaunchDescription([ + node1, + node2 + ]) \ No newline at end of file diff --git a/lolito/CMakeLists.txt b/lolito/CMakeLists.txt index b7d1cb2..e69de29 100644 --- a/lolito/CMakeLists.txt +++ b/lolito/CMakeLists.txt @@ -1,35 +0,0 @@ -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 index 322108a..e69de29 100644 --- a/lolito/package.xml +++ b/lolito/package.xml @@ -1,18 +0,0 @@ - - - - lolito - 0.0.0 - TODO: Package description - roncanciovl - TODO: License declaration - - ament_cmake - - ament_lint_auto - ament_lint_common - - - ament_cmake - - diff --git a/lolito/scripts/__init__.py b/lolito/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lolito/scripts/pubhen.py b/lolito/scripts/pubhen.py new file mode 100644 index 0000000..e69de29 diff --git a/peruano_pkg/package.xml b/peruano_pkg/package.xml new file mode 100644 index 0000000..ea5d078 --- /dev/null +++ b/peruano_pkg/package.xml @@ -0,0 +1,30 @@ + + + + peruano_pkg + 0.0.0 + TODO: Package description + jackson + TODO: License declaration + + rclpy + std_msgs + + cv_bridge + cv_bridge + image_transport + image_transport + sensor_msgs + sensor_msgs + OpenCV + OpenCV + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/peruano_pkg/peruano_pkg/P_EnviarFoto.py b/peruano_pkg/peruano_pkg/P_EnviarFoto.py new file mode 100644 index 0000000..9f31795 --- /dev/null +++ b/peruano_pkg/peruano_pkg/P_EnviarFoto.py @@ -0,0 +1,34 @@ +import cv2 +import numpy as np +import rclpy +from rclpy.node import Node +from sensor_msgs.msg import Image +from cv_bridge import CvBridge + +class ImagePublisher(Node): + + def _init_(self): + super()._init_('chamito') + self.publisher_ = self.create_publisher(Image, 'ALO', 10) + self.timer_ = self.create_timer(0.1, self.publish_image) + self.bridge_ = CvBridge() + + def publish_image(self): + # Creamos una imagen de 640x480 píxeles con tres canales (BGR) + image = np.zeros((480, 640, 3), np.uint8) + # Dibujamos un círculo azul en el centro de la imagen + cv2.circle(image, (320, 240), 100, (255, 0, 0), -1) + # Convertimos la imagen a un mensaje de ROS + msg = self.bridge_.cv2_to_imgmsg(image, 'bgr8') + # Publicamos el mensaje + self.publisher_.publish(msg) + self.get_logger().info('Imagen publicada') + +def main(args=None): + rclpy.init(args=args) + node = ImagePublisher() + rclpy.spin(node) + rclpy.shutdown() + +if __name__ == '_main_': + main() \ No newline at end of file diff --git a/peruano_pkg/peruano_pkg/P_RecibirFoto.py b/peruano_pkg/peruano_pkg/P_RecibirFoto.py new file mode 100644 index 0000000..9806306 --- /dev/null +++ b/peruano_pkg/peruano_pkg/P_RecibirFoto.py @@ -0,0 +1,29 @@ +import rclpy +from rclpy.node import Node +from sensor_msgs.msg import Image + + +class ImageSubscriber(Node): + + def _init_(self): + super()._init_('image_subscriber') + self.subscription = self.create_subscription( + Image, + 'ALO', + self.listener_callback, + 10) + self.subscription # prevent unused variable warning + + def listener_callback(self, msg): + self.get_logger().info('Received an image!') # add your own code here to process the image data + + +def main(args=None): + rclpy.init(args=args) + node = ImageSubscriber() + rclpy.spin(node) + rclpy.shutdown() + + +if __name__ == '_main_': + main() \ No newline at end of file diff --git a/peruano_pkg/peruano_pkg/T_LinSpeed.py b/peruano_pkg/peruano_pkg/T_LinSpeed.py new file mode 100644 index 0000000..b5d5af7 --- /dev/null +++ b/peruano_pkg/peruano_pkg/T_LinSpeed.py @@ -0,0 +1,35 @@ +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, + 'lineal_speed', + 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/peruano_pkg/peruano_pkg/T_PubRpm.py b/peruano_pkg/peruano_pkg/T_PubRpm.py new file mode 100644 index 0000000..700e485 --- /dev/null +++ b/peruano_pkg/peruano_pkg/T_PubRpm.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_('CR_T1_PUBRPM') + 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/peruano_pkg/peruano_pkg/T_PubSub.py b/peruano_pkg/peruano_pkg/T_PubSub.py new file mode 100644 index 0000000..7effc08 --- /dev/null +++ b/peruano_pkg/peruano_pkg/T_PubSub.py @@ -0,0 +1,39 @@ +import rclpy +from rclpy.node import Node +from std_msgs.msg import String + +class MyNode(Node): + + def _init_(self): + super()._init_('jackson') + self.declare_parameter('Radio', 0.10) + sub_topic = self.get_parameter('Radio').value + 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('Radio').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() \ No newline at end of file diff --git a/peruano_pkg/peruano_pkg/__init__.py b/peruano_pkg/peruano_pkg/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/peruano_pkg/peruano_pkg/jack_pub.py b/peruano_pkg/peruano_pkg/jack_pub.py new file mode 100644 index 0000000..fff0ae1 --- /dev/null +++ b/peruano_pkg/peruano_pkg/jack_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/peruano_pkg/peruano_pkg/jack_sub.py b/peruano_pkg/peruano_pkg/jack_sub.py new file mode 100644 index 0000000..90b6807 --- /dev/null +++ b/peruano_pkg/peruano_pkg/jack_sub.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/peruano_pkg/peruano_pkg/prueba.py b/peruano_pkg/peruano_pkg/prueba.py new file mode 100644 index 0000000..fcf5379 --- /dev/null +++ b/peruano_pkg/peruano_pkg/prueba.py @@ -0,0 +1,31 @@ +import rclpy +from rclpy.node import Node +from std_msgs.msg import String + +class MyNode(Node): + + def _init_(self): + super().__init__('jackson') + self.publisher_ = self.create_publisher(String, 'LinSpeed', 10) + self.subscription_ = self.create_subscription(String, 'Rpm', self.callback, 10) + self.subscription_ + + def callback(self, msg): + self.get_logger().info('Received message: "%s"' % msg.data) + + response_msg = String() + response_msg.data = 'Received message: "%s"' % msg.data + self.publisher_.publish(response_msg) + +def main(args=None): + rclpy.init(args=args) + + node = MyNode() + + rclpy.spin(node) + + node.destroy_node() + rclpy.shutdown() + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/peruano_pkg/resource/peruano_pkg b/peruano_pkg/resource/peruano_pkg new file mode 100644 index 0000000..e69de29 diff --git a/peruano_pkg/setup.cfg b/peruano_pkg/setup.cfg new file mode 100644 index 0000000..3614dd9 --- /dev/null +++ b/peruano_pkg/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script-dir=$base/lib/peruano_pkg +[install] +install-scripts=$base/lib/peruano_pkg diff --git a/peruano_pkg/setup.py b/peruano_pkg/setup.py new file mode 100644 index 0000000..faed28e --- /dev/null +++ b/peruano_pkg/setup.py @@ -0,0 +1,45 @@ +from setuptools import setup +import os +from glob import glob +from setuptools import setup +from setuptools import find_packages + +package_name = 'peruano_pkg' + +package_files = [ + 'launch/Tarea.launch.py', + 'launch/Nodos.launch.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']), + #COLOQUE NUEVO + #('share/' + package_name, package_files), + #('share/' + package_name + '/launch', package_files), + (os.path.join('share', package_name, 'launch'), glob('launch/*.py')), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='jackson', + maintainer_email='jdicano1319@gmail.com', + description='TODO: Package description', + license='TODO: License declaration', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'talker = peruano_pkg.jack_pub:main', + 'rpm = peruano_pkg.T_PubRpm:main', + 'suppub = peruano_pkg.T_PubSub:main', + 'linspeed = peruano_pkg.T_LinSpeed:main', + 'penviar = peruano_pkg.P_EnviarFoto:main', + 'precibir = peruano_pkg.P_RecibirFoto:main', + ], + + }, +) diff --git a/peruano_pkg/test/test_copyright.py b/peruano_pkg/test/test_copyright.py new file mode 100644 index 0000000..cc8ff03 --- /dev/null +++ b/peruano_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/peruano_pkg/test/test_flake8.py b/peruano_pkg/test/test_flake8.py new file mode 100644 index 0000000..27ee107 --- /dev/null +++ b/peruano_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/peruano_pkg/test/test_pep257.py b/peruano_pkg/test/test_pep257.py new file mode 100644 index 0000000..b234a38 --- /dev/null +++ b/peruano_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'