Ejemplo n.º 1
0
Walker::Walker(double maxInitTime, double jointSpaceTolerance, double jointVelContinuityTolerance) :
        m_maxInitTime(maxInitTime),
        m_jointSpaceTolerance( jointSpaceTolerance ),
        m_jointVelContTol( jointVelContinuityTolerance ),
        keepWalking(true),
        hubo()
{
    ach_status_t r = ach_open( &zmp_chan, HUBO_CHAN_ZMP_TRAJ_NAME, NULL );
    if( r != ACH_OK )
        fprintf( stderr, "Problem with channel %s: %s (%d)\n",
                HUBO_CHAN_ZMP_TRAJ_NAME, ach_result_to_string(r), (int)r );
    
    r = ach_open( &param_chan, BALANCE_PARAM_CHAN, NULL );
    if( r != ACH_OK )
        fprintf( stderr, "Problem with channel %s: %s (%d)\n",
                BALANCE_PARAM_CHAN, ach_result_to_string(r), (int)r );

    r = ach_open( &bal_cmd_chan, BALANCE_CMD_CHAN, NULL );
    if( r != ACH_OK )
        fprintf( stderr, "Problem with channel %s: %s (%d)\n",
                BALANCE_CMD_CHAN, ach_result_to_string(r), (int)r );

    r = ach_open( &bal_state_chan, BALANCE_STATE_CHAN, NULL );
    if( r != ACH_OK )
        fprintf( stderr, "Problem with channel %s: %s (%d)\n",
                BALANCE_STATE_CHAN, ach_result_to_string(r), (int)r );

    memset( &cmd, 0, sizeof(cmd) );
    memset( &bal_state, 0, sizeof(bal_state) );
} 
Ejemplo n.º 2
0
static PyObject *
open_channel( PyObject *self, PyObject *args ) {
    (void)self;
    const char *name = NULL;
    long frame_count = 0, frame_size = 0;
    if( !PyArg_ParseTuple(args, "sll", &name, &frame_count, &frame_size ) ) {
        return NULL;
    }
    /* Alloc struct */
    ach_channel_t *c = (ach_channel_t*)malloc(sizeof(ach_channel_t));

    /* Open it */
    ach_status_t r = ach_open(c, name, NULL);

    /* Create channel if necessary */
    if( ACH_ENOENT == r ) {
        r = ach_create( name, (size_t)frame_count, (size_t)frame_size, NULL );
        if( ach_status_match(r, ACH_MASK_OK | ACH_MASK_EEXIST) ) {
            r = ach_open(c, name, NULL);
        }
    }

    /* Check result */
    if( ACH_OK != r ) {
        return raise_error(r);
    }

    return PyLong_FromVoidPtr(c);
}
Ejemplo n.º 3
0
/**
 * Open up the ACH simulation channels. 
 */
SimChannels::SimChannels(){
	memset(&H_virtual, 0, sizeof(H_virtual));
    
    int r = ach_open(&huboToSimChannel, HUBO_CHAN_VIRTUAL_TO_SIM_NAME, NULL);
    if (ACH_OK != r)
        std::cerr << "Error! To Sim Channel failed with state " << r << std::endl;
   
    r = ach_open(&huboFromSimChannel, HUBO_CHAN_VIRTUAL_FROM_SIM_NAME, NULL);
    if (ACH_OK != r)
        std::cerr << "Error! From Sim Channel failed with state " << r << std::endl;
}
// Function to get encoder value from the Ach channel
double* getEncoderValues(){
    static double encoderValues[40];

    int t2 = ach_open(&chan_hubo_state, HUBO_CHAN_STATE_NAME, NULL);
    assert( ACH_OK == t2);

    // open to sim chan
    int t1 = ach_open(&chan_hubo_from_sim, HUBO_CHAN_VIRTUAL_FROM_SIM_NAME, NULL);
    assert( ACH_OK == t1);

    struct hubo_state H_state;
    size_t fs;
    int r= ach_get( &chan_hubo_state, &H_state, sizeof(H_state), &fs, NULL, ACH_O_LAST );
    if(hubo_debug) {
        //		printf("State ini r = %s\n",ach_result_to_string(r));
    }
    else{
        assert( sizeof(H_state) == fs );
    }

    encoderValues[0]=H_state.joint[RHY].pos;
    encoderValues[1]=H_state.joint[RHR].pos;
    encoderValues[2]=H_state.joint[RHP].pos;
    encoderValues[3]=H_state.joint[RKN].pos;
    encoderValues[4]=H_state.joint[RAP].pos;
    encoderValues[5]=H_state.joint[RAR].pos;
    encoderValues[6]=H_state.joint[LHY].pos;
    encoderValues[7]=H_state.joint[LHR].pos;
    encoderValues[8]=H_state.joint[LHP].pos;
    encoderValues[9]=H_state.joint[LKN].pos;
    encoderValues[10]=H_state.joint[LAP].pos;
    encoderValues[11]=H_state.joint[LAR].pos;
    encoderValues[12]=H_state.joint[RSP].pos;
    encoderValues[13]=H_state.joint[RSR].pos;
    encoderValues[14]=H_state.joint[RSY].pos;
    encoderValues[15]=H_state.joint[REB].pos;
    encoderValues[16]=H_state.joint[RWY].pos;
    encoderValues[17]=H_state.joint[RWR].pos;
    encoderValues[18]=H_state.joint[RWP].pos;
    encoderValues[19]=H_state.joint[LSP].pos;
    encoderValues[20]=H_state.joint[LSR].pos;
    encoderValues[21]=H_state.joint[LSY].pos;
    encoderValues[22]=H_state.joint[LEB].pos;
    encoderValues[23]=H_state.joint[LWY].pos;
    encoderValues[24]=H_state.joint[LWR].pos;
    encoderValues[25]=H_state.joint[LWP].pos;
    encoderValues[26]=H_state.joint[NKY].pos;
    encoderValues[27]=H_state.joint[NK1].pos;
    encoderValues[28]=H_state.joint[NK2].pos;
    encoderValues[29]=H_state.joint[WST].pos;
    return encoderValues;

}
Ejemplo n.º 5
0
int main(int argc, char* argv[] ) 
{
  // Copy to char pointers
  char outputChanChar[1024];
  strcpy(outputChanChar, PERCEPTION_CHANNEL.c_str());
  char debugChanChar[1024];
  strcpy(debugChanChar, DEBUG_CHANNEL.c_str());

  // open the channels
  int r = ach_open( &channel, outputChanChar, NULL );
  int rdebug = ach_open( &debug_channel, debugChanChar, NULL );

  assert(ACH_OK == r && ACH_OK == rdebug);

  r = ach_flush(&channel);
  r = ach_flush(&debug_channel);

  // test receive
  double rtraj[NUM_OBJECTS][NDIM];
  memset(rtraj, 0, NUM_OBJECTS*NDIM*sizeof(double));
  size_t frame_size;

  while( true ) {

    r = ach_get( &channel, &rtraj, 
		 sizeof(rtraj), 
		 &frame_size, 
		 NULL, 
		 ACH_O_WAIT );
    
    std::cout << "Received traj (visible, x, y, angle): " << std::endl; 
    print_arr_2d( rtraj, NUM_OBJECTS );

    // DEBUG CHANNEL
    r = ach_get( &debug_channel, &rtraj, 
		 sizeof(rtraj), 
		 &frame_size, 
		 NULL, 
		 ACH_O_WAIT );
    
    std::cout << "[DEBUG] Received traj (visible, x, y, angle): " << std::endl; 
    print_arr_2d( rtraj, NUM_OBJECTS );


    // Read every second
    usleep(1.0*1e6);

  }

}
Ejemplo n.º 6
0
void openAllCAN(int vCan) {
	int skt1;
	int skt0;
	if(HUBO_VIRTUAL_MODE_VIRTUAL == vCan | HUBO_VIRTUAL_MODE_OPENHUBO == vCan){
		skt1    =       openCAN("vcan1");
		skt0	=	openCAN("vcan0");
	}
	else {
		skt1    =       openCAN("can1");
		skt0	=	openCAN("can0");
	}
	//H.socket[0]   =	skt0;
	hubo_socket[0]  =	skt0;
	//H.socket[1]	=	skt1;
	hubo_socket[1]	=	skt1;

        ach_status_t result = ach_open(&iotrace_chan,
                                       IO_TRACE_CHAN_NAME,
                                       NULL);

        have_iotrace_chan = (result == ACH_OK);
        fprintf(stderr, "open iotrace channel: %s\n", 
                ach_result_to_string(result));

}
Ejemplo n.º 7
0
Archivo: achtest.c Proyecto: golems/ach
static int publisher( int32_t i ) {
    ach_channel_t chan;
    ach_status_t r = ach_open( &chan, opt_channel_name, NULL );
    if( r != ACH_OK ) {
        fprintf(stderr, "publisher %d couldn't ach_open: %s\n",
                i, ach_result_to_string(r) );
        return -1;
    }

    int32_t data[2] = {i, 0};
    size_t j;
    for( j = 0; j < (unsigned int)opt_n_msgs; j++,data[1]++ ) {
        r = ach_put( &chan, data, sizeof(data) );
        if( r != ACH_OK ) {
            fprintf(stderr, "publisher %d couldn't ach_put: %s\n",
                    i, ach_result_to_string(r) );
            return -1;
        }
        if( opt_pub_sleep_us <= 0 ) {
            sched_yield();
        } else {
            usleep((unsigned int)opt_pub_sleep_us);
        }
    }
    r = ach_close(&chan);
    if( ACH_OK != r ) {
        fprintf(stderr, "publisher %d couldn't ach_close: %s\n",
                i, ach_result_to_string(r) );
        return -1;
    } else {
        fprintf(stderr, "publisher %d ok\n", i);
        return 0;
    }
}
Ejemplo n.º 8
0
void CrichtonView<PointT>::startComm( int state, void* userdata ) {

  sns_init();
  sns_start();
  ach_status_t r;
  
  r = ach_open( &mObj_param_chan, gObj_param_chan_name.c_str(), NULL );
  if( r != ACH_OK ) { printf("[ERROR] COULD NOT OPEN OBJ PARAM CHAN"); return; }
  r = ach_open( &mServer2Module_chan, gServer2Module_chan_name.c_str(), NULL );
  if( r != ACH_OK ) { printf("[ERROR] COULD NOT OPEN SERVER-2-SEE CHAN"); return; }
  r = ach_open( &mModule2Server_chan, gModule2Server_chan_name.c_str(), NULL );
  if( r != ACH_OK ) { printf("[ERROR] COULD NOT SEE-2-SERVER CHAN"); return; }
    
  printf("\t [OK] Communication stablished and ready to go \n");
  mChanReady = true;

}
Ejemplo n.º 9
0
/**
 * @brief Open channel with marker information
 */
bool openComm() {

  // Set marker robot channel
  enum ach_status r;
  
  r = ach_open( &mMarker_robot_chan, gMarker_robot_chan_name.c_str(), NULL );
  
  return( r == ACH_OK );    
}
Ejemplo n.º 10
0
/**
 * Constructor that initializes the ach channel
 */
ReferenceChannel::ReferenceChannel() {
    errored = false;

    int r = ach_open(&huboReferenceChannel, HUBO_CHAN_REF_NAME, NULL);
    if (ACH_OK != r && ACH_MISSED_FRAME != r && ACH_STALE_FRAMES != r){
        cout << "Error! Reference Channel failed with state " << r << endl;
        errored = true;
    }

}
Ejemplo n.º 11
0
void HuboInitWidget::achCreateCHandle()
{
    ach_status_t r = ach_open(&cmdChan, HUBO_CHAN_BOARD_CMD_NAME, NULL);
    if( r == ACH_OK )
        cmdOpen = true;
    else
    {
        ROS_INFO("Command Channel failed to open");
        fprintf(stderr, "Command Channel failed to open: %s", ach_result_to_string(r));
    }
}
Ejemplo n.º 12
0
/* simple integrator, x = dt * dx */
void robot(void) {
    enum ach_status r = ach_open(&chan_feedback, "feedback", NULL);
    if(ACH_OK != r) abort();
    r = ach_open(&chan_control, "control", NULL);
    if(ACH_OK != r) abort();
    x_t X = {now(),0,0};
    while(1) {
        u_t U;
        size_t fs;
        r = ach_get( &chan_control, U, sizeof(U), &fs, NULL, ACH_O_WAIT|ACH_O_LAST );
        if( ach_status_match(r, ACH_MASK_OK | ACH_MASK_MISSED_FRAME) && sizeof(U) == fs ) {
            double tm = now();
            X[2] = U[0];               /*  dx = u       */
            X[1] = (tm - X[0]) * X[2]; /*  x = dt * dx  */
            X[0] = tm;
            ach_put(&chan_feedback, X, sizeof(X));
        } else abort();
    }
    exit(0);
}
Ejemplo n.º 13
0
/* sinusoidal input */
void controller(void) {
    int r = ach_open(&chan_control, "control", NULL);
    if(ACH_OK != r) abort();
    while(1){
        double tm = now();
        u_t U = {sin(tm)};
        ach_put(&chan_control, U, sizeof(U));
        usleep((int)(1e6 * 1e-3)); /* kilohertz */
    }
    exit(0);
}
Ejemplo n.º 14
0
void HuboInitWidget::achCreateSHandle()
{
    ach_status_t r = ach_open(&stateChan, HUBO_CHAN_STATE_NAME, NULL);
    if( r == ACH_OK )
        stateOpen = true;
    else
    {
        ROS_INFO("State Channel failed to open");
        fprintf(stderr, "State Channel failed to open: %s", ach_result_to_string(r));
    }
}
//NEW MAIN LOOP
int main(int argc, char **argv)
{
    printf("Initializing ROS-to-ACH bridge\n");
    //initialize ACH channel
    int r = ach_open(&chan_hubo_ref_filter, HUBO_CHAN_REF_NAME , NULL);
    assert(ACH_OK == r);
    r = ach_open(&chan_hubo_board_cmd, HUBO_CHAN_BOARD_CMD_NAME, NULL);
    assert(ACH_OK == r);
    printf("Hubo-ACH channel loaded\n");
    //initialize ROS node
    ros::init(argc, argv, "hubo_ros_feedforward");
    ros::NodeHandle nh;
    printf("Node up\n");
    //construct ROS RT Subscriber
    ros::Subscriber hubo_command_sub = nh.subscribe("Hubo/HuboCommand", 1, hubo_cb);
    printf("Subscriber up\n");
    ros::Subscriber ach_command_sub = nh.subscribe("Hubo/AchCommand", 1, com_cb);
    printf("Subscriber up\n");
    //spin
    ros::spin();
    //Satisfy the compiler
    return 0;
}
Ejemplo n.º 16
0
/* print samples periodically */
void periodic_logger(void) {
    enum ach_status r = ach_open(&chan_feedback, "feedback", NULL);
    if(ACH_OK != r) abort();
    while(1) {
        x_t X;
        size_t fs;
        r = ach_get( &chan_feedback, X, sizeof(X), &fs, NULL, ACH_O_WAIT|ACH_O_LAST );
        if( ach_status_match(r, ACH_MASK_OK | ACH_MASK_MISSED_FRAME) && sizeof(X) == fs ) {
            printf("%f\t%f\t%f\n", X[0], X[1], X[2]);
            usleep((int) (1e6 * 0.1)); /* 10 Hertz */
        } else abort();
    }
    exit(0);
}
Ejemplo n.º 17
0
    /** Open the channel. */
    ach_status_t open(const char* channel_name,
                      ach_attr_t* attr = NULL,
                      int allow_mask=ACH_MASK_OK,
                      int warn_mask=ACH_MASK_NONE) {
        ach_status_t r = ach_open(&channel, channel_name, attr);

        switch(check_status(r, allow_mask, warn_mask)) {
        case STATUS_WARN: warn_open(r);  break;
        case STATUS_ERR:  error_open(r); break;
        case STATUS_OK: break;
        }

        return r;
    }
Ejemplo n.º 18
0
int main( int argc, char **argv ) {
    (void)argc;
    (void) argv;

    ach_channel_t channel;

    ach_status_t r;

    /* unlink */
    r = ach_unlink(OPT_CHAN);
    test( ach_status_match(r, ACH_MASK_OK | ACH_MASK_ENOENT),
          r, "ach_unlink");

    /* create */
    r = ach_create(OPT_CHAN, 32ul, 64ul, NULL );
    test(ACH_OK == r, r, "ach_create");


    /* open */
    r = ach_open(&channel, OPT_CHAN, NULL);
    test(ACH_OK == r, r, "ach_open");

    /* first test */
    r = ach_get( &channel, NULL, 0, NULL, NULL, ACH_O_LAST );
    test( ACH_STALE_FRAMES == r, r, "get stale");

    /* read test */
    make_locked();
    r = ach_get( &channel, NULL, 0, NULL, NULL, ACH_O_LAST );
    test( ACH_STALE_FRAMES == r, r, "get stale");

    /* corrupt test */
    make_locked();
    channel.shm->sync.dirty = 1;
    r = ach_get( &channel, NULL, 0, NULL, NULL, ACH_O_LAST );
    test( ACH_CORRUPT == r, r, "get corrupt");
    /* and again */
    r = ach_get( &channel, NULL, 0, NULL, NULL, ACH_O_LAST );
    test( ACH_CORRUPT == r, r, "get corrupt");

    /* another read test */
    channel.shm->sync.dirty = 0;
    r = ach_get( &channel, NULL, 0, NULL, NULL, ACH_O_LAST );
    r = ach_get( &channel, NULL, 0, NULL, NULL, ACH_O_LAST );
    test( ACH_STALE_FRAMES == r, r, "get stale");

    return 0;

}
Ejemplo n.º 19
0
bool Aggregator::open_channels()
{
    if(_channels_opened)
        return true;

    _channels_opened = true;

    ach_status_t result = ach_open(&_cmd_chan, HUBO_CMD_CHANNEL, NULL);
    if( ACH_OK != result )
    {
        fprintf(stderr, "Error opening command channel: %s (%d)\n",
                ach_result_to_string(result), (int)result);
        _channels_opened = false;
        return false;
    }

    result = ach_open(&_agg_chan, HUBO_AGG_CHANNEL, NULL);
    if( ACH_OK != result )
    {
        fprintf(stderr, "Error opening aggregated channel: %s (%d)\n",
                ach_result_to_string(result), (int)result);
        _channels_opened = false;

        report_ach_errors(ach_close(&_cmd_chan), "Aggregator::open_channels",
                          "ach_close", HUBO_CMD_CHANNEL);
        return false;
    }

    report_ach_errors(ach_flush(&_cmd_chan), "Aggregator::open_channels",
                      "ach_flush", HUBO_CMD_CHANNEL);

    report_ach_errors(ach_flush(&_agg_chan), "Aggregator::open_channels",
                      "ach_flush", HUBO_AGG_CHANNEL);

    return true;
}
Ejemplo n.º 20
0
Archivo: achtool.c Proyecto: KimBP/ach
int cmd_dump(void) {
    if( opt_verbosity > 0 ) {
        fprintf(stderr, "Dumping Channel %s\n", opt_chan_name);
    }
    ach_channel_t chan;
    ach_status_t r = ach_open( &chan, opt_chan_name, NULL );
    check_status( r, "Error opening ach channel '%s'", opt_chan_name );

    ach_dump( chan.shm );

    r = ach_close( &chan );
    check_status( r, "Error closing ach channel '%s'", opt_chan_name );

    return r;
}
Ejemplo n.º 21
0
void setup_ach(void) {
    /* create channel */
    enum ach_status r = ach_unlink("bench");               /* delete first */
    if( ! ach_status_match(r, ACH_MASK_OK | ACH_MASK_ENOENT) ) abort();
    ach_create_attr_t cattr;
    if (KERNDEV) {
        ach_create_attr_init(&cattr);
        cattr.map = ACH_MAP_KERNEL;
    }
    r = ach_create("bench", 10, 256, KERNDEV ? &cattr : NULL );
    if(ACH_OK != r) abort();

    /* open channel */
    r = ach_open(&chan, "bench", NULL);
    if(ACH_OK != r) abort();
}
Ejemplo n.º 22
0
/* log all samples to a file */
void full_logger(void) {
    enum ach_status r = ach_open(&chan_feedback, "feedback", NULL);
    if(ACH_OK != r) abort();
    FILE *fp = fopen("ach-example.dat", "w");
    if(NULL == fp) abort();
    while(1) {
        x_t X;
        size_t fs;
        r = ach_get( &chan_feedback, X, sizeof(X), &fs, NULL, ACH_O_WAIT );
        if( ach_status_match(r, ACH_MASK_OK | ACH_MASK_MISSED_FRAME) ) {
            fprintf(fp,"%f\t%f\t%f\n", X[0], X[1], X[2]);
        } else abort();
    }
    fclose(fp);
    exit(0);
}
Ejemplo n.º 23
0
void init_time_chan(void) {
    /* create channel */
    ach_create_attr_t cattr;
    enum ach_status r = ach_unlink("time");               /* delete first */
    if( ! ach_status_match(r, ACH_MASK_OK | ACH_MASK_ENOENT) ) abort();
    if (KERNDEV) {
        ach_create_attr_init(&cattr);
        cattr.map = ACH_MAP_KERNEL;
    }
    r = ach_create("time", (size_t)FREQUENCY*(size_t)SECS*RECV_RT,
                   sizeof(float), KERNDEV ? &cattr : NULL );
    if(ACH_OK != r) abort();

    /* open channel */
    r = ach_open(&time_chan, "time", NULL);
    if(ACH_OK != r) abort();
}
Ejemplo n.º 24
0
static void make_locked( ) {
    pid_t pid = fork();
    if( 0 == pid ) { /* child */
        ach_channel_t channel;
        /* open */
        enum ach_status r = ach_open(&channel, OPT_CHAN, NULL);
        test(ACH_OK == r, r, "ach_open");

        pthread_mutex_lock(&channel.shm->sync.mutex);
        exit(EXIT_SUCCESS);

    } else if (0 < pid) {
        wait( NULL );
    } else {
        exit(EXIT_FAILURE);
    }
}
Ejemplo n.º 25
0
int ach_move_init() {
  // Channels
  int r = 0;
  printf("ACH: Creating Channel\n");
  ach_create_attr_t attr;
  ach_create_attr_init(&attr);
  r = ach_create((char*)craftyo_chan_name, 100, IBOARDSTATE_SIZE+IMOVESTRING_SIZE, &attr);
  printf("ACH: %s\n", ach_result_to_string((ach_status_t)r));

  printf("ACH: Opening Channel\n");
  craftyo_chan = (ach_channel_t*) malloc (sizeof(ach_channel_t));
  if(craftyo_chan == NULL) return 0;
  r = ach_open(craftyo_chan, craftyo_chan_name, NULL);
  if(r != ACH_OK) {
	  printf("ACH: %s\n", ach_result_to_string((ach_status_t)r));
	  return 0;
  }

  ach_chmod(craftyo_chan, SOMATIC_CHANNEL_MODE );

  r = ach_flush(craftyo_chan);

  if(r != ACH_OK) {
	  printf("ACH: %s\n", ach_result_to_string((ach_status_t)r));
	  return 0;
  }

  // Data
  craftyo_message = (Somatic__Crafty*)malloc(sizeof(Somatic__Crafty));
  if(craftyo_message == NULL) return 0;
  somatic__crafty__init(craftyo_message);
  //craftyo_message->boardstate.data = (uint8_t*) malloc(128);
  //craftyo_message->has_boardstate = 1;
  //craftyo_message->boardstate.len = 128;
  craftyo_message->move = (char*)malloc(10);

  printf("ACH: Info\n"
		 "ACH: Name: %s\n"
		 "ACH: Size: %d\n", craftyo_chan_name, somatic__crafty__get_packed_size(craftyo_message));

  return 1;
}
Ejemplo n.º 26
0
    bool initialize(const std::vector<std::string>& names, const std::string& channel_name)
    {
        free(_raw_data);
        _raw_data = initialize_data<DataClass>(names.size());

        _mapping.clear();
        _names.clear();
        for(size_t i=0; i<names.size(); ++i)
        {
            StringMap::iterator it = _mapping.find(names[i]);
            if(it == _mapping.end())
            {
                _mapping[names[i]] = i;
            }
            else
            {
                std::cout << "[HuboData::initialize] You have a repeated data member name ('"
                          << names[i] << "')\n"
                          << " -- Already exists as entry #" << it->second << "\n"
                          << " -- Attempted to assign it to entry #" << i << std::endl;
                _mapping.clear();
                return false;
            }
        }
        _names = names;

        _channel_name = channel_name;
        ach_status_t r = ach_open(&_channel, channel_name.c_str(), NULL);
        if( ACH_OK == r )
        {
            _initialized = true;
            return true;
        }

        _initialized = false;

        std::cout << "[HuboData::initialize] Failed to open channel '" << _channel_name << "': "
                     << ach_result_to_string(r) << std::endl;

        return false;
    }
Ejemplo n.º 27
0
int main( int argc, char **argv ) {

    cx_t cx;
    memset(&cx, 0, sizeof(cx));
/*    static cx_t cx;
    memset(&cx, 0, sizeof(cx));
    cx.d_opts.ident = "fastrakd";
    cx.d_opts.sched_rt = SOMATIC_D_SCHED_UI; // logger not realtime

    cx.opt_chan_name = "fastrak";
    cx.opt_freq = -1;
    cx.opt_peekabot = 0;
    cx.opt_peekabot_host = "localhost";
    cx.opt_device = "/dev/ttyS0";
    cx.opt_kalman = 0;
    cx.opt_diag_E = 1;
    cx.opt_diag_Q = 250;
    cx.opt_diag_R = 1;
*/

    // parse options
//    argp_parse (&argp, argc, argv, 0, NULL, &cx);
//    somatic_verbprintf_prefix="fastrak";
//    somatic_verbprintf( 1, "Frequency of %d Hz\n", cx.opt_freq );


//    init(&cx);
    daemonize("fastrakd");
    int r = fastrak_init(&(cx.fk), "/dev/ttyS0" );

    r = ach_open( &chan, "fastrak", NULL );
    daemon_assert( ACH_OK == r, __LINE__ );

    //printf("About to start\n");

    run(&cx);
//    destroy(&cx);
    daemon_close();

    return 0;
}
Ejemplo n.º 28
0
int main(int argc, char **argv){
	(void) argc; (void)argv;
	int r;

	// create chanels
	//r = ach_unlink("getNum");
//	r = ach_unlink("getNum");
//	assert( ACH_OK == r || ACH_ENOENT == r );

//	r = ach_create("getNum", 10ul, 256ul, NULL);
//	assert( ACH_OK == r);


	r = ach_open(&chan_num, "can", NULL);
	assert(ACH_OK == r);

	mainLoop();

	pause();
	return 0;

}
Ejemplo n.º 29
0
Archivo: achtool.c Proyecto: KimBP/ach
int cmd_chmod(void) {
    assert(opt_mode >=0 );
    if( opt_verbosity > 0 ) {
        fprintf( stderr, "Changing mode of %s to %o\n",
                 opt_chan_name, (unsigned)opt_mode );
    }

    /* open */
    ach_channel_t chan;
    errno = 0;
    ach_status_t r = ach_open( &chan, opt_chan_name, NULL );
    check_status( r, "Error opening channel '%s'", opt_chan_name );

    /* chmod */
    r = ach_chmod( &chan, (mode_t)opt_mode );
    check_status( r, "Error chmodding channel '%s'", opt_chan_name );

    /* close */
    r = ach_close( &chan );
    check_status( r, "Error closing channel '%s'", opt_chan_name );

    return r;
}
Ejemplo n.º 30
0
/**
 * Create the command channel
 */
CommandChannel::CommandChannel() {
    int r = ach_open(&huboBoardCommandChannel, HUBO_CHAN_BOARD_CMD_NAME, NULL);
    if (ACH_OK != r)
        cerr << "Error! Command Channel failed with state " << r << endl;
}