Hi everyone,
I’m currently working on integrating BeamNG.tech with ROS2 and would like to know if it’s possible to control multiple vehicles (agents) simultaneously using the ROS2 bridge. Right now, I’m using the following script to control just one vehicle:
def __init__(self):
super().__init__(NODE_NAME)
host = self.declare_parameter("host", "###.##.224.1").value
port = self.declare_parameter("port", 25252).value
vehicle_id = self.declare_parameter("vehicle_id", "ego").value
if not vehicle_id:
self.get_logger().fatal("No Vehicle ID given, shutting down node.")
sys.exit(1)
self.game_client = bngpy.BeamNGpy(host, port)
try:
self.game_client.open(listen_ip="*", launch=False, deploy=False)
self.get_logger().info("Successfully connected to BeamNG.tech.")
except TimeoutError:
self.get_logger().error("Could not establish game connection.")
sys.exit(1)
current_vehicles = self.game_client.get_current_vehicles()
if vehicle_id not in current_vehicles:
self.get_logger().fatal(f"No vehicle with id {vehicle_id} exists.")
sys.exit(1)
self.vehicle_client = current_vehicles[vehicle_id]
try:
self.vehicle_client.connect(self.game_client)
self.get_logger().info(f"Connected to vehicle {self.vehicle_client.vid}")
except TimeoutError:
self.get_logger().fatal("Could not establish vehicle connection.")
sys.exit(1)
My questions are:
- Is it possible to control more than one vehicle at the same time using this ROS2 bridge setup?
- Can I use the same IP and port for all vehicles and just manage multiple vehicle clients in code? Or is it necessary to use different ports (or even different IP addresses) for each vehicle connection?
- In the scenario definition i just have to define a new vehicle?
Thanks in advance for any answer! And sorry for the specific question