Commit 86624061 authored by Daniel Flickinger's avatar Daniel Flickinger
Browse files

New application: gorobotc

 (Console interactive robot driving program)
parent 5a4e9df8
......@@ -3,16 +3,21 @@
# Dan Flickinger
#
# 2004/10/04
# 2004/11/19
# 2004/12/08
HOSTPATH=/z/garcia/brainstem
# Build for Stargate:
ARCH=ARM
CC=/usr/local/arm/3.4.1/bin/arm-linux-g++
CFLAGS=-DaUNIX -s -static
# Build for i386:
#ARCH=i686
#CC=g++
#CFLAGS=-DaUNIX -g
INCLUDES=-I$(HOSTPATH)/aCommon \
-I$(HOSTPATH)/aUnix \
......@@ -38,16 +43,12 @@ LIBRARIES=\
VPATH=$(HOSTPATH)/aCommon:$(HOSTPATH)/aUnix
CFLAGS=-DaUNIX -s -static
#CFLAGS=-DaUNIX -g
LDFLAGS=-L$(HOSTPATH)/aRelease/aUnix/$(ARCH)/
OBJECTSREQ=grobot gcallbacks gbehaviors simplepath
OBJECTS=grobot.o gcallbacks.o gbehaviors.o simplepath.o
all: commotion pathmotion circle gorobot
all: commotion pathmotion circle gorobot gorobotc
commotion: $(OBJECTSREQ)
......@@ -62,6 +63,10 @@ circle: $(OBJECTSREQ)
gorobot: $(OBJECTSREQ)
$(CC) -o gorobot $(OBJECTS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) gorobot.cc $(LIBRARIES)
gorobotc: $(OBJECTSREQ)
$(CC) -o gorobotc $(OBJECTS) $(INCLUDES) $(CFLAGS) $(LDFLAGS) gorobotc.cc $(LIBRARIES)
# %.o : %.c
# $(CC) $(CFLAGS) -c -o $@ $< $(INCLUDES)
#
......@@ -91,3 +96,4 @@ clean :
rm -f circle
rm -f batt
rm -f gorobot
rm -f gorobotc
......@@ -6,7 +6,7 @@
* Dan Flickinger
*
* 2004/11/12
* 2004/12/07
* 2004/12/09
*/
#include "dgrobot/commotion.h"
......@@ -20,10 +20,12 @@ int main(int argc, char **argv) {
int quitnow = 0; // quit now
int lsetup = 0; // listener is setup
grobot mrrobot; // Mr. Robot
int gstatus; // status of goto move
grobot mrrobot; // Mr. Robot
int gor_sock; // GoRobot socket
int msg_sock; // MSG socket
int gor_sock; // GoRobot socket
int msg_sock; // MSG socket
struct sockaddr_in gor_sin; // listener sockaddr
......@@ -232,15 +234,26 @@ int main(int argc, char **argv) {
// give robot a chance to handle callbacks
// if (mrrobot.garcia.getNamedValue("idle")->getBoolVal()) {
if (mrrobot.sleepy() != 0) {
// a callback has been sent
// PROBLEM: three callbacks are expected for a goto command
}
mrrobot.sleepy();
// poll grobot for behavior completion
// if behavior has completed: send back notification to RMCD
gstatus = mrrobot.getGOTOstatus();
if (0 != Gstatus) {
// send back notification to RMCD about goto behavior completion
// determine if the move was successful
if (gstatus > 0) {
// move was good
// FIXME
} else {
// move was bad
// FIXME
}
// send back position
// FIXME
}
......
/* gorobotc.cc
*
* Console application to drive robot using grobot::goto()
*
* Dan Flickinger
*
* 2004/12/08
* 2004/12/09
*/
#include "dgrobot/commotion.h"
int main() {
float dx, dy, dr;
float dxe, dye;
int quitnow = 0;
int gstatus = 0;
grobot mrrobot;
while (quitnow == 0) {
std::cout << "? " << std::flush;
std::cin >> dx >> dy >> dr;
if ((float)(dx) == 0.0f && (float)(dy) == 0.0f) {
if ((float)(dr) == 0.0f) {
// send an estop
std::cout << "ESTOP" << std::endl;
mrrobot.estop();
} else {
std::cout << "Quiting..." << std::endl;
quitnow = 1;
}
} else {
mrrobot.dgoto((float)(dx), (float)(dy), (float)(dr));
// wait for moves to complete
while (!mrrobot.garcia.getNamedValue("idle")->getBoolVal()) {
mrrobot.sleepy();
}
// get the status
gstatus = mrrobot.getGOTOstatus();
mrrobot.getDisplacement(dxe, dye);
std::cout << "Goto move finished with status: " << gstatus
<< std::endl
<< "(Estimated position: " << dxe << ", "
<< dye << ".)" << std::endl;
}
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment