Skip to content

Commit

Permalink
Late initialize web session, since it is rarely used and needs to mak…
Browse files Browse the repository at this point in the history
…e requests, impeding the connector from starting if a connection to the robot is not established
  • Loading branch information
b-Tomas committed Feb 3, 2025
1 parent a2598a7 commit 4a0e54a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mir_connector/inorbit_mir_connector/src/mir_api/mir_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def __init__(
self.mir_username = mir_username
self.mir_password = mir_password
self.api_session = self._create_api_session()
self.web_session = self._create_web_session()

def _get_web_session(self) -> requests.Session:
if not self.web_session:
self.web_session = self._create_web_session()

def _create_api_session(self) -> requests.Session:
session = requests.Session()
Expand Down Expand Up @@ -270,7 +273,7 @@ def send_waypoint(self, pose):
"orientation": orientation_degs,
"mode": "map-go-to-coordinates",
}
response = self._get(self.mir_base_url, self.web_session, params=parameters)
response = self._get(self.mir_base_url, self._get_web_session(), params=parameters)
self.logger.info(response.text)

def get_status(self):
Expand Down

0 comments on commit 4a0e54a

Please sign in to comment.