All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

grobot.h 2.63 KB
Newer Older
Timothy Stack's avatar
Timothy Stack committed
1 2 3 4 5 6
/*
 * EMULAB-COPYRIGHT
 * Copyright (c) 2005 University of Utah and the Flux Group.
 * All rights reserved.
 */

7 8 9 10 11
/* Garcia robot class
 *
 * Dan Flickinger
 *
 * 2004/10/04
Daniel Flickinger's avatar
Daniel Flickinger committed
12
 * 2004/12/09
13 14
 */

15
 
16 17 18
#ifndef GROBOT_H
#define GROBOT_H

Timothy Stack's avatar
 
Timothy Stack committed
19
class grobot;
Timothy Stack's avatar
 
Timothy Stack committed
20 21
class CallbackComplete;
class CallbackExecute;
Timothy Stack's avatar
 
Timothy Stack committed
22 23

#if !defined(GROBOT_SIM)
24 25
#include "acpGarcia.h"
#include "acpValue.h"
Timothy Stack's avatar
 
Timothy Stack committed
26
#endif
27 28 29 30 31 32 33 34 35 36

#include <math.h>
#include <iostream>
#include <string>



// track width, in meters
#define TRACK_WIDTH 0.1778f

Timothy Stack's avatar
 
Timothy Stack committed
37 38 39 40 41 42 43
typedef enum {
  CBT_NONE,
  
  CBT_PIVOT,
  CBT_MOVE
} cb_type_t;

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
class grobot {
  public:
    grobot();
    ~grobot();
    
    void estop();
    void setWheels(float Vl, float Vr);
    void setvPath(float Wv, float Wr);
    
    void pbMove(float mdisplacement);
    void pbPivot(float pangle);
    void dgoto(float Dx, float Dy, float Rf);

    void resetPosition();
    void updatePosition();
    float getArclen();
Timothy Stack's avatar
Timothy Stack committed
60
    void getDisplacement(float &dxtemp, float &dytemp);
61 62
    
    int getGstatus();
Daniel Flickinger's avatar
Daniel Flickinger committed
63 64
    int getGOTOstatus();
    void sleepy();
65 66
    
    void setCBexec(int id);
Timothy Stack's avatar
 
Timothy Stack committed
67
    void setCBstatus(int id, int stat, cb_type_t cbt);
68

Timothy Stack's avatar
 
Timothy Stack committed
69
#if !defined(GROBOT_SIM)
70
    acpGarcia garcia;
Timothy Stack's avatar
 
Timothy Stack committed
71
#endif
72 73 74
    
  private:
    void createNULLbehavior();
Timothy Stack's avatar
 
Timothy Stack committed
75
    void createPRIMbehavior(cb_type_t cbt);
Daniel Flickinger's avatar
Daniel Flickinger committed
76 77 78
    
    void set_gotocomplete();
    
79
        
Daniel Flickinger's avatar
Daniel Flickinger committed
80
    // Wheel odometry values
Timothy Stack's avatar
Timothy Stack committed
81 82
    float Vl;      // left wheel velocity
    float Vr;      // right wheel velocity
Daniel Flickinger's avatar
Daniel Flickinger committed
83
    
Timothy Stack's avatar
Timothy Stack committed
84 85
    float dleft;   // left wheel distance
    float dright;  // right wheel distance
Daniel Flickinger's avatar
Daniel Flickinger committed
86
    
Timothy Stack's avatar
Timothy Stack committed
87 88 89
    float dt_init; // initial pivot angle for a goto command
    float dx_est;  // estimated displacement x
    float dy_est;  // estimated displacement y
Daniel Flickinger's avatar
Daniel Flickinger committed
90 91

    
92
    
Daniel Flickinger's avatar
Daniel Flickinger committed
93 94 95 96 97 98 99 100 101 102 103
    // goto command administration shit
    int gotolock;      // nonzero if a goto command is executing
    int gotocomplete;  // 1 if a goto has completed, 0 otherwise
    
    int gotomexec;     // count for execute
    int gotomcomplete; // count for complete
    
    int gotop1;       // status for first pivot of a goto command
    int gotom1;       // status for move segment of a goto command
    int gotop2;       // status for second pivot of a goto command
    
Timothy Stack's avatar
 
Timothy Stack committed
104
#if !defined(GROBOT_SIM)
Daniel Flickinger's avatar
Daniel Flickinger committed
105 106
    // Garcia stuff
    acpObject *pBehavior;         // Garcia behavior
107 108
     
    
Daniel Flickinger's avatar
Daniel Flickinger committed
109 110
    CallbackComplete *completeCB; // completion callback
    CallbackExecute *executeCB;   // execution callback
111
    
Daniel Flickinger's avatar
Daniel Flickinger committed
112 113 114 115 116
    acpValue completeCBacpV;      // acpValue completion callback
    acpValue executeCBacpV;       // acpValue execution callback
    
    aIOLib ioRef;                 // Garcia Input/Output reference
    aErr err;                     // Garcia Error
Timothy Stack's avatar
 
Timothy Stack committed
117
#endif
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
    
};


#endif