Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 114 lines (80 sloc) 1.904 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
#pragma once
#include "ofMain.h"
#include "ofxThread.h"
#include "ofxIndustrialRobotMotorConverter.h"
#define DATAGRAM_LENGTH 24

/*
Description of the bytes:

byte 0:
0: No speed limit
1: bit 1 (?)
2: bit 2 (?)
3: bit 3 (?)
4: bit 4 (?)
5: Reset power
6: Run 0 (?)
7: Run 1 (Unlock motors)
byte 1:
0: Reset motor 0
1: Reset motor 1
2: Reset motor 2
3: Reset motor 3
4: Reset motor 4
5: bit 5 (?)
6: bit 6 (?)
7: bit 7 (?)
byte status:
0: Axis 0 OK
1: Axis 1 OK
2: Axis 2 OK
3: Axis 3 OK
4: Axis 4 OK
5: Bit 5 (?)
6: Manual stop (emergency stop)
7: Hardware error (panic)
*/
 
class ofxIndustrialRobotSerial : public ofxThread{
public:
ofxIndustrialRobotSerial();

    
bool returnedFlags[8];
    bool sendFlags[2][8];

    bool hasReceivenLastPosition;

bool motorFlag(int n);
bool emergencyFlag();
bool panicFlag();
bool lockFlag();
    
    bool resetMotorFlag(int n);
bool speedLimitFlag();
bool resetPowerFlag();
bool unlockFlag();
    
    void setSpeedLimitFlag(bool flag);
    void setResetPowerFlag(bool flag);
    void setUnlockFlag(bool flag);
    void setResetMotorFlag(int motor, bool flag);
    
    void step();
void recvChar(char c);


void setValue(int n, float val);
void sendValues();


bool connected;

void start();

void stop(){
stopThread();
}

    
    int resetting;

//--------------------------
void threadedFunction();

    int inValues[5];
    float initValues[5];


private:
unsigned char syncstate;
unsigned char dptr;
unsigned char INBUF[DATAGRAM_LENGTH];

unsigned char botStatus;

    unsigned char sendingoutbuf[DATAGRAM_LENGTH];

unsigned int lastStep;

int errorCounter;
    
    ofSerial serial;
    
    int outValues[5];
    
    static const int num_axis = 5;
    unsigned char outbuf[DATAGRAM_LENGTH];

    

};
Something went wrong with that request. Please try again.