luxonis / rae-ros

Implementation of RAE ROS and gazebo stack
MIT License
32 stars 13 forks source link

Using instance of Robot() in a separate node #76

Open mjohannessen opened 8 months ago

mjohannessen commented 8 months ago

After starting the robot instance using

from rae_sdk.robot import Robot robot = Robot()

Can that instance of robot be called from another node to, for example stop that instance or add a publisher, nav command or make another api call to Robot? Creating a second instance of Robot() disrupts the first instance.

Serafadam commented 8 months ago

Hi, do you mean if it's possible to create ROS interfaces (subscriptions, timers) etc. via some external service call? That is currently not available. I also did not test it yet but I think it should be possible to create a ROS node that has Robot class in it. Regarding multiple 'Robot' class instances, you can use RobotOptions to indicate whether new instance should start the hardware controllers and/or controllers, is that more in line of what you need?

mjohannessen commented 8 months ago

Here's an example: robot_test_1.py brings up rae, and robot_test_2.py seems to have no effect. This would be the same if a new Robot object is instantiated in a node, for example to add a publisher or test the audio using the python api:

robot_test_1.py:

from rae_sdk.robot import Robot
from rae_sdk.robot.robot_options import RobotOptions

## brigup rae
options = RobotOptions(
    name='rae_sdk_1', 
    namespace='', 
    launch_controllers=True, 
    start_hardware=True, 
    launch_mock=False
)
robot = Robot(options)
robot.led.set_leds('#FF0000', 100, 'solid', 1)  # set color to red

and

robot_test_2.py:

from rae_sdk.robot import Robot
from rae_sdk.robot.robot_options import RobotOptions

options = RobotOptions(
    name='rae_sdk_2', 
    namespace='', 
    launch_controllers=False, 
    start_hardware=False, 
    launch_mock=False
)
robot = Robot(options)
robot.led.set_leds('#0000FF', 100, 'solid', 1)  # set color to blue
Serafadam commented 8 months ago

Hi, sorry for the delay, I didn't get the notification. If you set launch_controllers to true in robot_test_2.py you should be able to use the interfaces.