Add method to set replay_mode, also via a start_program kwarg#38
Conversation
| ) | ||
| if (error_msg := await self._wait_for_answer_async(msg_id)) is not None: | ||
| raise CRICommandError(f"Could not set replay mode: {error_msg}") | ||
| await asyncio.sleep(0.1) |
There was a problem hiding this comment.
What's the STATUS refresh rate again? Sleeping for one cycle would be best.
There was a problem hiding this comment.
The STATUS message is sent roughly every 25ms, it may be a bit slower
There was a problem hiding this comment.
Thanks, I reduced the sleep to 50 ms.
In practice I'd expect the replay mode to usually match already, making the method extremely fast.
Makes it easy to set the replay mode before starting a program.
31cd026 to
959caba
Compare
|
About observing program execution:
Each of those command got the parameters
EXECEND and EXECERROR may contain an error message / reason string as 4th parameter Logic programs send EXECERROR on error but no other messages. In the current RobotControl version 15 Move-To commands generate MOVETOxxx (e.g. MOVETOEXECACK) messages and mobile platform programs generate PLTFxxx messages. So to wait for completion you will need to observe EXECEND, EXECERROR and perhaps EXECPAUSE. Regarding your comment in PR #36: Each EXECxxx message generates a new message ID. |
|
Thanks! My execution/observation code is currently this, and it works too. For the moment I think it's sufficient. logger.info("Executing program '%s' once", fname)
if not await controller.start_programm_async(replay_mode=ReplayMode.SINGLE):
raise MovementError("Program execution failed.")
# Wait for it to start
while controller.robot_state.main_runstate != RunState.RUNNING:
await asyncio.sleep(0.1)
# Observe and log progress
cmd_count = -1
while controller.robot_state.main_runstate == RunState.RUNNING:
if controller.robot_state.main_current_command != cmd_count:
cmd_count = controller.robot_state.main_current_command
logger.info(
"Program '%s' is in step %d/%d",
controller.robot_state.main_current_program,
controller.robot_state.main_current_command,
controller.robot_state.main_commands_count,
)
await asyncio.sleep(0.025)
logger.info("Program '%s' completed.", fname) |
We'd like to run programs primarily in
SINGLEmode, and this way it's easy to make sure it's set.Observing program execution and awaiting it's completion would be nice, but even after #36 I'm still a bit confused about the exact order of events to monitor for that.