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

📄 robot.h

📁 用于机器人自动低分辨路的地图测绘程序。用于机器人控制测绘。分为远端控制端和本地控制端。控制电机为标准舵机。
💻 H
字号:
/*
    Robot Interface
    (C) 2006 Jason Hunt
    nulluser@gmail.com
    
    File: robot.h
*/

#ifndef ROBOT_H
#define ROBOT_H



/* Structure for robot control data */
typedef struct control_type
{
   double left_motor_target;                   // Target motor speed
   double right_motor_target;
    
   double left_motor_speed;                 // Current motor speed
   double right_motor_speed;
       
   bool left_motor_dir;                     // Motor directions
   bool right_motor_dir;
    
   unsigned char servo_pos[6];              // Servo positions
};

/* Structure for  robot telemetry */
typedef struct telemetry_type
{
    unsigned int  analog_data[8];
    unsigned char encoders[4];
    
    unsigned int encoder_counts[4];
};


/* Robot class */
class robot_class 
{

  public:
    
    robot_class();
    ~robot_class();
    
    
    void start(void);
    void stop(void);
           
    void reset_control( void );
        
           
    // Interface to control data
    void get_control(control_type * control_data);          // Control into struct
    void get_control(unsigned char * buffer);               // Control into buffer

    void set_control(control_type &control_data);           // Control from struct
    void set_control(unsigned char *buffer);                // Control from buffer

    void get_telemetry(telemetry_type * telemetry_data);    // Telemetry into struct
    void get_telemetry(unsigned char * buffer);             // Telemetry into buffer

    void set_telemetry(unsigned char * buffer);             // Telemetry from buffer

    void set_motion(double x_move, double y_move);  // Set motion from xy speed value

    double robot_class::get_update_speed(void);     // Return serial update speed

    void update_complete(bool fail);

    bool get_auto_mode(void);
    void set_auto_mode(bool mode);


  private:

    CRITICAL_SECTION control_data_lock;     // Lock for contorl_data
    CRITICAL_SECTION telemetry_data_lock;   // Lock for telemetry data
    CRITICAL_SECTION update_speed_lock;     // Lock for update speed
    CRITICAL_SECTION auto_mode_lock;     // Lock for update speed
   
    control_type control_data;              // Robot contorl data
    telemetry_type telemetry_data;          // Robot Telemetry data

    unsigned int updates;                   // Number of updates in this time slice
    double update_speed;                    // Updates per second

    bool auto_mode;      
};


extern robot_class robot;                   // export
extern bool remote_mode;                    // True if in remote control mode


void reset_vals(void);
#endif

⌨️ 快捷键说明

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