Esempio n. 1
0
    def test_component_config(self):
        self._app = Application()
        self._app.add('node')

        node = self._app.nodes['node']
        self.assertIsNotNone(node)

        result = self._app.load_module('viewers')
        self.assertTrue(result)

        component = node.add(self._app.registry.isaac.viewers.ImageViewer)
        self.assertTrue(isinstance(component, Component.Component))
        self.assertIsNotNone(component)

        self.assertIsNotNone(component.config)
        component.config.reduce_scale = 2.0
        self.assertEqual(component.config.reduce_scale, 2.0)

        self.assertEqual(component.config['reduce_scale'], 2.0)
        component.config['reduce_scale'] = 3.0
        self.assertEqual(component.config['reduce_scale'], 3.0)
        self.assertEqual(component.config.reduce_scale, 3.0)

        self._app.start()
        self._app.stop()
Esempio n. 2
0
    def test_component_access(self):
        self._app = Application()
        self._app.add('node')

        node = self._app.nodes['node']
        self.assertIsNotNone(node)

        result = self._app.load_module('viewers')
        self.assertTrue(result)
        node.add(self._app.registry.isaac.viewers.ImageViewer)

        component = node.components['ImageViewer']
        self.assertTrue(isinstance(component, Component.Component))
        self.assertIsNotNone(component)

        self.assertEqual(node.components['ImageViewer'].config['target_fps'],
                         30.0)

        component = node.components['ImageViewer']
        self.assertTrue(isinstance(component, Component.Component))
        self.assertIsNotNone(component)

        self.assertEqual(node.components['ImageViewer'].config['target_fps'],
                         30.0)

        node.components['ImageViewer'].config['target_fps'] = 45.0
        self.assertEqual(node.components['ImageViewer'].config['target_fps'],
                         45.0)
Esempio n. 3
0
    def test_load_subgraph_in_asset_path(self):
        self._app = Application()
        self._app.add('node')

        # override the asset path to point to our test location
        self._app._asset_path = 'packages/pyalice/tests/mock_asset_path'

        # loads subgraph and checks if the node/component are created, config is good
        self._app.load('mock_installed_application_test.subgraph.json', 'foo')

        pynode = self._app.nodes['foo.camera_viewer']
        self.assertIsNotNone(pynode)
        component = pynode['ImageViewer']
        self.assertIsNotNone(component)

        fps_readback = self._app.nodes['foo.camera_viewer'].components[
            'ImageViewer'].config['target_fps']
        self.assertEqual(fps_readback, 11)

        camera_name_readback = self._app.nodes['foo.camera_viewer'].components[
            'ImageViewer'].config['camera_name']
        self.assertEqual(camera_name_readback, 'bar')

        self._app.start()
        self._app.stop()
Esempio n. 4
0
    def test_pose(self):
        self._app = Application()

        self._app.start()

        self.assertTrue(
            self._app.atlas.set_pose(
                'foo', 'bar', 1.0,
                [np.quaternion(1.0, 0.0, 0.0, 0.0),
                 np.array([0.0, 0.0, 0.0])]))
        self.assertTrue(
            self._app.atlas.set_pose(
                'foo', 'bar', 2.0,
                [np.quaternion(1.0, 0.0, 0.0, 0.0),
                 np.array([1.0, 2.0, 3.0])]))

        read_pose = self._app.atlas.pose('foo', 'bar', 1.5)
        self.assertIsNotNone(read_pose)
        self.assertEqual(len(read_pose), 2)

        q = read_pose[0]
        t = read_pose[1]
        self.assertLess(q.w - 1.0, 1e-6)
        self.assertLess(q.x - 0.0, 1e-6)
        self.assertLess(q.y - 0.0, 1e-6)
        self.assertLess(q.z - 0.0, 1e-6)
        self.assertLess(t[0] - 0.5, 1e-6)
        self.assertLess(t[1] - 1.0, 1e-6)
        self.assertLess(t[2] - 1.5, 1e-6)

        self._app.stop()
Esempio n. 5
0
 def test_wait_for_node_timeout(self):
     self._app = Application()
     self._app.load_module('behavior_tree')
     self._app.add('node').add(
         self._app.registry.isaac.behavior_tree.TimerBehavior)
     self._app.start()
     status = self._app.wait_for_node('node', duration=0.1)
     self._app.stop()
     self.assertEqual(str(status), 'Status.Running',
                      'Should still be in Status.Running')
Esempio n. 6
0
 def test_wait_for_node(self):
     self._app = Application()
     self._app.load_module('behavior_tree')
     self._app.add('node').add(
         self._app.registry.isaac.behavior_tree.TimerBehavior)
     self._app.start()
     status = self._app.wait_for_node('node')
     self._app.stop()
     self.assertEqual(str(status), 'Status.Success',
                      'Should reach Status.Success in 1 second.')
Esempio n. 7
0
    def test_load_module(self):
        self._app = Application()

        result = self._app.load_module('message_generators')
        self.assertTrue(result)

        component = self._app.registry.isaac.message_generators.ImageLoader
        self.assertIsNotNone(component)
        self.assertEqual(str(component),
                         "['isaac::message_generators::ImageLoader']")
Esempio n. 8
0
    def test_clock(self):
        self._app = Application()

        self._app.start()
        clock = self._app.clock
        self.assertIsNotNone(clock)
        self.assertIsNotNone(clock.time)
        cur_time = clock.time
        self.assertGreater(cur_time, 0.0)
        self.assertGreater(clock.time, cur_time)
        self._app.stop()
Esempio n. 9
0
    def test_perf_report(self):
        PERF_REPORT_PATH = '/tmp/perf_report'
        if os.path.exists(PERF_REPORT_PATH):
            os.remove(PERF_REPORT_PATH)

        self._app = Application(
            argv=['--performance_report_out', PERF_REPORT_PATH])
        self._app.load_module('behavior_tree')
        self._app.add('node').add(
            self._app.registry.isaac.behavior_tree.TimerBehavior)
        self._app.run(0.2)
        self.assertTrue(os.path.exists(PERF_REPORT_PATH))
Esempio n. 10
0
    def test_load_bogus_subgraph(self):
        bogus_json_filename = ''
        with tempfile.NamedTemporaryFile('w') as f:
            f.write('this is bogus json')
            bogus_json_filename = f.name

        self._app = Application()
        with self.assertRaises(ValueError):
            self._app.load('/no/such/file')

        with self.assertRaises(ValueError):
            self._app.load(bogus_json_filename)
Esempio n. 11
0
    def test_run_until_failure(self):
        now_secs = time.time()

        self._app = Application()
        self._app.add('failure')

        node_failure = self._app.nodes['failure']
        self.assertIsNotNone(node_failure)

        self._app.nodes['failure'].add(FailureLaterCodelet)

        self._app.run('failure')

        delta_secs = time.time() - now_secs
        self.assertGreater(delta_secs, 0.4)
Esempio n. 12
0
    def test_run_until_succeed(self):
        now_secs = time.time()

        self._app = Application()
        self._app.add('success')

        node_success = self._app.nodes['success']
        self.assertIsNotNone(node_success)

        self._app.nodes['success'].add(SucceedLaterCodelet)

        self._app.run('success')

        delta_secs = time.time() - now_secs
        self.assertGreater(delta_secs, 0.4)
Esempio n. 13
0
def main():
    # patching capnp paths. Needed if using isaac python API.
    patch_capnp_paths()

    # creating app
    app = Application(app_filename="app/graphs/graph.app.json")

    # adding python codelet to the hello_node in graph
    app.nodes["hello_node"].add(HelloWorld, "print")

    # configuring Websight webroot and assetroot. Needed if using isaac python API.
    configure_websight_root(app)

    # running the application
    app.run()
Esempio n. 14
0
    def test_expand_asset(self):
        self._app = Application()
        ws, path = self._app._app.expand_asset_path('@workspace_//foo/bar')
        self.assertEqual(path, 'external/workspace_/foo/bar')
        self.assertEqual(ws, 'workspace_')

        ws1 = self._app.home_workspace_name
        self.assertEqual(len(ws1), 0)
        self._app.home_workspace_name = 'workspace_'
        ws2 = self._app.home_workspace_name
        self.assertEqual(ws2, 'workspace_')

        ws3, path3 = self._app._app.expand_asset_path('@workspace_//foo/bar')
        self.assertEqual(ws3, 'workspace_')
        self.assertEqual(path3, 'foo/bar')
Esempio n. 15
0
def main():
    # patching capnp paths. Needed if using isaac python API.
    patch_capnp_paths()

    # creating app
    app = Application(app_filename="apps/hello_world_py/graphs/graph.app.json")

    # adding python codelets to graph
    app.nodes["sender"].add(Sender, "sender_component")
    app.nodes["receiver"].add(Receiver, "receiver_component")

    # configuring Websight webroot and assetroot. Needed if using isaac python API.
    configure_websight_root(app)

    # running the application
    app.run()
Esempio n. 16
0
    def test_get_component(self):
        self._app = Application()
        self._app.add('node')

        node = self._app.nodes['node']
        self.assertIsNotNone(node)

        # Get None if no component has such name
        component = node['ledger']
        self.assertIsNone(component)

        component = node['MessageLedger']
        self.assertIsNotNone(component)

        self._app.start()
        self._app.stop()
Esempio n. 17
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--simulate",
        action="store_true",
        help="uses issac sim unity3d instead of a v4l2 camera.",
    )
    args = parser.parse_args()

    if args.simulate:
        app_file = "apps/isaac_object_detection/graphs/detection_unity3d.app.json"
    else:
        app_file = "apps/isaac_object_detection/graphs/detection.app.json"

    app = Application(app_filename=app_file)
    app.nodes["edge_detector.subgraph.edge_detector"].add(EdgeDetector, "detector")
    app.run()
Esempio n. 18
0
    def test_node_start_stop(self):
        self._app = Application()

        result = self._app.load_module('message_generators')
        self.assertTrue(result)

        node = self._app.add('src')
        self.assertIsNotNone(node)
        component = node.add(
            self._app.registry.isaac.message_generators.PanTiltStateGenerator,
            'pantilt')
        component.config['tick_period'] = '20 Hz'
        self.assertIsNotNone(component)

        node_sink = self._app.add('sink')
        self.assertIsNotNone(node_sink)

        self._app.connect(component, 'target',
                          node_sink.components['MessageLedger'], 'rcv')

        self._app.start()

        time.sleep(0.1)
        msg = self._app.receive('sink', 'MessageLedger', 'rcv')
        self.assertIsNotNone(msg)

        node.stop()
        msg = self._app.receive('sink', 'MessageLedger', 'rcv')
        time.sleep(0.1)
        msg = self._app.receive('sink', 'MessageLedger', 'rcv')
        self.assertIsNone(msg)
        time.sleep(0.1)
        msg = self._app.receive('sink', 'MessageLedger', 'rcv')
        self.assertIsNone(msg)

        node.start()

        time.sleep(0.1)
        msg = self._app.receive('sink', 'MessageLedger', 'rcv')
        self.assertIsNotNone(msg)

        self._app.stop()

        with self.assertRaises(RuntimeError):
            self._app.stop()
class TestPyCodeletStatus(unittest.TestCase):
    '''
    Test loading subgraph via the application API
    '''
    @classmethod
    def setUpClass(cls):
        # method will be ran once before any test is ran
        pass

    @classmethod
    def tearDownClass(cls):
        # method will be ran once after all tests have run
        pass

    def setUp(self):
        # ran before each test
        return super().setUp()

    def tearDown(self):
        # ran after each test
        return super().tearDown()

    def test_report_status(self):
        self._app = Application()
        self._app.add('success')
        self._app.add('failure')

        node_success = self._app.nodes['success']
        self.assertIsNotNone(node_success)
        component = node_success.add(self._app.registry.isaac.alice.PyCodelet)
        self.assertIsNotNone(component)

        node_failure = self._app.nodes['failure']
        self.assertIsNotNone(node_failure)
        component = node_failure.add(self._app.registry.isaac.alice.PyCodelet)
        self.assertIsNotNone(component)

        self._app.nodes['success'].add(AlwaysSucceedCodelet)
        self._app.nodes['failure'].add(AlwaysFailureCodelet)

        self._app.start_wait_stop(1.5)

        self.assertEqual(node_success.status, Status.Success)
        self.assertEqual(node_failure.status, Status.Failure)
Esempio n. 20
0
    def test_node_accesor(self):
        self._app = Application()
        self._app.load_module('json')

        node = self._app.add('foo1')
        self.assertIsNotNone(node)
        component = node.add(self._app.registry.isaac.json.JsonToProto, 'bar1')
        self.assertIsNotNone(component)

        node = self._app.add('foo2')
        self.assertIsNotNone(node)
        component = node.add(self._app.registry.isaac.json.ProtoToJson, 'bar2')
        self.assertIsNotNone(component)

        self.assertIsNotNone(self._app.nodes['foo1'])
        self.assertIsNotNone(self._app.nodes['foo2'])
        self.assertIsNone(self._app.nodes['foo3'])

        self._app.start()
        self._app.stop()
Esempio n. 21
0
    def test_max_duration(self):
        time_now = time.time()
        self._app = Application(argv=['--max_duration', '0.5s'])
        self._app.load_module('behavior_tree')
        self._app.add('node').add(
            self._app.registry.isaac.behavior_tree.TimerBehavior)
        self._app.run(2.0)
        time_dt = time.time() - time_now

        self.assertLess(time_dt, 1.0)

        time_now = time.time()
        self._app = Application(argv=['--max_duration', '0.5s'])
        self._app.load_module('behavior_tree')
        self._app.add('node').add(
            self._app.registry.isaac.behavior_tree.TimerBehavior)
        self._app.run(2)
        time_dt = time.time() - time_now

        self.assertLess(time_dt, 1.0)
    def test_report_status(self):
        self._app = Application()
        self._app.add('success')
        self._app.add('failure')

        node_success = self._app.nodes['success']
        self.assertIsNotNone(node_success)
        component = node_success.add(self._app.registry.isaac.alice.PyCodelet)
        self.assertIsNotNone(component)

        node_failure = self._app.nodes['failure']
        self.assertIsNotNone(node_failure)
        component = node_failure.add(self._app.registry.isaac.alice.PyCodelet)
        self.assertIsNotNone(component)

        self._app.nodes['success'].add(AlwaysSucceedCodelet)
        self._app.nodes['failure'].add(AlwaysFailureCodelet)

        self._app.start_wait_stop(1.5)

        self.assertEqual(node_success.status, Status.Success)
        self.assertEqual(node_failure.status, Status.Failure)
def run(task):
    '''
        Given a task description, starts the application, waits for the node to stop
        running or for the duration to lapse. Stops the application after the execution.

        Can be used standalone or with the run_parallel helper.

        Example:
        >>> task = {
        >>>         'app_filename' : 'packages/detect_net/apps/apriltags_process.app.json',
        >>>         'more_json' : {
        >>>              "config": {
        >>>                  "replay.interface": {"output": {"cask_directory": root}},
        >>>                  "record.interface": {"input": {"base_directory": apriltags_root}}
        >>>              }
        >>>         },
        >>>         'success_node': "replay.interface",
        >>>         'duration': 2040.0, 'poll_interval': 1.0, 'exit_interval': 1.0
        >>>        }
        >>>
        >>> run(task)

        Args:
            task['app_filename'] (str): the main application json filename
            task['more_json'] (dict): a dictionary containing additional configuration,
                                   to serialize into json and load as more_jsons to the app
            task['more_jsons'] (str): a comma-separated string of additional jsons to load
            task['name'] (str): the name of the application
            task['modules'] (List(str)): a list of modules to be loaded
            task['argv']: Command line arguments from sys.argv
            task['success_node'] (string): the name of the node to wait to stop running
            task['duration'] (float): timeout in seconds, can run forever, if duration is None
            task['exit_interval'] (float): exit interval in seconds

        Returns: True, if the success status had been reached.  False otherwise.
    '''
    with tempfile.NamedTemporaryFile(mode='w+t', suffix='.json',
                                     delete=True) as more_json:
        json.dump(task['more_json'], more_json)
        more_json.flush()
        more_jsons = ((task['more_jsons'] +
                       ',') if 'more_jsons' in task else '') + more_json.name
        app = Application(app_filename=task['app_filename'],
                          more_jsons=more_jsons,
                          name=task.get('name', None),
                          modules=task.get('modules', None),
                          argv=task.get('argv', sys.argv))

    app.start()
    status = app.wait_for_node(task['success_node'], task['duration'])
    time.sleep(task['exit_interval'])
    app.stop()
    return status == bindings.Status.Success
Esempio n. 24
0
    def test_print_node(self):
        self._app = Application()
        self._app.add('foo')

        node_names = self._app.nodes._names
        self.assertTrue(isinstance(node_names, list) and 'foo' in node_names)

        self._app.add('bar')
        node_names = self._app.nodes._names
        self.assertTrue(
            isinstance(node_names, list) and 'foo' in node_names
            and 'bar' in node_names)

        foo_node = None
        bar_node = None
        for n in self._app.nodes:
            if n.name == 'foo':
                foo_node = n
            if n.name == 'bar':
                bar_node = n

        self.assertIsNotNone(foo_node)
        self.assertIsNotNone(bar_node)
Esempio n. 25
0
    def test_load_subgraph(self):
        self._app = Application()
        self._app.add('node')

        # loads subgraph and checks if the node/component are created, config is good
        self._app.load('packages/pyalice/tests/application_test.subgraph.json',
                       'foo')

        node = self._app.nodes['foo.camera_viewer']
        component = node['ImageViewer']
        self.assertIsNotNone(component)

        fps_readback = self._app.nodes['foo.camera_viewer'].components[
            'ImageViewer'].config['target_fps']
        self.assertEqual(fps_readback, 11)

        camera_name_readback = self._app.nodes['foo.camera_viewer'].components[
            'ImageViewer'].config['camera_name']
        self.assertEqual(camera_name_readback, 'bar')

        # loads the subgraph again with different prefix name
        self._app.load('packages/pyalice/tests/application_test.subgraph.json',
                       'foo1')
        node = self._app.nodes['foo1.camera_viewer']
        component = node['ImageViewer']
        self.assertIsNotNone(component)

        fps_readback = self._app.nodes['foo1.camera_viewer'].components[
            'ImageViewer'].config['target_fps']
        self.assertEqual(fps_readback, 11)

        camera_name_readback = self._app.nodes[
            'foo1.camera_viewer'].components['ImageViewer'].config[
                'camera_name']

        self._app.start()
        self._app.stop()
Esempio n. 26
0
def main():
    patch_capnp_paths()
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--simulate",
        action="store_true",
        help="uses issac sim unity3d instead of a v4l2 camera.",
    )
    args = parser.parse_args()

    if args.simulate:
        app_file = "app/graphs/edge_detection_unity3d.app.json"
    else:
        app_file = "app/graphs/edge_detection.app.json"

    # creating app
    app = Application(app_filename=app_file)

    # adding EdgeDetector codelet to the detector component of the edge_detector node
    app.nodes["edge_detector"].add(EdgeDetector, "detector")
    configure_websight_root(app)

    # running the application
    app.run()
 parser.add_argument('--framerate',
                     dest='framerate',
                     action='store',
                     type=int,
                     default=60,
                     help='Camera framerate')
 parser.add_argument('--device_id',
                     dest='device_id',
                     action='store',
                     type=int,
                     help='Camera device id')
 args = parser.parse_args()
 # Create april_tag_python application
 app = Application(name="april_tags_python",
                   modules=[
                       "//packages/fiducials:april_tags", "realsense",
                       "sensors:v4l2_camera", "sight", "viewers", "zed"
                   ])
 # Setup camera node
 camera = None
 if args.camera == "zed":
     camera = app.add('input_images').add(app.registry.isaac.ZedCamera)
     camera.config.resolution = args.resolution
     camera.config.camera_fps = args.framerate
     camera_out_channel = "left_camera_rgb"
 elif args.camera == "realsense":
     camera = app.add('input_images').add(
         app.registry.isaac.RealsenseCamera)
     camera.config.cols, camera.config.rows = tuple(
         [int(arg) for arg in args.resolution.split('x')])
     camera.config.color_framerate = args.framerate
Esempio n. 28
0
        description='Demonstrates the simulation integration with SVIO')
    parser.add_argument(
        "--map_json",
        help="The path to the map json to load into simulation",
        default="apps/assets/maps/virtual_medium_warehouse.json")
    parser.add_argument(
        "--robot_json",
        help="The path to the robot json to load into simulation",
        default="packages/navsim/robots/carter_stereo_with_bumper.json")
    parser.add_argument(
        "--more",
        help="A comma separated list of additional json files to load")
    args = parser.parse_args()

    # Create the app and load the required subgraphs
    app = Application(name="sim_svio")
    app.load_module("atlas")
    app.load_module('behavior_tree')
    app.load_module('sight')
    app.load_module('utils')
    app.load_module("viewers")
    app.load("packages/navsim/apps/navsim_navigation.subgraph.json",
             "simulation")
    app.load(
        "packages/navigation/apps/differential_base_navigation.subgraph.json",
        "navigation")
    app.load("packages/navigation/apps/goal_generators.subgraph.json", "goals")
    app.load(
        "packages/visual_slam/apps/stereo_visual_odometry_rgb.subgraph.json",
        "svo")
Esempio n. 29
0
                        help='The directory in which log files will be stored')
    parser.add_argument('--num_nodes',
                        dest='num_nodes',
                        default=10,
                        help='Number of virtual lidar nodes to run')
    parser.add_argument('--points_per_message',
                        dest='points_per_message',
                        default=10,
                        help='Number of virtual lidar points to generate at each tick per node')
    parser.add_argument('--node_tick_rate',
                        dest='node_tick_rate',
                        default='50Hz',
                        help='Rate at which each node should generate sets of points')
    args, _ = parser.parse_known_args()

    app = Application(name="record_small_point_clouds_test",
                      modules=["message_generators", "cask", "sight"])
    app.load_module("cask")
    app.load_module("sight")
    recorder = app.add("recorder").add(app.registry.isaac.cask.Recorder)
    recorder.config.base_directory = args.base_directory

    generators = list()
    for i in range(int(args.num_nodes)):
        pcd = app.add("cam" + str(i)).add(app.registry.isaac.message_generators.PointCloudGenerator)
        pcd.config.point_count = 100000000
        pcd.config.point_per_message = int(args.points_per_message)
        pcd.config.tick_period = args.node_tick_rate

        generators.append(pcd)
        app.connect(generators[i - 1], "point_cloud", recorder, "point_cloud" + str(i))
Esempio n. 30
0
        '  using the live stereo image feed obtained from the ZED (Mini) camera.'
    )
    parser.add_argument(
        '--imu',
        dest='imu',
        action='store_true',
        help='Enables the support for the on-board camera IMU.')
    parser.add_argument(
        '--no-imu',
        dest='imu',
        action='store_false',
        help='Disables the support for the on-board camera IMU.')
    parser.set_defaults(imu=False)
    args, _ = parser.parse_known_args()

    app = Application(name="svo_zed", modules=["zed"])

    app.load(
        "packages/visual_slam/apps/stereo_visual_odometry_grayscale.subgraph.json",
        "svo")
    svo_interface = app.nodes["svo.subgraph"].components["interface"]

    camera = app.add('camera').add(app.registry.isaac.ZedCamera)
    camera.config.enable_factory_rectification = True
    camera.config.enable_imu = args.imu
    camera.config.camera_fps = 60
    camera.config.resolution = "672x376"
    camera.config.gray_scale = True
    camera.config.rgb = False

    tracker = app.nodes['svo.tracker'].components['StereoVisualOdometry']