Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multi robot #19

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ sessions:
- `-c` or `--config`: Specify the path to the YAML configuration file that defines the hosts, sessions, and other settings. The default configuration file path is "/etc/ros/upstart_robot.yaml."
- `-s` or `--sessions`: Optionally, specify which sessions should be started or stopped. You can provide multiple session names as arguments.
- `-f` or `--force`: Use this flag to force the closure of sessions, even if they are locked.
- `-l <L>` or `--logging_level <L>`: Use this flag to set the logging level, ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
- `--instance_id <N>`: An unique id used to prepend to each session name and used within multi-robot setups.

### YAML Configuration

Expand Down
18 changes: 16 additions & 2 deletions robmuxinator/robmuxinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,12 +795,19 @@ def main():
default="INFO",
help="logging level",
)
parser.add_argument(
"--instance_id",
type=int,
help="an unique id used to prepend to each session name within the config file. used for multi-robot emulation. the instance_id is also exported to the env used within the sessions as well as to guarantee a unique ROS_DOMAIN_ID",
default=0,
)

argcomplete.autocomplete(parser)
args = parser.parse_args()
# parse arguments
yaml_file = args.config
command = args.command
instance_id = args.instance_id

# set logging level
logger.setLevel(level=args.logging_level)
Expand Down Expand Up @@ -880,6 +887,13 @@ def main():
else:
envs = None

# Check if 'instance_id' was given by the user.
# This indicates the a multi-instance setup, e.g. for multi-robot emulation.
# Therefore we export the INSTANCE_ID and use it for to guarantee a unique ROS_DOMAIN_ID
if instance_id != 0:
envs.append(("INSTANCE_ID", instance_id))
envs.append(("ROS_DOMAIN_ID", instance_id))

# get sessions from yaml
yaml_sessions = None
if "sessions" in yaml_content:
Expand Down Expand Up @@ -911,7 +925,7 @@ def main():
sessions.append(
Session(
SSHClient(user=user, hostname=hosts[host].get_hostname(), port=hosts[host].get_ssh_port()),
key,
str(instance_id) + "_" + key if instance_id != 0 else key,
yaml_sessions[key],
envs
)
Expand All @@ -920,7 +934,7 @@ def main():
sessions.append(
Session(
SSHClient(user=user, hostname=hosts[host].get_hostname(), port=hosts[host].get_ssh_port()),
key,
str(instance_id) + "_" + key if instance_id != 0 else key,
yaml_sessions[key],
envs
)
Expand Down