Skip to content

Commit 2e20aac

Browse files
authored
[Spawner] Create the FileLock in the ROS_HOME location (#2677)
1 parent b674ebb commit 2e20aac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controller_manager/controller_manager/spawner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ def main(args=None):
178178

179179
try:
180180
spawner_node_name = "spawner_" + controller_names[0]
181-
lock = FileLock("/tmp/ros2-control-controller-spawner.lock")
181+
# Get the environment variable $ROS_HOME or default to ~/.ros
182+
ros_home = os.getenv("ROS_HOME", os.path.join(os.path.expanduser("~"), ".ros"))
183+
ros_control_lock_dir = os.path.join(ros_home, "locks")
184+
if not os.path.exists(ros_control_lock_dir):
185+
os.makedirs(ros_control_lock_dir)
186+
lock = FileLock(f"{ros_control_lock_dir}/ros2-control-controller-spawner.lock")
182187
max_retries = 5
183188
retry_delay = 3 # seconds
184189
for attempt in range(max_retries):

0 commit comments

Comments
 (0)