Skip to content

Commit

Permalink
minor clean up from flake8/pycodestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Conner committed Jul 2, 2024
1 parent ad286a6 commit f1654c3
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions flexbe_core/flexbe_core/core/concurrency_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def _execute_current_state(self):

if command_msg.target == self.name:
cmd_msg2 = self._sub.get_from_buffer(Topics._CMD_TRANSITION_TOPIC) # Using here, so clear from buffer
assert cmd_msg2 is command_msg, "Unexpected change in CMD_TRANSITION_TOPIC buffer"
assert cmd_msg2 is command_msg, 'Unexpected change in CMD_TRANSITION_TOPIC buffer'
Logger.localinfo(f"-concurrency container '{self.name}' is handling the transition cmd msg={command_msg}")

self._force_transition = True
Expand Down Expand Up @@ -140,9 +140,9 @@ def _execute_current_state(self):
# @TODO - Should we be using path not name here?
command_msg = self._manual_transition_requested
cmd_msg2 = self._sub.get_from_buffer(Topics._CMD_TRANSITION_TOPIC) # Using here, so clear from buffer
assert cmd_msg2 is command_msg, "Something is up with handling of buffer for CMD_TRANSITION_TOPIC"
assert cmd_msg2 is command_msg, 'Something is up with handling of buffer for CMD_TRANSITION_TOPIC'
Logger.localinfo(f"-concurrency container '{self.name}' state '{state.name}' is handling "
f"the cmd msg={command_msg}")
f"the cmd msg='{command_msg}'")
self._manual_transition_requested = None # Reset at this level

if 0 <= command_msg.outcome < len(state.outcomes):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _manually_transitionable_execute(self, *args, **kwargs):
command_msg = self._sub.peek_at_buffer(Topics._CMD_TRANSITION_TOPIC)
if command_msg.target == self.name:
cmd_msg2 = self._sub.get_from_buffer(Topics._CMD_TRANSITION_TOPIC)
assert cmd_msg2 is command_msg, "Unexpected change in CMD_TRANSITION_TOPIC buffer"
assert cmd_msg2 is command_msg, 'Unexpected change in CMD_TRANSITION_TOPIC buffer'
self._pub.publish(Topics._CMD_FEEDBACK_TOPIC,
CommandFeedback(command='transition', args=[command_msg.target, self.name]))

Expand Down
2 changes: 1 addition & 1 deletion flexbe_core/flexbe_core/core/operatable_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def define_structure(self):
"""Calculate all state ids and prepare the ContainerStructure message."""
self._state_map = StateMap()
self._structure = self._build_structure_msg()
print(f"\x1b[94mBuilt {self._state_map}\x1b[0m", flush=True)
print(f'\x1b[94mBuilt {self._state_map}\x1b[0m', flush=True)

def _build_structure_msg(self):
"""Create a message to describe the structure of this state machine."""
Expand Down
1 change: 1 addition & 0 deletions flexbe_core/flexbe_core/core/preemptable_state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from flexbe_core.core.preemptable_state import PreemptableState
from flexbe_core.core.topics import Topics
from flexbe_core.logger import Logger

from flexbe_msgs.msg import CommandFeedback

import rclpy
Expand Down
29 changes: 14 additions & 15 deletions flexbe_mirror/flexbe_mirror/flexbe_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

"""Class to handle the FlexBE mirror of onboard statemachine."""

import threading
import time
import traceback
from collections import deque

try:
Expand All @@ -39,10 +42,6 @@ def set_thread_name(name):
# print('Python thread names are not visible in ps/top unless you install prctl')
pass

import threading
import time
import traceback

from flexbe_core import Logger, MIN_UI_VERSION
from flexbe_core.core import LockableStateMachine, OperatableStateMachine
from flexbe_core.core import PreemptableState, PreemptableStateMachine, StateMap
Expand All @@ -62,16 +61,16 @@ def set_thread_name(name):
from .mirror_state_machine import MirrorStateMachine

bestatus_map = {
BEStatus.STARTED: "STARTED",
BEStatus.FINISHED: "FINISHED",
BEStatus.FAILED: "FAILED",
BEStatus.LOCKED: "LOCKED",
BEStatus.WAITING: "WAITING",
BEStatus.SWITCHING: "SWITCHING",
BEStatus.WARNING: "WARNING",
BEStatus.ERROR: "ERROR",
BEStatus.READY: "READY",
BEStatus.RUNNING: "RUNNING",
BEStatus.STARTED: 'STARTED',
BEStatus.FINISHED: 'FINISHED',
BEStatus.FAILED: 'FAILED',
BEStatus.LOCKED: 'LOCKED',
BEStatus.WAITING: 'WAITING',
BEStatus.SWITCHING: 'SWITCHING',
BEStatus.WARNING: 'WARNING',
BEStatus.ERROR: 'ERROR',
BEStatus.READY: 'READY',
BEStatus.RUNNING: 'RUNNING',
}


Expand Down Expand Up @@ -801,7 +800,7 @@ def _mirror_state_machine(self, msg):
assert path_seg in state.path, (f'Mismatched state id={state.state_id} for {state.path} vs. '
f'({con_msg.state_id}) {con_msg.path}')
else:
raise KeyError(f"State id {con_msg.state_id} not found in {self._state_map}!")
raise KeyError(f'State id {con_msg.state_id} not found in {self._state_map}!')
end = time.time()
Logger.localinfo(f"Validated constructed mirror for behavior id ='{self._sm.id}' in {end - start} seconds !")
return # success here
Expand Down
6 changes: 3 additions & 3 deletions flexbe_onboard/flexbe_onboard/flexbe_onboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def _parse_version(v):
def _behavior_callback(self, beh_sel_msg):
if self._starting:
# Prevent multiple request messages from triggering too soon
Logger.logwarn(f"Received behavior start request for {beh_sel_msg.behavior_key} "
f"({beh_sel_msg.behavior_id}) while prior request was starting.\n Ignore second request!")
Logger.logwarn(f'Received behavior start request for {beh_sel_msg.behavior_key} '
f'({beh_sel_msg.behavior_id}) while prior request was starting.\n Ignore second request!')
return
self._starting = True # Prevent two start requests from ocurring back to back
self._trigger_ready = False # We have received the behavior selection request
Expand Down Expand Up @@ -357,7 +357,7 @@ def _behavior_execution(self, beh_sel_msg):
self._status_pub.publish(BEStatus(stamp=self.get_clock().now().to_msg(), code=BEStatus.READY))
Logger.localinfo('\033[92m--- Behavior Engine finished - ready for more! ---\033[0m')

Logger.localinfo(f"Behavior execution finished for id={self.be.beh_id}, exit thread!")
Logger.localinfo(f'Behavior execution finished for id={self.be.beh_id}, exit thread!')
self._running = False
self._switching = False
self.be = None
Expand Down

0 comments on commit f1654c3

Please sign in to comment.