Skip to content

Commit fc563c8

Browse files
committed
fix linting
1 parent 2633568 commit fc563c8

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

spot_examples/docs/simple_sub.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ ros2 run spot_examples simple_sub --robot spot1
6363

6464
## Author
6565
- Kabir Kedia <[email protected]>
66-
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,58 @@
1-
import os
21
import argparse
3-
import logging
4-
from typing import Any, Dict, Optional
52
from contextlib import closing
3+
from typing import Optional
4+
65
import synchros2.process as ros_process
76
from geometry_msgs.msg import Pose
87
from synchros2.subscription import Subscription
8+
99
from .robot_commander import RobotCommander
1010

11+
1112
class SpotRobotInterface:
1213
def __init__(self, robot_name: Optional[str] = None):
1314
# self.robot_name = os.getenv("ROBOT_NAME")
1415
self.robot_commander = RobotCommander(robot_name)
1516
self.latest_message = None # Buffer to store the latest message
1617
self.is_busy = False # Flag to indicate if the robot is busy
1718
self.robot_commander._logger.info(f"Robot Name: {self.robot_commander._robot_name}")
18-
19-
def initialize(self):
19+
20+
def initialize(self) -> bool:
2021
if not self.robot_commander.initialize_robot():
2122
self.robot_commander._logger.info("Failed to initialize robot")
2223
return False
2324
self.robot_commander._logger.info("Initialized robot")
2425
return True
2526

26-
def process_message(self, message):
27+
def process_message(self, message: Pose) -> None:
2728
if self.is_busy:
2829
self.latest_message = message
2930
self.robot_commander._logger.info("Robot is busy, buffering the latest message")
3031
else:
3132
self.execute_command(message)
32-
33-
if self.latest_message:
34-
self.execute_command(self.latest_message)
35-
self.latest_message = None
3633

37-
def execute_command(self, message):
34+
# if self.latest_message:
35+
# # self.execute_command(self.latest_message)
36+
# self.latest_message = None
37+
38+
def execute_command(self, message: Pose) -> None:
3839
self.is_busy = True
3940
self.robot_commander.walk_forward_with_world_frame_goal(message)
4041
self.is_busy = False
41-
42-
def listen_to_pose_commands(self):
42+
43+
def listen_to_pose_commands(self) -> None:
4344
topic_data = Subscription(Pose, "/pose_commands")
4445
with closing(topic_data.stream()) as stream:
4546
for message in stream:
4647
self.process_message(message)
4748

49+
4850
def cli() -> argparse.ArgumentParser:
4951
parser = argparse.ArgumentParser()
5052
parser.add_argument("--robot", help="Name of the robot if the ROS driver is inside that namespace")
5153
return parser
5254

55+
5356
@ros_process.main(cli())
5457
def main(args: argparse.Namespace) -> None:
5558
robot_interface = SpotRobotInterface(args.robot)
@@ -58,5 +61,6 @@ def main(args: argparse.Namespace) -> None:
5861
if robot_interface.initialize():
5962
robot_interface.listen_to_pose_commands()
6063

64+
6165
if __name__ == "__main__":
6266
main()

0 commit comments

Comments
 (0)