Skip to content

Commit

Permalink
Merge pull request #19 from fmessmer/feature/multi_robot
Browse files Browse the repository at this point in the history
Feature/multi robot
  • Loading branch information
Deleh authored Nov 5, 2024
2 parents 1e481f0 + 1191e0d commit 25a1e8f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit 25a1e8f

Please sign in to comment.