Ejemplo n.º 1
0
void iter_ext_kalman_step( m_elem *z_in )
{
  int     iteration = 1;
  m_elem  est_change;
  m_elem  *prev_state;
  m_elem  *new_state;
  m_elem  *temp;

  generate_system_transfer( state_pre, sys_transfer );
  estimate_prob( cov_post, sys_transfer, sys_noise_cov, cov_pre );
  apply_system( state_post, state_pre );

  /*  Now iterate, updating the probability and the system model
      until no change is noticed between iteration steps      */

  prev_state = iter_state0;
  new_state  = iter_state1;

  generate_measurement_transfer( state_pre, mea_transfer );
  update_prob( cov_pre, mea_noise_cov, mea_transfer,
          cov_post, kalman_gain );
  update_system( z_in, state_pre, kalman_gain, prev_state );
  est_change = calc_state_change( state_pre, prev_state );

  while( (est_change < ITERATION_THRESHOLD) &&
    (iteration++ < ITERATION_DIVERGENCE) )
    {
#ifdef DEBUG_ITER      
      print_vector( "\titer state", prev_state, 10 );
#endif
      /*  Update the estimate  */

      generate_measurement_transfer( prev_state, mea_transfer );
      update_prob( cov_pre, mea_noise_cov, mea_transfer,
          cov_post, kalman_gain );
      update_system( z_in, prev_state, kalman_gain, new_state );
      est_change = calc_state_change( prev_state, new_state );

      temp = prev_state;
      prev_state = new_state;
      new_state = temp;
    }

  vec_copy( prev_state, state_post, state_size );

#ifdef PRINT_DEBUG
  printf( "iekf: step %3d, %2d iters\n", global_step, iteration );
#endif
  global_step++;
}
Ejemplo n.º 2
0
void extended_kalman_step( uFloat *z_in )
{
#ifdef PRINT_DEBUG
  printf( "ekf: step %d\n", global_step );
#endif

#ifdef PRINT_DEBUG
	printVector( "measurements ", z_in, MEAS_SIZE );
#endif
  /*****************  Gain Loop  *****************
    First, linearize locally, then do normal gain loop    */

  generate_system_transfer( state_pre, sys_transfer );
  generate_measurement_transfer( state_pre, mea_transfer );

  estimate_prob( cov_post, sys_transfer, sys_noise_cov, cov_pre );
  update_prob( cov_pre, mea_noise_cov, mea_transfer, cov_post, kalman_gain );

  /**************  Estimation Loop  ***************/

  rungeKutta( state_post, state_pre );
  update_system( z_in, state_pre, kalman_gain, state_post );

  global_step++;
}
Ejemplo n.º 3
0
void kalman_step( m_elem *z_in )
{
  /**************  Estimation Loop  ***************/

  apply_system( state_post, state_pre );
  update_system( z_in, state_pre, kalman_gain, state_post );

  global_step++;
}
Ejemplo n.º 4
0
int main(int argc, char **argv)
{
	unsigned i;
	conf_t *conf;
	dict_t *repositories;
	dict_t *ports_dict;
	dict_t *not_founds;
	list_t *ports_list;
	list_t *packages;
	list_t *list;
	list_t *drivers;
	struct arguments arguments;

	arguments.action = 0;
	arguments.no_favourite_repositories = 0;
	arguments.no_locked_versions = 0;
	arguments.no_aliases = 0;
	arguments.no_colors = 0;
	arguments.no_deps = 1;
	arguments.all = 0;
	arguments.fetch_only = 0;
	arguments.no_repositories_hierarchy = 0;
	arguments.tree = 0;
	arguments.verbose = 0;
	arguments.rebuild_cache = 0;
	arguments.args = list_new();

	if (argc < 2) {
		char *fake_arg[2];
		fake_arg[0] = "ilenia";
		fake_arg[1] = "--help";
		argp_parse(&argp, 2, fake_arg, 0, 0, &arguments);
	}

	argp_parse(&argp, argc, argv, 0, 0, &arguments);

	conf = conf_init();

	if (arguments.no_repositories_hierarchy) {
		list_free(conf->repositories_hierarchy, free);
		conf->repositories_hierarchy = list_new();
	}

	if (arguments.no_favourite_repositories) {
		dict_free(conf->favourite_repositories, NULL);
		conf->favourite_repositories = dict_new();
	}

	if (arguments.no_locked_versions) {
		dict_free(conf->locked_versions, free);
		conf->locked_versions = dict_new();
	}

	if (arguments.no_aliases) {
		aliases_free(conf->aliases);
		conf->aliases = dict_new();
	}

	drivers = drivers_list_init();
	repositories = repositories_dict_init(drivers,
					      conf->repositories_hierarchy);
	if (!conf->enable_colors || arguments.no_colors)
		cprintf = uncoloredprintf;
	else
		cprintf = coloredprintf;

	if (arguments.rebuild_cache)
		cache_build(repositories);
	packages = packages_list_init();
	if ((ports_list = ports_list_init(repositories)) == NULL) {
		list_free(arguments.args, NULL);
		dict_free(repositories, repository_free);
		list_free(packages, port_free);
		list_free(drivers, free);
		dict_free(conf->favourite_repositories, free);
		conf->favourite_repositories = dict_new();
		conf_free(conf);
		return 1;
	}

	conf_reparse(conf, ports_list);
	ports_dict = ports_dict_init(ports_list, packages, conf);
	not_founds = dict_new();

	if (!arguments.verbose)
		arguments.verbose = conf->verbose;

	switch (arguments.action) {
	case ACT_LIST:
		if (!arguments.args->length) {
			list_dump(ports_list, port_dump);
			break;
		}
		for (i = 0; i < arguments.args->length; i++) {
			if (dict_get(repositories, list_get(arguments.args, i))
			    == NULL) {
				warning("repository %s not found!",
					list_get(arguments.args, i));
				continue;
			}
			list = list_query(ports_list,
					  port_query_by_repository,
					  list_get(arguments.args, i));
			list_dump(list, port_dump);
			list_free(list, NULL);
		}
		break;
	case ACT_SEARCH:
		if (!arguments.args->length) {
			warning("action --search (-s) requires at least an "
				"argument!");
			break;
		}
		for (i = 0; i < arguments.args->length; i++) {
			list = list_query(ports_list, port_query_by_name,
					  list_get(arguments.args, i));
			if (arguments.verbose)
				list_dump(list, port_info_dump);
			else
				list_dump(list, port_dump);
			if (list->length == 0)
				printf("%s not found!\n",
				       (char *)list_get(arguments.args, i));
			list_free(list, NULL);
		}
		break;
	case ACT_SEARCHDESC:
		if (!arguments.args->length) {
			warning("action --search-desc requires at least an "
				"argument!");
			break;
		}
		for (i = 0; i < arguments.args->length; i++) {
			char *key = xstrdup(list_get(arguments.args, i));
			if (isalpha(*key) && isalpha(*(key + strlen(key) - 1))) {
				strprepend(&key, "*");
				strappend(&key, "*");
			}
			list = list_query(ports_list, port_query_by_description,
					  key);
			if (arguments.verbose)
				list_dump(list, port_info_dump);
			else
				list_dump(list, port_dump);
			list_free(list, NULL);
			free(key);
		}
		break;
	case ACT_DIFF:
		port_show_diffs(ports_dict, packages);
		break;
	case ACT_UPDATED:
		port_show_outdated(ports_dict, packages);
		break;
	case ACT_DEPENDENCIES:
		if (!arguments.args->length) {
			warning("action --dependencies (-D) requires at "
				"least an argument!");
			break;
		}
		//for (i = 0; i < arguments.args->length; i++)
		dependencies_dump(arguments.args,
				  ports_dict, conf->aliases,
				  not_founds,
				  arguments.tree, arguments.verbose);
		break;
	case ACT_DEPENDENTS:
		if (!arguments.args->length) {
			warning("action --dependents (-T) requires at "
				"least an argument!");
			break;
		}
		for (i = 0; i < arguments.args->length; i++)
			dependents_dump(list_get(arguments.args, i),
					ports_dict, conf->aliases,
					arguments.tree, arguments.verbose,
					arguments.all);
		break;
	case ACT_INFO:
		if (!arguments.args->length) {
			warning("action --info requires at "
				"least an argument!");
			break;
		}
		for (i = 0; i < arguments.args->length; i++)
			info_dump(list_get(arguments.args, i), ports_dict);
		break;
	case ACT_README:
		if (!arguments.args->length) {
			warning("action --show-readme requires at "
				"least an argument!");
			break;
		}
		for (i = 0; i < arguments.args->length; i++)
			readme_dump(list_get(arguments.args, i), ports_dict);
		break;
	case ACT_REPOSITORY_LIST:
		repositories_dict_dump(repositories);
		break;
	case ACT_UPDATE:
		if (arguments.args->length)
			repositories_dict_update(repositories, arguments.args);
		else
			repositories_dict_update_all(repositories);
		break;
	case ACT_REMOVE:
		if (!arguments.args->length) {
			warning("action --remove (-R) requires at "
				"least an argument!");
			break;
		}
		remove_packages(arguments.args, packages, ports_dict, conf,
				arguments.all);
		break;
	case ACT_UPDATE_PKG:
		if (!arguments.args->length) {
			update_system(ports_dict,
				      conf->aliases, arguments.fetch_only,
				      conf->ask_for_update,
				      conf->not_found_policy);
			break;
		}
		update_package(arguments.args, ports_dict, conf,
			       arguments.fetch_only);
		break;
	default:
		if (!arguments.rebuild_cache)
			warning("What can I do for you?");
	}

	list_free(arguments.args, NULL);
	dict_free(repositories, repository_free);
	list_free(ports_list, port_free);
	list_free(packages, port_free);
	dict_free(ports_dict, NULL);
	list_free(drivers, free);
	conf_free(conf);
	dict_free(not_founds, port_free);

	return 0;
}
Ejemplo n.º 5
0
int main(int argc, char **argv)
{
	struct arguments arguments;

	arguments.action = 0;
	arguments.no_favorite_repo = 0;
	arguments.no_favorite_version = 0;
	arguments.no_deps = 1;
	arguments.all = 0;
	arguments.args = NULL;

	if (argc < 2) {
		char *fake_arg[2];
		fake_arg[0] = "ilenia";
		fake_arg[1] = "--help";
		argp_parse(&argp, 2, fake_arg, 0, 0, &arguments);
	}

	argp_parse(&argp, argc, argv, 0, 0, &arguments);

	if (parse_ileniarc() != 0)
		return (EXIT_FAILURE);

	ilenia_repos = build_repolist();

	if (arguments.action == ACT_CACHE) {
		FILE *file;
		if ((file = fopen(CACHE, "w")))
			fclose(file);
	}

	ilenia_favoriterepo = get_favorite(FAVORITE_REPO);
	ilenia_favoriteversion = get_favorite(FAVORITE_VERSION);
	ilenia_aliases = aliaseslist_build();
	ilenia_ports = lsports();
	ilenia_pkgs = lspkgs();
	ilenia_favoritepkgmk = pkgmklist_build();

	if (arguments.action > 21 || arguments.action == 0)
		error("%s", "please perform an action at a time!");

	int confront_options =
	    arguments.no_favorite_repo + arguments.no_favorite_version;

	int update_options = arguments.no_deps;
	if (confront_options)
		update_options = confront_options * update_options;

	int status = EXIT_SUCCESS;

	if (arguments.action == ACT_UPDATE) {
		if (arguments.args == NULL) {
			status = update_all_repos();
			return (EXIT_SUCCESS);
		}
		while (arguments.args) {
			status = update_repo(arguments.args->data);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_LIST) {
		if (arguments.args == NULL) {
			pkglist_print(ilenia_ports);
			return (EXIT_SUCCESS);
		}
		while (arguments.args) {
			if (repolist_exists(arguments.args->data,
					    ilenia_repos)) {
				warning("repository %s not found!\n",
					arguments.args->data);
				arguments.args = arguments.args->next;
				continue;
			}
			pkglist_print(pkglist_select_from_repo
				      (arguments.args->data,
				       ilenia_ports));
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_SEARCH) {
		if (arguments.args == NULL)
			error("action search requires an argument!");
		while (arguments.args) {
			pkglist_print(pkglist_find_like
				      (arguments.args->data,
				       ilenia_ports));
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_INFO) {
		if (arguments.args == NULL)
			error("action info requires an argument!");
		while (arguments.args) {
			info(arguments.args->data, confront_options);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_DIFF)
		pkglist_confront(DIFF, confront_options, 1);

	if (arguments.action == ACT_UPDATED)
		pkglist_confront(UPDATED, confront_options, 1);

	if (arguments.action == ACT_DEPENDENCIES) {
		if (arguments.args == NULL)
			error("action dependencies requires an argument!");
		while (arguments.args) {
			print_dependencies(arguments.args->data);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_UPDATE_PKG) {
		if (arguments.args == NULL) {
			status = update_system(update_options);
			return status;
		}
		while (arguments.args) {
			status =
			    update_pkg(update_options,
				       arguments.args->data);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_DEPENDENTS) {
		if (arguments.args == NULL)
			error("action dependents requires an argument!");
		while (arguments.args) {
			print_dependents(arguments.args->data,
					 arguments.all);
			arguments.args = arguments.args->next;
		}
	}

	if (arguments.action == ACT_REMOVE) {
		if (arguments.args == NULL)
			error("action remove requires an argument!");
		while (arguments.args) {
			status =
			    remove_pkg(arguments.args->data,
				       arguments.no_deps, arguments.all);
			arguments.args = arguments.args->next;
		}
	}


	if (arguments.action == ACT_REPOSITORY_LIST) {
		while (ilenia_repos != NULL) {
			printf("name %s path %s\n", ilenia_repos->name,
			       ilenia_repos->path);
			ilenia_repos = ilenia_repos->next;
		}
	}

	return status;
}