Exemplo n.º 1
0
int epos_home(epos_node_p node, double timeout) {
  epos_home_t home;
  epos_home_init(&home,
    config_get_int(&node->config, EPOS_PARAMETER_HOME_METHOD),
    config_get_float(&node->config, EPOS_PARAMETER_HOME_CURRENT),
    deg_to_rad(config_get_float(&node->config, EPOS_PARAMETER_HOME_VELOCITY)),
    deg_to_rad(config_get_float(&node->config, 
      EPOS_PARAMETER_HOME_ACCELERATION)),
    deg_to_rad(config_get_float(&node->config, EPOS_PARAMETER_HOME_POSITION)));
  home.type = config_get_int(&node->config, EPOS_PARAMETER_HOME_TYPE);
  home.offset = deg_to_rad(config_get_float(&node->config, 
    EPOS_PARAMETER_HOME_OFFSET));

  if (!epos_home_start(node, &home)) {
    epos_home_wait(node, timeout);
    return EPOS_ERROR_NONE;
  }
  else
    return EPOS_ERROR_HOME;
}
Exemplo n.º 2
0
int main(int argc, char **argv) {
  config_parser_t parser;
  epos_node_t node;

  config_parser_init(&parser,
    "Start EPOS controller in homing mode",
    "Establish the communication with a connected EPOS device and attempt to "
    "start the controller in homing mode. The controller will be stopped "
    "if SIGINT is received or the homing operation is completed. The "
    "communication interface depends on the momentarily selected alternative "
    "of the underlying CANopen library.");  
  epos_node_init_config_parse(&node, &parser, 0, argc, argv,
    config_parser_exit_error);
  config_parser_destroy(&parser);
  
  signal(SIGINT, epos_signaled);

  epos_node_connect(&node);
  error_exit(&node.error);

  epos_node_home(&node, 0.0);
  if (node.dev.error.code != EPOS_DEVICE_ERROR_WAIT_TIMEOUT)
    error_exit(&node.error);
  
  while (!quit) {
    if (epos_home_wait(&node, 0.1) != EPOS_DEVICE_ERROR_WAIT_TIMEOUT)
      error_exit(&node.dev.error);
  };
  
  epos_home_stop(&node);
  error_exit(&node.dev.error);
  
  epos_node_disconnect(&node);
  error_exit(&node.error);

  epos_node_destroy(&node);
  return 0;
}