-
Notifications
You must be signed in to change notification settings - Fork 73
Description
It seems like the AMBF python client is failing to load the handles for objects in Ubuntu 24.04 with ros2 Jazzy. I did my testings with the ambf-3.0 branch. This is probably just a timing issue. The ambf client creates objects based on the get_node_names_and_namespaces() from ROS, but this function sometimes doesn't return all the available topics.
A simple solution to this problem is to add a sleep in between the moment you create a node and the moment you query the node_names with ROS2. You can see this with the simple script below.
import rclpy
import time
rclpy.init()
node = rclpy.create_node("test_node")
## If sleep is not included you won't see all the available nodes
# time.sleep(0.1)
nodes = node.get_node_names_and_namespaces()
print(nodes)
print(f"Total nodes: {len(nodes)}")
As a workaround for the ambf_client, you can create a ros2 node and add a sleep before instantiating the client. A hardcoded sleep is probably not the most reliable solution, so we should probably check with Anton or Brendan to see if there are any better solutions.
import time
from ambf_client import Client
############
# Temp solution
############
import rclpy
rclpy.init()
node = rclpy.create_node("test_node")
time.sleep(0.3)
############
client = Client("client")
client.connect()
obj_names = client.get_obj_names()
print(f"Found {len(obj_names)} objects in the simulation:")
print(obj_names)