⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cricket.h

📁 无线传感器网络中的节点定位算法。详见ReadMe文件。在TinyOS上实现的节点定位算法。
💻 H
字号:
#ifndef _CRICKET_H#define _CRICKET_H#include <stdio.h>#ifndef PLATFORM_PC#include <avr/eeprom.h>#endif#if defined(PLATFORM_CRICKET_MIT)// Number of timer ticks between starting the timer and sending the pulse#define TIMER_OFFSET        315// Number of timer ticks per bit over the radio (19200 baud)#define COMPENSATION_VAL    52// Multiplier as a given speed of sound in timer_ticks per cm#define DISTANCE_MULT       30// Number of microseconds per timer tick#define US_PER_TICK         1.0// The maximum amount of that to wait for ultrasound arrival// The should be the time to travel the maximum distance + the offset// Currently this is 45000 us + the offset#define MAX_ALLOWED_TIMER_VAL 45000#define MAX_NEIGHBORS   16#elif defined(PLATFORM_CRICKET)#define TIMER_OFFSET        262#define COMPENSATION_VAL    48#define DISTANCE_MULT       28#define US_PER_TICK         1.0850694#define MAX_ALLOWED_TIMER_VAL 41472#define MAX_NEIGHBORS   16#else /* if defined(PLATFORM_PC) */#define TIMER_OFFSET        0#define COMPENSATION_VAL    0#define DISTANCE_MULT       30#define US_PER_TICK         1.0#define MAX_ALLOWED_TIMER_VAL 45000#define MAX_NEIGHBORS   50#endif#define SELF            MAX_NEIGHBORS// Minimum and maximum beacon interval times#define MIN_BEAC_IVAL       468#define MAX_BEAC_IVAL       900// Maximum ultrasound travel time#define MAX_US_TRAVEL_TIME  45// Speed of sound in microseconds per cm#define DISTANCE_MULT_US    30// Localization parameters#define ASYMMETRIC_THRESHOLD 180// Filtering parameters#define VEL_VARIANCE    100#define VEL_VARIANCE_MOTION  360000#define MEAS_VARIANCE   3600#define MAX_DIST        30000/* Cricket flags */#define CR_MOVING   1#define CR_HAS_CONE 2/* Information about a neighboring node */typedef struct NodeInfo {    uint8_t id[4];      /* Its 4-byte ID */    uint8_t status;     /* status of our distance cache */    uint8_t next;       /* pointer to next node for hash table collisions */} node_info;/* values for the status field */#define EMPTY           0xff#define RELAY_DATA      0x1#define OLD_MEAS        0x2#define OLD_RELAY       0x4#define IS_MOVING       0x8#define IS_NEW          0x10uint8_t has_cones = 0;#define OUT_NONE        0#define OUT_CRITICAL    1#define OUT_ERROR       2#define OUT_WARNING     3#define OUT_INFO        4#define OUT_DEBUG       5#ifdef PLATFORM_PC#define debug_out   ((NODE_NUM==0)?OUT_DEBUG:OUT_NONE)void print_output(char * s) {    static char lastch = '\n';    while (*s) {        if (lastch == '\n') {            fprintf(stdout, "%04u.%03u: ", (unsigned int)(tos_state.tos_time / (long long)4000000), (unsigned int)((tos_state.tos_time % (long long)4000000)/4000));        }        fwrite(s, 1, 1, stdout);        fflush(stdout);        lastch = *s;        s++;    }}#define UARTOutput(__x,__y,__args...) do { \    char __s[256]; \    snprintf(__s, 256, __y, ## __args); \    if (debug_out) print_output(__s); \    } while (0)#define square(x)   ((x)*(x))#define strcmp_P(x,y)   strcmp(x,y)#else /* PLATFORM_PC */uint8_t debug_out = OUT_INFO;#define UARTOutput(__x,__y,__args...) do { \    static char __s[] __attribute__((progmem)) = __y; \    if (debug_out >= __x) \        printf_P(__s, ## __args);	\} while (0)#endif /* PLATFORM_PC */#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -