Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

tweak for camera props

  • Loading branch information...
commit 0e4f0e19889bda937efdfd36c9d6fd2c8a101bde 1 parent 1a35ae1
@hideyukisaito hideyukisaito authored
View
91 src/ArsUIButton.cpp
@@ -1,9 +1,11 @@
#include "ArsUIButton.h"
#include "ofxEasingFunc.h"
-ArsUIButton::ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle){
+//--------------------------------------------------------------
+ArsUIButton::ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle, string _udid){
x = _x;
y = _y;
+ udid = _udid;
bid = _bid;
status = 0;
speed = 3600;
@@ -15,9 +17,37 @@ ArsUIButton::ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _ang
current.set(_x, _y);
directionToFuji = calcDirection(&current, &fuji);
currentDirection = directionToFuji;
- viewAngle = _angle;
+ angle = _angle;
+ compass = getCompass();
}
+//--------------------------------------------------------------
+ArsUIButton::ArsUIButton(double _lat, double _lon, string _udid, int _angle, int _compass, int _bid, ofPoint _fuji)
+{
+ ofPoint p = GPStoXY(_lat, _lon);
+ x = p.x;
+ y = p.y;
+ udid = _udid;
+ angle = _angle;
+ compass = _compass;
+ bid = _bid;
+ fuji = _fuji;
+
+ status = 0;
+ speed = 3600;
+ bcnt = (int)ofRandom(speed);
+ mark.loadImage("mark.png");
+ markShadow.loadImage("markshadow.png");
+
+ ofPoint current;
+ current.set(x, y);
+
+ currentDirection = compass * PI / 180;
+
+ compass = getCompass();
+}
+
+//--------------------------------------------------------------
void ArsUIButton::update(){
float v = sinf((float)bcnt/speed * 2 * PI);
@@ -26,6 +56,7 @@ void ArsUIButton::update(){
if(bcnt == speed) bcnt =0;
}
+//--------------------------------------------------------------
void ArsUIButton::draw(){
//status: 0:default 1:select
@@ -40,8 +71,8 @@ void ArsUIButton::draw(){
path.setCurveResolution(120);
path.setColor( ofColor(50, 200, 255,40));
path.moveTo(x,y);
- float angle1 = 360 - (360 * currentDirection / (PI * 2) + viewAngle / 2) ;
- float angle2 = 360 - (360 * currentDirection / (PI * 2) - viewAngle / 2) ;
+ float angle1 = 360 - (360 * currentDirection / (PI * 2) + angle / 2) ;
+ float angle2 = 360 - (360 * currentDirection / (PI * 2) - angle / 2) ;
path.arc(x, y, distanceToFuji, distanceToFuji, angle1, angle2);
@@ -70,6 +101,8 @@ void ArsUIButton::draw(){
ofPopMatrix();
}
+
+//--------------------------------------------------------------
int ArsUIButton::hitTestPoint(ofPoint p)
{
double distance = abs(sqrt((double)((p.x - x) * (p.x - x) + (p.y - y) * (p.y - y))));
@@ -80,17 +113,26 @@ int ArsUIButton::hitTestPoint(ofPoint p)
return -1;
}
+//--------------------------------------------------------------
void ArsUIButton::setPosition(ofPoint pos)
{
x = pos.x;
y = pos.y;
}
+//--------------------------------------------------------------
ofPoint ArsUIButton::getPosition()
{
return ofPoint(x, y);
}
+//--------------------------------------------------------------
+void ArsUIButton::setFujiPosition(ofPoint p)
+{
+ fuji = p;
+}
+
+//--------------------------------------------------------------
//return radian
double ArsUIButton::calcDirection(ofPoint *_p1, ofPoint *_p2)
{
@@ -106,6 +148,7 @@ double ArsUIButton::calcDirection(ofPoint *_p1, ofPoint *_p2)
return theta;
}
+//--------------------------------------------------------------
int ArsUIButton::calcCompass(ofPoint *p)
{
float dx = x - p->x;
@@ -114,27 +157,37 @@ int ArsUIButton::calcCompass(ofPoint *p)
return (int)radians * 180 / PI;
}
+//--------------------------------------------------------------
void ArsUIButton::setAngle(float _angle)
{
- viewAngle = _angle;
+ angle = _angle;
}
+//--------------------------------------------------------------
int ArsUIButton::getAngle()
{
- return viewAngle;
+ return angle;
}
-
+//--------------------------------------------------------------
double ArsUIButton::getDirectionAsRadians()
{
return currentDirection;
}
+//--------------------------------------------------------------
double ArsUIButton::getDirectionAsDegrees()
{
return currentDirection * 180 / PI;
}
+//--------------------------------------------------------------
+void ArsUIButton::setCompass(int degrees)
+{
+ currentDirection = degrees * PI / 180;
+}
+
+//--------------------------------------------------------------
int ArsUIButton::getCompass()
{
int deg = (int)getDirectionAsDegrees() - 90;
@@ -144,25 +197,45 @@ int ArsUIButton::getCompass()
return deg;
}
+//--------------------------------------------------------------
void ArsUIButton::setStatus(int _status){
status = _status;
}
+
+//--------------------------------------------------------------
int ArsUIButton::getStatus(){
return bid;
}
+
+//--------------------------------------------------------------
int ArsUIButton::getId(){
return bid;
}
-void ArsUIButton::setCameraStatus(double _lat, double _lon){
+//--------------------------------------------------------------
+void ArsUIButton::setCameraStatus(double _lat, double _lon, int compass, int angle){
latitude = _lat;
- longtitude = _lon;
+ longitude = _lon;
ofPoint place = GPStoXY(_lat, _lon);
x = place.x;
y = place.y;
}
+//--------------------------------------------------------------
+void ArsUIButton::setCameraStatus(ofxJSONElement json)
+{
+ latitude = json["latitude"].asDouble();
+ longitude = json["longitude"].asDouble();
+ compass = json["compass"].asInt();
+ angle = json["angle"].asInt();
+
+ ofPoint p = GPStoXY(latitude, longitude);
+ x = p.x;
+ y = p.y;
+}
+
+//--------------------------------------------------------------
ofPoint ArsUIButton::GPStoXY(double _lat,double _lon){
//calibration set
//fuji benchmark (富士 中心)
View
24 src/ArsUIButton.h
@@ -1,24 +1,30 @@
#include "ofMain.h"
+#include "ofxJSONElement.h"
class ArsUIButton
{
protected:
- int status, bcnt, speed, tcnt; //status 0: not selected, 1:selected, 2: broken
+ string udid;
+ double latitude, longitude;
+ int compass;
+ int angle;
+
+ int status, bcnt, speed, tcnt; //status 0: not selected, 1:selected, 2: broken
ofImage mark, markShadow;
float x, y, radius;
int bid;
+
ofPoint fuji;
double directionToFuji; //radian
double currentDirection;
double calcDirection(ofPoint *_p1, ofPoint *_p2);
+
int calcCompass(ofPoint *p);
- double viewAngle;
- double latitude;
- double longtitude;
public:
- ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle );
+ ArsUIButton(float _x, float _y, int _bid, ofPoint _fuji, float _angle, string _udid);
+ ArsUIButton(double _lat, double _lon, string _udid, int _angle, int _compass, int _bid, ofPoint _fuji = ofPoint(964, 600));
virtual void draw();
virtual void update();
virtual int hitTestPoint(ofPoint p);
@@ -26,14 +32,18 @@ class ArsUIButton
void setPosition(ofPoint pos);
ofPoint getPosition();
+ void setFujiPosition(ofPoint p);
+
void setAngle(float _angle);
int getAngle();
double getDirectionAsRadians();
double getDirectionAsDegrees();
+ void setCompass(int degrees);
int getCompass();
void setStatus(int _status);
int getStatus();
int getId();
- void setCameraStatus(double _lat, double _lon);
- ofPoint GPStoXY(double _lat,double _lon);
+ void setCameraStatus(double _lat, double _lon, int compass, int angle);
+ void setCameraStatus(ofxJSONElement json);
+ ofPoint GPStoXY(double _lat, double _lon);
};
View
135 src/ArsUIMapControlState.cpp
@@ -23,7 +23,7 @@ ArsUIMapControlState::~ArsUIMapControlState()
//--------------------------------------------------------------
void ArsUIMapControlState::init()
{
- setupGUI();
+ //setupGUI();
}
//--------------------------------------------------------------
@@ -32,17 +32,19 @@ void ArsUIMapControlState::stateEnter()
bShowStatus = true;
fujiPoint.set(964, 600);
+ ofPoint p = ArsUIUtil::XYtoGPS(fujiPoint);
+ cout << "XYtoGPS x: " << p.x << ", y: " << p.y << endl;
for (int i = 0; i < 10; ++i) {
- buttons.push_back(ArsUIButton(ofRandom(ofGetWidth()), ofRandom(ofGetHeight() - 100), i, fujiPoint, ofRandom(20, 60)));
+ inoperableCameras.push_back(ArsUIButton(ofRandom(ofGetWidth()), ofRandom(ofGetHeight() - 100), i, fujiPoint, ofRandom(20, 60), ""));
}
for (int i = 10; i < (10 + getSharedData().numRobots); ++i) {
- robos.push_back(ArsUIRoboCam(ofRandom(ofGetWidth()), ofRandom(ofGetHeight() - 100), i, fujiPoint, ofRandom(20, 60)));
+ operableCameras.push_back(ArsUIRoboCam(ofRandom(ofGetWidth()), ofRandom(ofGetHeight() - 100), i, fujiPoint, ofRandom(20, 60), ""));
}
- cam1Position = ofPoint(robos[0].getPosition().x, robos[0].getPosition().y);
- cam2Position = ofPoint(robos[1].getPosition().x, robos[1].getPosition().y);
+ cam1Position = ofPoint(operableCameras[0].getPosition().x, operableCameras[0].getPosition().y);
+ cam2Position = ofPoint(operableCameras[1].getPosition().x, operableCameras[1].getPosition().y);
eyes[0] = -1;
eyes[1] = -1;
@@ -55,15 +57,20 @@ void ArsUIMapControlState::stateEnter()
ofAddListener(getSharedData().tuioClient.cursorUpdated, this, &ArsUIMapControlState::tuioUpdated);
ofAddListener(getSharedData().oscReceiverFromServer.onMessageReceived, this, &ArsUIMapControlState::onOscMessageReceived);
- sendViewpointToServer(robos[0]);
- sendViewpointToServer(robos[1]);
+ ofxOscMessage msg;
+ msg.setAddress("/gianteyes/hello");
+ msg.addIntArg(getSharedData().incomingPort);
+ getSharedData().oscSenderToServer.sendMessage(msg);
+
+ sendViewpointToServer(operableCameras[0]);
+ sendViewpointToServer(operableCameras[1]);
}
//--------------------------------------------------------------
void ArsUIMapControlState::stateExit()
{
- buttons.clear();
- robos.clear();
+ inoperableCameras.clear();
+ operableCameras.clear();
fujiMap.clear();
ofRemoveListener(getSharedData().tuioClient.cursorAdded, this, &ArsUIMapControlState::tuioAdded);
@@ -87,14 +94,14 @@ void ArsUIMapControlState::update()
}
}
- for (int i = 0; i < buttons.size(); ++i) {
- buttons[i].update();
+ for (int i = 0; i < inoperableCameras.size(); ++i) {
+ inoperableCameras[i].update();
}
- robos[0].setPosition(cam1Position);
- robos[1].setPosition(cam2Position);
- robos[0].update();
- robos[1].update();
+ operableCameras[0].setPosition(cam1Position);
+ operableCameras[1].setPosition(cam2Position);
+ operableCameras[0].update();
+ operableCameras[1].update();
}
//--------------------------------------------------------------
@@ -114,14 +121,14 @@ void ArsUIMapControlState::draw()
getSharedData().tappedPoints[i].draw();
}
- for (int i = 0; i<buttons.size(); ++i) {
- buttons[i].draw();
+ for (int i = 0; i<inoperableCameras.size(); ++i) {
+ inoperableCameras[i].draw();
}
- for (int i = 0; i < robos.size(); ++i) {
- robos[i].draw();
+ for (int i = 0; i < operableCameras.size(); ++i) {
+ operableCameras[i].draw();
- ofPoint p = robos[i].getPosition();
+ ofPoint p = operableCameras[i].getPosition();
ofSetColor(255, 0, 0);
ofLine(p.x, 0, p.x, ofGetHeight());
@@ -132,32 +139,15 @@ void ArsUIMapControlState::draw()
ofSetColor(255, 0, 0);
if (bShowStatus) {
- string str1 = "X : " + ofToString(cam1Position.x) +
- "\nY : " + ofToString(cam1Position.y) +
- "\nANGLE : " + ofToString(robos[0].getAngle()) +
- "\nCOMPASS: " + ofToString(robos[0].getCompass());
- ofDrawBitmapString(str1, cam1Position + ofPoint(70, -50));
-
- string str2 = "X : " + ofToString(cam2Position.x) +
- "\nY : " + ofToString(cam2Position.y) +
- "\nANGLE : " + ofToString(robos[1].getAngle()) +
- "\nCOMPASS: " + ofToString(robos[1].getCompass());
- ofDrawBitmapString(str2, cam2Position + ofPoint(70, -50));
+ drawCamStatuses(operableCameras[0]);
+ drawCamStatuses(operableCameras[1]);
} else {
if (isCam1Draggable) {
- string str = "X : " + ofToString(cam1Position.x) +
- "\nY : " + ofToString(cam1Position.y) +
- "\nANGLE : " + ofToString(robos[0].getAngle()) +
- "\nCOMPASS: " + ofToString(robos[0].getCompass());
- ofDrawBitmapString(str, cam1Position + ofPoint(70, -50));
+ drawCamStatuses(operableCameras[0]);
}
if (isCam2Draggable) {
- string str = "X : " + ofToString(cam2Position.x) +
- "\nY : " + ofToString(cam2Position.y) +
- "\nANGLE : " + ofToString(robos[1].getAngle()) +
- "\nCOMPASS: " + ofToString(robos[1].getCompass());
- ofDrawBitmapString(str, cam2Position + ofPoint(70, -50));
+ drawCamStatuses(operableCameras[1]);
}
}
@@ -220,15 +210,15 @@ void ArsUIMapControlState::setEye(int bid)
int lastEye = eyes[selectedEye];
if (-1 != lastEye) {
- for (int i = 0; i < buttons.size(); ++i) {
- if(buttons[i].getId() == lastEye){
- buttons[i].setStatus(0);
+ for (int i = 0; i < inoperableCameras.size(); ++i) {
+ if(inoperableCameras[i].getId() == lastEye){
+ inoperableCameras[i].setStatus(0);
}
}
- for (int i = 0; i < robos.size(); ++i) {
- if(robos[i].getId() == lastEye){
- robos[i].setStatus(0);
+ for (int i = 0; i < operableCameras.size(); ++i) {
+ if(operableCameras[i].getId() == lastEye){
+ operableCameras[i].setStatus(0);
}
}
}
@@ -248,29 +238,29 @@ void ArsUIMapControlState::tuioAdded(ofxTuioCursor &tuioCursor)
ArsUITappedPoint tappedPoint(loc.x, loc.y, tuioCursor.getFingerId());
getSharedData().tappedPoints.push_back(tappedPoint);
- for (int i = 0; i < buttons.size(); ++i) {
- int bid = buttons[i].hitTestPoint(loc);
+ for (int i = 0; i < inoperableCameras.size(); ++i) {
+ int bid = inoperableCameras[i].hitTestPoint(loc);
if (0 <= bid && bid != eyes[0] && bid != eyes[1]) {
setEye(bid);
- buttons[i].setStatus(1);
+ inoperableCameras[i].setStatus(1);
sendOSCToDisplay(bid);
}
}
- for (int i = 0; i < robos.size(); ++i) {
- int bid = robos[i].hitTestPoint(loc);
+ for (int i = 0; i < operableCameras.size(); ++i) {
+ int bid = operableCameras[i].hitTestPoint(loc);
if (0 <= bid && bid != eyes[0] && bid != eyes[1]){
setEye(bid);
- robos[i].setStatus(1);
+ operableCameras[i].setStatus(1);
sendOSCToDisplay(bid);
}
}
- ofPoint cam1Pos = robos[0].getPosition();
- ofPoint cam2Pos = robos[1].getPosition();
+ ofPoint cam1Pos = operableCameras[0].getPosition();
+ ofPoint cam2Pos = operableCameras[1].getPosition();
float dist1 = ArsUIUtil::distance(loc, cam1Pos);
float dist2 = ArsUIUtil::distance(loc, cam2Pos);
@@ -299,13 +289,13 @@ void ArsUIMapControlState::tuioRemoved(ofxTuioCursor &tuioCursor)
cam1TouchedStartedAt = 0;
cam1FingerId = -1;
isCam1Draggable = false;
+ sendViewpointToServer(operableCameras[0]);
} else if (tuioCursor.getFingerId() == cam2FingerId) {
cam2TouchedStartedAt = 0;
cam2FingerId = -1;
isCam2Draggable = false;
+ sendViewpointToServer(operableCameras[1]);
}
-
- sendViewpointToServer(robos[0]);
}
//--------------------------------------------------------------
@@ -320,7 +310,7 @@ void ArsUIMapControlState::tuioUpdated(ofxTuioCursor &tuioCursor)
cam1Position = loc;
} else {
isCam1Draggable = false;
- robos[0].dragAngle(loc.x, loc.y);
+ operableCameras[0].dragAngle(loc.x, loc.y);
}
if (0 < cam2TouchedStartedAt && 1000 <= ofGetElapsedTimeMillis() - cam2TouchedStartedAt && tuioCursor.getFingerId() == cam2FingerId) {
@@ -328,7 +318,7 @@ void ArsUIMapControlState::tuioUpdated(ofxTuioCursor &tuioCursor)
cam2Position = loc;
} else {
isCam2Draggable = false;
- robos[1].dragAngle(loc.x, loc.y);
+ operableCameras[1].dragAngle(loc.x, loc.y);
}
}
@@ -354,10 +344,22 @@ void ArsUIMapControlState::drawTuioCursors()
}
//--------------------------------------------------------------
+void ArsUIMapControlState::drawCamStatuses(ArsUIRoboCam cam)
+{
+ string str = "X : " + ofToString(cam.getPosition().x) +
+ "\nY : " + ofToString(cam.getPosition().y) +
+ "\nANGLE : " + ofToString(cam.getAngle()) +
+ "\nCOMPASS: " + ofToString(cam.getCompass());
+ ofDrawBitmapString(str, cam.getPosition() + ofPoint(70, -50));
+}
+
+//--------------------------------------------------------------
void ArsUIMapControlState::onOscMessageReceived(ofxOscMessage &msg)
{
string addr = msg.getAddress();
+ cout << "OSC received. address: " << addr << endl;
+
if ("/gianteyes/camera" == addr) {
int udid = msg.getArgAsInt32(0);
float lat = msg.getArgAsFloat(1);
@@ -381,7 +383,20 @@ void ArsUIMapControlState::onOscMessageReceived(ofxOscMessage &msg)
string jsonString = msg.getArgAsString(0);
if (0 < jsonString.length()) {
- json.parse(jsonString);
+ if (json.parse(jsonString)) {
+ ofxJSONElement cameras = json["cameras"];
+
+ inoperableCameras.clear();
+ operableCameras.clear();
+
+ for (int i = 0; i < cameras.size(); ++i) {
+ if (true == cameras[i]["operable"].asBool()) {
+ ArsUIRoboCam r = ArsUIRoboCam(cameras[i]["latitude"].asDouble(), cameras[i]["longitude"].asDouble(), cameras[i]["udid"].asString(), cameras[i]["angle"].asInt(), cameras[i]["compass"].asInt(), cameras[i]["battery"].asInt(), cameras[i]["living"].asBool(), i, fujiPoint);
+ } else {
+ ArsUIButton b = ArsUIButton(cameras[i]["latitude"].asDouble(), cameras[i]["longitude"].asDouble(), cameras[i]["udid"].asString(), cameras[i]["angle"].asInt(), cameras[i]["compass"].asInt(), i, fujiPoint);
+ }
+ }
+ }
}
}
}
View
5 src/ArsUIMapControlState.h
@@ -42,8 +42,8 @@ class ArsUIMapControlState : public Apex::ofxState<ArsUISharedData>
private:
void init();
- vector <ArsUIButton> buttons; // web camera
- vector <ArsUIRoboCam> robos; // robot
+ vector <ArsUIButton> inoperableCameras; // web camera
+ vector <ArsUIRoboCam> operableCameras; // robot
void tuioAdded(ofxTuioCursor & tuioCursor);
void tuioRemoved(ofxTuioCursor & tuioCursor);
@@ -77,6 +77,7 @@ class ArsUIMapControlState : public Apex::ofxState<ArsUISharedData>
bool isCam1Draggable, isCam2Draggable;
int cam1FingerId, cam2FingerId;
unsigned long long cam1TouchedStartedAt, cam2TouchedStartedAt;
+ void drawCamStatuses(ArsUIRoboCam cam);
bool bShowStatus;
};
View
83 src/ArsUIRoboCam.cpp
@@ -1,15 +1,29 @@
#include "ArsUIRoboCam.h"
-ArsUIRoboCam::ArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji,float _angle):ArsUIButton(_x,_y,_bid,_fuji,_angle){
+//--------------------------------------------------------------
+ArsUIRoboCam::ArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji,float _angle, string _udid):ArsUIButton(_x, _y, _bid, _fuji, _angle, _udid)
+{
ArsUIButton::mark.loadImage("markyellow.png");
}
-void ArsUIRoboCam::update(){
+ArsUIRoboCam::ArsUIRoboCam(double _lat, double _lon, string _udid, int _angle, int _compass, float _battery, bool _living, int _bid, ofPoint _fuji):ArsUIButton(
+_lat, _lon, _udid, _angle, _compass, _bid, _fuji)
+{
+ battery = _battery;
+ living = _living;
+ ArsUIButton::mark.loadImage("markyellow.png");
+}
+
+//--------------------------------------------------------------
+void ArsUIRoboCam::update()
+{
ArsUIButton::update();
// dragAngle(x, y);
}
-void ArsUIRoboCam::draw(){
+//--------------------------------------------------------------
+void ArsUIRoboCam::draw()
+{
//status: 0:default 1:select
ofColor c;
@@ -24,9 +38,9 @@ void ArsUIRoboCam::draw(){
ofPath path;
path.setCurveResolution(60);
path.setColor( ofColor(255, 255, 0,40));
- path.moveTo(x,y);
- float angle1 = 360 - (360 * currentDirection/(PI*2) + viewAngle/2) ;
- float angle2 = 360 - (360 * currentDirection/(PI*2) - viewAngle/2) ;
+ path.moveTo(x, y);
+ float angle1 = 360 - (360 * currentDirection / (PI * 2) + angle / 2) ;
+ float angle2 = 360 - (360 * currentDirection / (PI * 2) - angle / 2) ;
path.arc(x, y, distanceToFuji, distanceToFuji, angle1, angle2);
@@ -67,6 +81,7 @@ void ArsUIRoboCam::draw(){
}
+//--------------------------------------------------------------
int ArsUIRoboCam::hitTestPoint(ofPoint p)
{
int _bid = ArsUIButton::hitTestPoint(p);
@@ -77,7 +92,9 @@ int ArsUIRoboCam::hitTestPoint(ofPoint p)
return _bid;
}
-void ArsUIRoboCam::dragAngle(float _x, float _y){
+//--------------------------------------------------------------
+void ArsUIRoboCam::dragAngle(float _x, float _y)
+{
if(status == 1){
float distance = sqrt((x - _x) * (x - _x) + (y - _y) * (y - _y));
if (distance > radius && distance < radius * 1.5) {
@@ -91,7 +108,9 @@ void ArsUIRoboCam::dragAngle(float _x, float _y){
}
}
-bool ArsUIRoboCam::dragAngleEnded (float _x, float _y){
+//--------------------------------------------------------------
+bool ArsUIRoboCam::dragAngleEnded (float _x, float _y)
+{
if(status == 1){
float distance = sqrt((x - _x) * (x - _x) + (y - _y) *(y - _y) );
if (distance > radius && distance < radius *1.5) {
@@ -102,21 +121,59 @@ bool ArsUIRoboCam::dragAngleEnded (float _x, float _y){
return false;
}
-void ArsUIRoboCam::setDefaultAngle(){
+//--------------------------------------------------------------
+void ArsUIRoboCam::setDefaultAngle()
+{
currentDirection = directionToFuji;
}
-void ArsUIRoboCam::setRoboStatus(string _udid, double _lat, double _long, double _robox, double _roboy, double _buttery, bool _living){
+//--------------------------------------------------------------
+void ArsUIRoboCam::setRoboStatus(string _udid, double _lat, double _long, double _robox, double _roboy, double _battery, bool _living)
+{
udid = _udid;
latitude = _lat;
- longtitude = _long;
+ longitude = _long;
xpos = _robox;
ypos = _roboy;
- buttery = _buttery;
+ battery = _battery;
living = _living;
- ofPoint p = GPStoXY(latitude, longtitude);
+ ofPoint p = GPStoXY(latitude, longitude);
x = p.x;
y = p.y;
}
+//--------------------------------------------------------------
+void ArsUIRoboCam::setCamStatus(string jsonString)
+{
+ ofxJSONElement json;
+ if (json.parse(jsonString)) {
+ setCameraStatus(json);
+ battery = json["battery"].asInt();
+ living = json["living"].asBool();
+ }
+}
+
+//--------------------------------------------------------------
+int ArsUIRoboCam::getBattery()
+{
+ return (int)battery;
+}
+
+//--------------------------------------------------------------
+void ArsUIRoboCam::setBattery(int value)
+{
+ battery = value;
+}
+
+//--------------------------------------------------------------
+bool ArsUIRoboCam::getLiving()
+{
+ return living;
+}
+
+//--------------------------------------------------------------
+void ArsUIRoboCam::setLiving(bool value)
+{
+ living = value;
+}
View
16 src/ArsUIRoboCam.h
@@ -1,14 +1,17 @@
#include "ArsUIButton.h"
+#include "ofxJSONElement.h"
class ArsUIRoboCam: public ArsUIButton
{
private:
string udid;
- double xpos, ypos, buttery;
- bool living;
+ double xpos, ypos;
+ float battery;
+ bool living;
public:
- ArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji, float angle);
+ ArsUIRoboCam(float _x, float _y, int _bid, ofPoint _fuji, float angle, string _udid);
+ ArsUIRoboCam(double _lat, double _lon, string _udid, int _angle, int _compass, float _battery, bool _living, int _bid, ofPoint _fuji);
void draw();
void update();
@@ -17,4 +20,11 @@ class ArsUIRoboCam: public ArsUIButton
bool dragAngleEnded(float _, float _y);
void setDefaultAngle();
void setRoboStatus(string _udid, double _lat, double _long, double _robox, double _roboy, double _buttery, bool _living );
+ void setCamStatus(string jsonString);
+
+ int getBattery();
+ void setBattery(int value);
+
+ bool getLiving();
+ void setLiving(bool value);
};
View
11 src/ArsUIUtil.h
@@ -24,7 +24,8 @@ class ArsUIUtil
return abs(sqrt(a * a + b * b));
};
- static ofPoint GPStoXY(ofPoint fujiPos, double lat, double lon) {
+ static ofPoint GPStoXY(double lat, double lon) {
+ ofPoint fujiPos = ofPoint(964, 600);
ofPoint yamanakaLakePos = ofPoint(1263, 489);
ofPoint p;
@@ -47,8 +48,12 @@ class ArsUIUtil
// return newPoint;
};
- static ofPoint XYtoGPS(ofPoint fujiPos, ofPoint pos) {
-
+ static ofPoint XYtoGPS(ofPoint fujiPos) {
+ // 35.601610, 138.255997
+ // 35.165514, 139.199448
+ double lat = ofMap(fujiPos.x, 0, ofGetWidth(), 35.601610, 35.165514);
+ double lon = ofMap(fujiPos.y, 0, ofGetHeight(), 138.255997, 139.199448);
+ return ofPoint(lat, lon);
};
};
View
2  src/testApp.h
@@ -12,7 +12,7 @@
#define DISPLAY_HOST "127.0.0.1"
#define DISPLAY_PORT 4444
-#define SERVER_HOST SERVER_HOST_DEVELOPMENT
+#define SERVER_HOST SERVER_HOST_PRODUCTION
#define SERVER_PORT 7771
#define INCOMING_PORT 5000
Please sign in to comment.
Something went wrong with that request. Please try again.