def generate_launch_description(): """ Create launch description for starting a SandboxedNodeContainer with a local image. A SandboxedNode must be loaded into the container for any work to be done. """ ld = LaunchDescription() ld.add_action( SandboxedNodeContainer( sandbox_name='my_sandbox', policy=DockerPolicy( tag='latest', repository='ros-dashing-dummy', entrypoint='/ros_entrypoint.sh' ), node_descriptions=[ SandboxedNode( package='demo_nodes_cpp', node_executable='talker', ), SandboxedNode( package='demo_nodes_cpp', node_executable='listener' ), ] ) ) return ld
def generate_launch_description() -> LaunchDescription: """ Create launch description for starting SandboxedNodeContainer with DockerPolicy. Talker and Listener are both loaded inside the SandboxedNodeContainer. When the sandboxed node is executed, it runs the ROS 2 node within the Docker container. The container continues to run until stopped externally. The output of the talker and listener nodes should be logged to the host machine's stdout. """ ld = LaunchDescription() ld.add_action( SandboxedNodeContainer(sandbox_name='my_sandbox', policy=DockerPolicy( tag='dashing-desktop', repository='osrf/ros', container_name='sandboxed-listener-node', ), node_descriptions=[ SandboxedNode( package='demo_nodes_cpp', node_executable='talker', ), SandboxedNode(package='demo_nodes_cpp', node_executable='listener') ])) return ld
def generate_launch_description() -> LaunchDescription: """ Create launch description for starting SandboxedNodeContainer with DockerPolicy. Talker is loaded inside the SandboxedNodeContainer. When the sandboxed node is executed, it runs the ROS 2 node within the Docker container. The container continues to run until stopped externally. The talker node can be interacted with by launching a listener node. The listener node does not need to be launched from within the Docker container. """ ld = LaunchDescription() ld.add_action( SandboxedNodeContainer(sandbox_name='my_sandbox', policy=DockerPolicy( tag='dashing-desktop', repository='osrf/ros', container_name='sandboxed-listener-node', ), node_descriptions=[ SandboxedNode( package='demo_nodes_cpp', node_executable='talker', ), ])) return ld
def test_launch_nodes(self): """Test launching a node.""" node_action = SandboxedNodeContainer( sandbox_name='my_sandbox', node_descriptions=[ SandboxedNode( package='demo_nodes_cpp', node_executable='talker', ), SandboxedNode( package='demo_nodes_cpp', node_executable='listener', ), ], ) self._assert_launch_no_errors([node_action])
def generate_launch_description() -> LaunchDescription: """ Create a launch description for starting SandboxedNodeContainer with DockerPolicy. In this example, the C++ demo talker node is loaded inside the SandboxedNodeContainer called 'sandboxed-listener-node'. The Docker policy uses a Docker image of ROS2 Dashing (Desktop) from 'osrf/ros'. When the sandboxed node is executed, it runs the ROS 2 node within the Docker container. The container continues to run until stopped externally. The talker node can be interacted with by launching a listener node. The listener node does not need to be launched from within the Docker container. Only CPU 0 will be available to the nodes. The number of CPUs can be queried by running nproc inside the container. """ ld = LaunchDescription() ld.add_action( SandboxedNodeContainer(sandbox_name='my_sandbox', policy=DockerPolicy( tag='dashing-desktop', repository='osrf/ros', container_name='sandboxed-listener-node', run_args={'cpuset_cpus': '0'}), node_descriptions=[ SandboxedNode( package='demo_nodes_cpp', node_executable='talker', ), ])) return ld
def generate_launch_description(): ld = LaunchDescription() ld.add_action( SandboxedNodeContainer( sandbox_name='my_sandbox', policy=DockerPolicy( tag='latest', repository='rosswg/turtlebot3_demo', container_name='sandboxed-cpu-hog', run_args={ # CPU quota, in microseconds per scheduler period. # The default scheduler period is 100ms == 100000us # Therefore the below value of 200000us limits this container to using, # at most, 2 cpu cores' worth of processing 'cpu_period': 100000, 'cpu_quota': 200000, }, entrypoint='/ros_entrypoint.sh', ), node_descriptions=[ SandboxedNode( package='example_nodes', node_executable='cpu_hog', ), ])) return ld
def test_launch_docker_policy(self, mock_docker_policy) -> None: """Test launching SandboxedNodeContainer with DockerPolicy.""" node_action = SandboxedNodeContainer( sandbox_name='my_sandbox', policy=mock_docker_policy, node_descriptions=[ SandboxedNode( package='demo_nodes_cpp', node_executable='talker', ), SandboxedNode(package='demo_nodes_cpp', node_executable='listener'), ], ) self._assert_launch_no_errors([node_action]) mock_docker_policy.apply.assert_called()