Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions package.xml → image_object_detection/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
<depend>cv_bridge</depend>
<depend>image_transport</depend>
<depend>vision_msgs</depend>
<depend>std_msgs</depend>
<depend>image_object_detection_msgs</depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
from utils.plots import plot_one_box
from utils.torch_utils import select_device
from vision_msgs.msg import Detection2D, Detection2DArray, ObjectHypothesisWithPose
from image_object_detection_msgs.srv import SetDetectionClasses

from ament_index_python.packages import get_package_share_directory

PACKAGE_NAME = "image_object_detection"


class ImageDetectObjectNode(Node):
def __init__(self):
super().__init__("image_object_detection_node")
Expand Down Expand Up @@ -112,6 +113,13 @@ def __init__(self):
callback=self.set_processing_enabled_callback,
)

self.set_classes_service = self.create_service(
SetDetectionClasses,
'set_detection_classes',
self.set_detection_classes_callback
)


if self.subscribers_qos == "best_effort":
self.get_logger().info("Using best effort qos policy for subscribers")
self.qos = QoSProfile(
Expand Down Expand Up @@ -166,6 +174,14 @@ def __init__(self):

self.initialize_model()


def set_detection_classes_callback(self, request, response):
self.selected_detections = request.classes
self.get_logger().info(f"Updated selected_detections: {self.selected_detections}")
response.success = True
response.message = f"Successfully updated detection classes to {self.selected_detections}"
return response

def initialize_model(self):
with torch.no_grad():
# Initialize
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions image_object_detection_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.8)
project(image_object_detection_msgs)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
"srv/SetDetectionClasses.srv"
)

ament_export_dependencies(rosidl_default_runtime)
install(
DIRECTORY srv
DESTINATION share/${PROJECT_NAME}
)

ament_package()
18 changes: 18 additions & 0 deletions image_object_detection_msgs/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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>image_object_detection_msgs</name>
<version>1.0.0</version>
<description>Messages for image object detection</description>
<maintainer email="pablo@ibrobotics.com">Pablo Iñigo Blasco</maintainer>
<license>BSD-3-Clause</license>

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

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
4 changes: 4 additions & 0 deletions image_object_detection_msgs/srv/SetDetectionClasses.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
string[] classes
---
bool success
string message
Binary file not shown.
Binary file not shown.