fix recording_demo
This commit is contained in:
parent
b22a64e5e9
commit
a87d577989
1 changed files with 17 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
recording_demo_lib
|
||||
recording_demo_service_node
|
||||
ROS 2 program for recording a demo via RosBag
|
||||
|
||||
@shalenikol release 0.1
|
||||
|
@ -39,32 +39,35 @@ KEY_SIDPATH = "@path@" # prefix for filepath
|
|||
class RbsActionClient(Node):
|
||||
def __init__(self):
|
||||
self.res_ok = False
|
||||
self.is_record_run = False
|
||||
super().__init__("rbs_action_client")
|
||||
self._action_client = ActionClient(self, RbsBt, SERVER_NAME)
|
||||
self._recorder_service = self.create_service(
|
||||
Recorder, "recorder", self.recorder
|
||||
)
|
||||
self._recorder_service = self.create_service(Recorder, "recorder", self.recorder)
|
||||
|
||||
def recorder(
|
||||
self, request: Recorder.Request, response: Recorder.Response
|
||||
) -> Recorder.Response:
|
||||
def recorder(self, request: Recorder.Request, response: Recorder.Response) -> Recorder.Response:
|
||||
# response.ok = recording_demo(request.command.command)
|
||||
if request.command.command == RecorderCommands.RUN:
|
||||
response.ok = False
|
||||
if request.command.command == RecorderCommands.RUN and not self.is_record_run:
|
||||
response.ok = recording_demo(CommandType.RUN)
|
||||
self.is_record_run = response.ok
|
||||
|
||||
elif request.command.command == RecorderCommands.SAVE_AND_NEXT:
|
||||
elif request.command.command == RecorderCommands.SAVE_AND_NEXT and self.is_record_run:
|
||||
response.ok = recording_demo(CommandType.SAVE_AND_NEXT)
|
||||
|
||||
elif request.command.command == RecorderCommands.CANCEL_AND_NEXT:
|
||||
elif request.command.command == RecorderCommands.CANCEL_AND_NEXT and self.is_record_run:
|
||||
response.ok = recording_demo(CommandType.CANCEL_AND_NEXT)
|
||||
self.is_record_run = response.ok
|
||||
|
||||
elif request.command.command == RecorderCommands.STOP_AND_SAVE:
|
||||
elif request.command.command == RecorderCommands.STOP_AND_SAVE and self.is_record_run:
|
||||
response.ok = recording_demo(CommandType.STOP_AND_SAVE)
|
||||
if response.ok:
|
||||
self.is_record_run = False
|
||||
|
||||
elif request.command.command == RecorderCommands.STOP_AND_CANCEL:
|
||||
elif request.command.command == RecorderCommands.STOP_AND_CANCEL and self.is_record_run:
|
||||
response.ok = recording_demo(CommandType.STOP_AND_CANCEL)
|
||||
else:
|
||||
response.ok = False
|
||||
if response.ok:
|
||||
self.is_record_run = False
|
||||
|
||||
return response
|
||||
|
||||
def send_goal(self, sid: str, action: str, command: str):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue