Last active
December 17, 2015 08:57
-
-
Save aman-tiwari/95308a11416e2fccb971 to your computer and use it in GitHub Desktop.
UArm control from Openframeworks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//-------------------------------------------------------------- | |
void ofApp::setup() { | |
uarm.setup("/dev/tty.usbserial-A600CRMU", 9600); | |
} | |
//-------------------------------------------------------------- | |
// x, y, z in cylindrical coordinates, handRot in degrees | |
void ofApp::setArmTo(int x, int y, int z, int handRot, bool gripper) { | |
// UArm expects 1 for an open gripper and 2 for a closed gripper | |
gripper = (int)gripper + 1; | |
unsigned char bytes[11] = { | |
0xFF, | |
0xAA, | |
static_cast<unsigned char>((x >> 8) & 0xFF), | |
static_cast<unsigned char>(x & 0xFF), | |
static_cast<unsigned char>((y >> 8) & 0xFF), | |
static_cast<unsigned char>(y & 0xFF), | |
static_cast<unsigned char>((z >> 8) & 0xFF), | |
static_cast<unsigned char>(z & 0xFF), | |
static_cast<unsigned char>((handRot >> 8) & 0xFF), | |
static_cast<unsigned char>(handRot & 0xFF), | |
static_cast<unsigned char>(gripper) | |
}; | |
uarm.writeBytes(&bytes[0], 11); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::exit() { | |
uarm.flush(true,true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
class ofApp : public ofBaseApp { | |
public: | |
void setup(); | |
void exit(); | |
ofSerial uarm; | |
void setArmTo(int x, int y, int z, int handRot, bool gripper); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment