Skip to content

Commit

Permalink
Fully cut out the interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
aentinger committed Jan 14, 2025
1 parent 2172ae4 commit f13edb0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 103 deletions.
72 changes: 36 additions & 36 deletions l3xz_openmv_camera/l3xz_openmv_camera/l3xz_openmv_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sensor_msgs.msg import CompressedImage
from sensor_msgs.msg import CameraInfo

from l3xz_openmv_camera_interfaces.srv import Rgb, Ir, Gpio, GpioSet
# from l3xz_openmv_camera_interfaces.srv import Rgb, Ir, Gpio, GpioSet
from camera_interface import OpenMvInterface

class CameraNode(Node):
Expand Down Expand Up @@ -58,14 +58,14 @@ def __init__(self):
img_timer_period = 1.0 / self.get_parameter('frames_hz').value
self._img_timer = self.create_timer(img_timer_period, self._img_timer_callback)

self._srv_rgb = self.create_service(Rgb, self.get_name() + '/rgb', self._rgb_callback)
self._srv_ir = self.create_service(Ir, self.get_name() + '/ir', self._ir_callback)

self._pub_inputs = []
self._srv_gpio = self.create_service(Gpio, self.get_name() + '/gpio_config', self._gpio_callback)
self._srv_gpio_set = self.create_service(GpioSet, self.get_name() + '/gpio_set', self._gpio_set_callback)
gpio_timer_period = 1.0 / self.get_parameter('gpio_hz').value
self._gpio_timer = self.create_timer(gpio_timer_period, self._gpio_timer_callback)
# self._srv_rgb = self.create_service(Rgb, self.get_name() + '/rgb', self._rgb_callback)
# self._srv_ir = self.create_service(Ir, self.get_name() + '/ir', self._ir_callback)
#
# self._pub_inputs = []
# self._srv_gpio = self.create_service(Gpio, self.get_name() + '/gpio_config', self._gpio_callback)
# self._srv_gpio_set = self.create_service(GpioSet, self.get_name() + '/gpio_set', self._gpio_set_callback)
# gpio_timer_period = 1.0 / self.get_parameter('gpio_hz').value
# self._gpio_timer = self.create_timer(gpio_timer_period, self._gpio_timer_callback)

def _img_timer_callback(self):
framedump = self._cam.dump()
Expand All @@ -77,33 +77,33 @@ def _img_timer_callback(self):
# self._pub_image_compressed.publish(framedump.fill_jpeg_msg(self._img_compressed_msg))
self._pub_info.publish(framedump.fill_info_msg(self._info_msg))

def _rgb_callback(self, request, response):
response.success = self._cam.rgb_led(request.r, request.g, request.b)
return response

def _ir_callback(self, request, response):
response.success = self._cam.ir_led(request.on)
return response

def _gpio_callback(self, request, response):
response.success = self._cam.gpio_config(request.nr, request.output, request.opendrain, request.pullup, request.pulldown)
if response.success:
self._pub_inputs.append([request.nr, self.create_publisher(Bool, self.get_name() + "/input_" + str(request.nr), 1)])
return response

def _gpio_set_callback(self, request, response):
response.success = self._cam.gpio_set(request.nr, request.on)
return response

def _gpio_timer_callback(self):
self._cam.gpio_poll_inputs()
for gpio_input in self._cam.inputs:
for pub in self._pub_inputs:
if pub[0] == gpio_input[0]:
msg = Bool()
msg.data = bool(gpio_input[1])
pub[1].publish(msg)
break
# def _rgb_callback(self, request, response):
# response.success = self._cam.rgb_led(request.r, request.g, request.b)
# return response
#
# def _ir_callback(self, request, response):
# response.success = self._cam.ir_led(request.on)
# return response
#
# def _gpio_callback(self, request, response):
# response.success = self._cam.gpio_config(request.nr, request.output, request.opendrain, request.pullup, request.pulldown)
# if response.success:
# self._pub_inputs.append([request.nr, self.create_publisher(Bool, self.get_name() + "/input_" + str(request.nr), 1)])
# return response

# def _gpio_set_callback(self, request, response):
# response.success = self._cam.gpio_set(request.nr, request.on)
# return response
#
# def _gpio_timer_callback(self):
# self._cam.gpio_poll_inputs()
# for gpio_input in self._cam.inputs:
# for pub in self._pub_inputs:
# if pub[0] == gpio_input[0]:
# msg = Bool()
# msg.data = bool(gpio_input[1])
# pub[1].publish(msg)
# break

def main(args=None):
rclpy.init(args=args)
Expand Down
2 changes: 1 addition & 1 deletion l3xz_openmv_camera/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<license>MIT</license>
<exec_depend>rclpy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>l3xz_openmv_camera_interfaces</exec_depend>
<!-- <exec_depend>l3xz_openmv_camera_interfaces</exec_depend>-->

<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
Expand Down
22 changes: 0 additions & 22 deletions l3xz_openmv_camera_interfaces/CMakeLists.txt

This file was deleted.

25 changes: 0 additions & 25 deletions l3xz_openmv_camera_interfaces/package.xml

This file was deleted.

7 changes: 0 additions & 7 deletions l3xz_openmv_camera_interfaces/srv/Gpio.srv

This file was deleted.

4 changes: 0 additions & 4 deletions l3xz_openmv_camera_interfaces/srv/GpioSet.srv

This file was deleted.

3 changes: 0 additions & 3 deletions l3xz_openmv_camera_interfaces/srv/Ir.srv

This file was deleted.

5 changes: 0 additions & 5 deletions l3xz_openmv_camera_interfaces/srv/Rgb.srv

This file was deleted.

0 comments on commit f13edb0

Please sign in to comment.