del scenario,gym_gz from env_manager + refactoring

This commit is contained in:
shalenikol 2025-05-20 12:07:15 +03:00
parent 8d83e3d708
commit 9c6cdfa291
5 changed files with 22 additions and 15 deletions

View file

@ -4,6 +4,7 @@
ROS 2 program for Object Detection
@shalenikol release 0.4
...
"""
from typing import Optional
@ -49,6 +50,7 @@ class ObjectDetection(Node):
self._is_image_mode = False
self.yolov8_weights_file = ""
self.model = None
self.is_detection = False # object detection indicator in the frame
# for other nodes
kwargs["allow_undeclared_parameters"] = True
@ -100,6 +102,8 @@ class ObjectDetection(Node):
# res = self._cli_getstate.call(req) # the program freezes
id_,_ = self._state_machine.current_state
_is = (id_ == State.PRIMARY_STATE_ACTIVE)
elif request.command == "isDetection":
_is = self.is_detection
response.ok = _is
return response
@ -206,6 +210,7 @@ class ObjectDetection(Node):
return
msg = BoundBox()
msg.is_detection = False
self.is_detection = False
#from ultralytics.engine.results
cconf = self._threshold # threshold
bb = None
@ -218,6 +223,7 @@ class ObjectDetection(Node):
bb = c
if bb:
msg.is_detection = True
self.is_detection = True
msg.name = self.objName
msg.x = float(bb.xywhn[0,0])
msg.y = float(bb.xywhn[0,1])