-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
484 additions
and
2,252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#! /usr/bin/env python3 | ||
# Copyright 2024 Open Navigation LLC | ||
# Copyright 2024 Stevedan Ogochukwu Omodolor Omodia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""General utility functions.""" | ||
|
||
import os | ||
import signal | ||
import subprocess | ||
|
||
|
||
def find_os_processes(name): | ||
"""Find all the processes that are running gz sim.""" | ||
ps_output = subprocess.check_output(['ps', 'aux'], text=True) | ||
ps_lines = ps_output.split('\n') | ||
gz_sim_processes = [] | ||
for line in ps_lines: | ||
if name in line: | ||
columns = line.split() | ||
pid = columns[1] | ||
command = ' '.join(columns[10:]) | ||
if command.startswith(name): | ||
gz_sim_processes.append((pid, command)) | ||
return gz_sim_processes | ||
|
||
|
||
def kill_process(pid): | ||
"""Kill a process with a given PID.""" | ||
try: | ||
os.kill(int(pid), signal.SIGKILL) | ||
print(f'Successfully killed process with PID: {pid}') | ||
except Exception as e: | ||
print(f'Failed to kill process with PID: {pid}. Error: {e}') | ||
|
||
|
||
def kill_os_processes(name): | ||
"""Kill all processes that are running with name.""" | ||
processes = find_os_processes(name) | ||
if processes: | ||
for pid, _ in processes: | ||
kill_process(pid) | ||
else: | ||
print(f'No processes found starting with {name}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<sdf version="1.6"> | ||
<model name='cardboard_box'> | ||
<include> | ||
<uri> | ||
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Cardboard box | ||
</uri> | ||
</include> | ||
</model> | ||
</sdf> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.