Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -55,6 +55,65 @@ sudo rosdep init
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
```


## 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

Expand All @@ -66,3 +125,8 @@ rosdep update


BUENOS DIAS :)
ADIOS
hola willy
HOla reyes

Feliz cumpleaños willy :)
Empty file added henry_pkg/henry_pkg/__init__.py
Empty file.
33 changes: 33 additions & 0 deletions henry_pkg/henry_pkg/fis.py
Original file line number Diff line number Diff line change
@@ -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()
39 changes: 39 additions & 0 deletions henry_pkg/henry_pkg/my_pub.py
Original file line number Diff line number Diff line change
@@ -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()
55 changes: 55 additions & 0 deletions henry_pkg/henry_pkg/server.py
Original file line number Diff line number Diff line change
@@ -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()
30 changes: 30 additions & 0 deletions henry_pkg/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>henry_pkg</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="henryroncanciovelandia@gmail.com">roncanciovl</maintainer>
<license>Apache License 2.0</license>

<exec_depend>rclpy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>example_interfaces</exec_depend>

<build_depend>rosidl_default_generators</build_depend>
<exec_depend>rosidl_default_runtime</exec_depend>
<member_of_group>rosidl_interface_packages</member_of_group>



<test_depend>ament_copyright</test_depend>

<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
Empty file added henry_pkg/resource/henry_pkg
Empty file.
4 changes: 4 additions & 0 deletions henry_pkg/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[develop]
script-dir=$base/lib/henry_pkg
[install]
install-scripts=$base/lib/henry_pkg
27 changes: 27 additions & 0 deletions henry_pkg/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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',
'imageServer = henry_pkg.server:main',
],
},
)
23 changes: 23 additions & 0 deletions henry_pkg/test/test_copyright.py
Original file line number Diff line number Diff line change
@@ -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'
25 changes: 25 additions & 0 deletions henry_pkg/test/test_flake8.py
Original file line number Diff line number Diff line change
@@ -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)
23 changes: 23 additions & 0 deletions henry_pkg/test/test_pep257.py
Original file line number Diff line number Diff line change
@@ -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'
45 changes: 45 additions & 0 deletions lolito/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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)
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(<dependency> 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()
Empty file added lolito/Scripts/__init__.py
Empty file.
Loading