def test_generate_kpis(self):        
        self.assertIn('recording.bag', os.listdir(ROOT_PATH),'recording.bag cannot be found')

        sim_eval = Evaluation(ROSBAG, RESULTS_DIR)        
        sim_eval.compute_kpis()

        self.assertTrue(type(sim_eval.get_kpis()) == dict, 'KPIs structure is not a dictionary')
Ejemplo n.º 2
0
    def test_generate_kpis(self):        
        runner = SimulationRunner(PARAMS, TASK, RESULTS_DIR, True)
        runner.run(PARAMS)

        self.assertIn('recording.bag', os.listdir(runner.current_sim_results_dir),'recording.bag cannot be found')

        sim_eval = Evaluation(runner.recording_filename, runner.current_sim_results_dir)        
        sim_eval.compute_kpis()

        self.assertTrue(type(sim_eval.get_kpis()) == dict, 'KPIs structure is not a dictionary')
                traj.append(sim_eval.get_trajectory_coord('actual'))

                error_t.append(sim_eval._error_set.get_time())
                error_vec.append(
                    KPI.get_error(sim_eval._error_set.get_data('position')))
                error_yaw_vec.append(sim_eval._error_set.get_data('yaw'))

                if t_cur is None:
                    t_cur, vec_cur = sim_eval._bag.get_current_vel()

                if t_force is None:
                    t_force, vec_force, vec_torque = sim_eval._bag.get_wrench_dist(
                    )

                kpis = sim_eval.get_kpis()

                kpi_results.append(kpis)

                cur_cost = 0.0
                for tag in opt_config['cost_fcn']:
                    cur_cost += sim_eval.get_kpi(
                        tag) * opt_config['cost_fcn'][tag]

                with open(
                        os.path.join(runner.current_sim_results_dir,
                                     'smac_result.yaml'), 'w') as smac_file:
                    yaml.dump(dict(cost=float(cur_cost)),
                              smac_file,
                              default_flow_style=False)