diff --git a/.gitignore b/.gitignore index 0330a29a..6e878975 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,6 @@ noggin/util/fakeData/* /motion/README.log /motion/README.toc /motion/README.pdf -docs*/ +docs* /noggin/offline/c++filt /noggin/offline/faker diff --git a/Makefile b/Makefile index 94b5c0be..048e3d18 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,7 @@ CROSS_TOOLCHAIN = $(abspath $(CURDIR)/cmake/geode.cmake) CMAKE_DEFS = -DOE_CROSS_BUILD=OFF -DSTRAIGHT=ON CMAKE_CROSS_DEFS = -DCMAKE_TOOLCHAIN_FILE=$(CROSS_TOOLCHAIN) -DOE_CROSS_BUILD=ON CMAKE_WEBOTS_DEFS = -DOE_CROSS_BUILD=OFF -DMAN_IS_REMOTE_=ON -DWEBOTS_BACKEND=ON -DCOLOR_TABLE=tables/webots.mtb +CCMAKE_CROSS_OPT = -DCMAKE_SHARED_LINKER_FLAGS:STRING="" -DCMAKE_MODULE_LINKER_FLAGS:STRING="" TRUNK_REVISION = r0# $(shell svn info | grep Revision | awk 'FS=" " {print $$2}') export TRUNK_REVISION @@ -70,7 +71,7 @@ $(STRAIGHT_FILE): cross: $(CROSS_FILE) @set -e ; \ $(CD) $(BUILD_DIR); \ - $(CCMAKE) . + $(CCMAKE) $(CCMAKE_CROSS_OPT) . $(CROSS_FILE): @if [ -e $(STRAIGHT_FILE) ] || [ -e $(WEBOTS_FILE) ]; then \ diff --git a/Man.cpp b/Man.cpp index 240fa153..4dcfe83b 100755 --- a/Man.cpp +++ b/Man.cpp @@ -88,6 +88,7 @@ Man::Man (shared_ptr _sensors, noggin = shared_ptr(new Noggin(profiler,vision,comm,guardian, sensors, motion->getInterface())); #endif// USE_NOGGIN + PROF_ENTER(profiler.get(), P_GETIMAGE); } Man::~Man () @@ -166,9 +167,10 @@ Man::processFrame () //if(camera_active) //vision->copyImage(sensors->getImage()); #endif - PROF_EXIT(profiler.get(), P_GETIMAGE); + PROF_ENTER(profiler.get(), P_FINAL); + PROF_EXIT(profiler.get(), P_GETIMAGE); #ifdef USE_VISION //if(camera_active) vision->notifyImage(sensors->getImage()); @@ -183,16 +185,16 @@ Man::processFrame () lights->sendLights(); PROF_EXIT(profiler.get(), P_LIGHTS); + PROF_ENTER(profiler.get(), P_GETIMAGE); PROF_EXIT(profiler.get(), P_FINAL); PROF_NFRAME(profiler.get()); - - PROF_ENTER(profiler.get(), P_GETIMAGE); } void Man::notifyNextVisionImage() { // Synchronize noggin's information about joint angles with the motion // thread's information + sensors->updateVisionAngles(); transcriber->postVisionSensors(); diff --git a/cmake.man/CMakeLists.txt b/cmake.man/CMakeLists.txt index 03a1c546..130066a4 100755 --- a/cmake.man/CMakeLists.txt +++ b/cmake.man/CMakeLists.txt @@ -150,7 +150,7 @@ SET( ROBOT_NAME ${@ROBOT_NAME@} ) ############################ COLOR TABLE SELECTION # Set the path to the color table you wish to be loaded into install/etc SET( COLOR_TABLE - "tables/lab120/joho850.mtb" + "tables/lab120/jack800.mtb" CACHE STRING "Path relative to man directory for the desired color table" ) diff --git a/cmake/base_definitions.cmake b/cmake/base_definitions.cmake index a535ef53..6bcab308 100644 --- a/cmake/base_definitions.cmake +++ b/cmake/base_definitions.cmake @@ -4,6 +4,7 @@ # The basic diefinitions for the Northern Bites cmake packages, used # throughout different packages' configurations +cmake_policy(SET CMP0011 OLD) ############################ TRUNK PATH # Ensure the TRUNK_PATH variable is set diff --git a/comm/Comm.cpp b/comm/Comm.cpp index e3c0a42e..70c023a1 100755 --- a/comm/Comm.cpp +++ b/comm/Comm.cpp @@ -466,6 +466,10 @@ void Comm::run () running = true; trigger->on(); + struct timespec interval, remainder; + interval.tv_sec = 0; + interval.tv_nsec = SLEEP_MILLIS * 1000; + try { bind(); @@ -476,7 +480,7 @@ void Comm::run () while (running && !timer.time_for_packet()) { receive(); - usleep(SLEEP_MILLIS); + nanosleep(&interval, &remainder); } } }catch (socket_error &e) { @@ -703,13 +707,17 @@ void Comm::send (const char *msg, int len, sockaddr_in &addr) throw(socket_error // send the udp message int result = -2; + struct timespec interval, remainder; + interval.tv_sec = 0; + interval.tv_nsec = 100000; + while (result == -2) { result = ::sendto(sockn, msg, len, 0, (struct sockaddr*)&addr, sizeof(broadcast_addr)); // except if error is blocking error if (result == -1 && errno == EAGAIN) { result = -2; - usleep(100); + nanosleep(&interval, &remainder); } } diff --git a/corpus/ALEnactor.cpp b/corpus/ALEnactor.cpp index 76e59503..1fce1561 100644 --- a/corpus/ALEnactor.cpp +++ b/corpus/ALEnactor.cpp @@ -40,6 +40,7 @@ void ALEnactor::run() { Thread::trigger->on(); long long currentTime; + struct timespec interval, remainder; while (running) { currentTime = micro_time(); sendCommands(); @@ -55,8 +56,10 @@ void ALEnactor::run() { << processTime <(MOTION_FRAME_LENGTH_uS - - static_cast(processTime))); + interval.tv_sec = 0; + interval.tv_nsec = static_cast(MOTION_FRAME_LENGTH_uS + - static_cast(processTime)); + nanosleep(&interval,&remainder); } #endif diff --git a/corpus/ALImageTranscriber.cpp b/corpus/ALImageTranscriber.cpp index 93240563..b3511069 100644 --- a/corpus/ALImageTranscriber.cpp +++ b/corpus/ALImageTranscriber.cpp @@ -55,6 +55,8 @@ void ALImageTranscriber::run() { Thread::trigger->on(); long long lastProcessTimeAvg = VISION_FRAME_LENGTH_uS; + + struct timespec interval, remainder; while (Thread::running) { //start timer const long long startTime = micro_time(); @@ -74,12 +76,15 @@ void ALImageTranscriber::run() { << " frame length: " << processTime <((VISION_FRAME_LENGTH_uS + -processTime) * 1000); - //usleep(10000000); - usleep(static_cast(VISION_FRAME_LENGTH_uS - -processTime)); + nanosleep(&interval, &remainder); } } Thread::trigger->off(); diff --git a/corpus/RoboGuardian.cpp b/corpus/RoboGuardian.cpp index f8dbf843..8ef16d21 100644 --- a/corpus/RoboGuardian.cpp +++ b/corpus/RoboGuardian.cpp @@ -83,6 +83,9 @@ void RoboGuardian::run(){ Thread::running = true; Thread::trigger->on(); + struct timespec interval, remainder; + interval.tv_sec = 0; + interval.tv_nsec = static_cast(GUARDIAN_FRAME_LENGTH_uS * 1000); while(Thread::running){ countButtonPushes(); @@ -92,7 +95,7 @@ void RoboGuardian::run(){ checkTemperatures(); processFallingProtection(); processChestButtonPushes(); - usleep(static_cast(GUARDIAN_FRAME_LENGTH_uS)); + nanosleep(&interval, &remainder); } Thread::trigger->off(); diff --git a/motion/AbstractGait.cpp b/motion/AbstractGait.cpp index b64b9618..6cfe470d 100644 --- a/motion/AbstractGait.cpp +++ b/motion/AbstractGait.cpp @@ -1,7 +1,8 @@ #include "AbstractGait.h" #include -#include +#include "string.h" +#include "stdio.h" using namespace std; AbstractGait::AbstractGait(){} AbstractGait::~AbstractGait(){} diff --git a/noggin/players/SweetStates.py b/noggin/players/SweetStates.py new file mode 100644 index 00000000..c95e0257 --- /dev/null +++ b/noggin/players/SweetStates.py @@ -0,0 +1,32 @@ +# +# Defines states for SweetMove testing +# + +import man.motion.SweetMoves as SweetMoves + +def gameInitial(player): + player.gainsOn() + return player.stay() + +def gameReady(player): + return player.goLater('doMove') +def gameSet(player): + return player.goLater('doMove') +def gamePlaying(player): + return player.goLater('doMove') +def gamePenalized(player): + return player.goLater('doMove') + +def doMove(player): + if player.firstFrame(): + player.gainsOn() + player.executeMove(SweetMoves.ZERO_POS) + + if player.counter == 1: + return player.goLater('done') + return player.stay() + +def done(player): + if player.firstFrame(): + return player.stay() + return player.stay() diff --git a/noggin/players/pSweet.py b/noggin/players/pSweet.py new file mode 100644 index 00000000..eb12093a --- /dev/null +++ b/noggin/players/pSweet.py @@ -0,0 +1,15 @@ +# +# A behavior to test SweetMoves. +# + +from . import SoccerFSA +from . import SweetStates + +class SoccerPlayer(SoccerFSA.SoccerFSA): + def __init__(self, brain): + SoccerFSA.SoccerFSA.__init__(self,brain) + self.addStates(SweetStates) + self.setName('pSweet') + # No fall protection when testing sweetMoves + brain.roboguardian.enableFallProtection(False) + diff --git a/scripts/setup-autologin b/scripts/setup-autologin new file mode 100755 index 00000000..2f8f3a56 --- /dev/null +++ b/scripts/setup-autologin @@ -0,0 +1,39 @@ +#!/bin/sh +############################################################################### +# This script will setup auto-login into a remote machine. Specifically, +# this is is useful for seting up auto-login for the Naos. +# Instructions filtched from http://linuxproblem.org/art_9.html +# +# NOTE: If you run this script twice on the same robot, your hostname will +# appear twice in .ssh/authorized_keys. Login will still work, but you will +# bloat the file +# +# jstrom, June 2008 +# +############################################################################## + +REMOTE_USERNAME=root +SSH=~/.ssh +ID_RSA_FILE=$SSH/id_rsa +RSA_PUBLIC_KEY_FILE=$SSH/id_rsa.pub + +if [ "$1" == "" ]; then + echo "Usage: ./setup-autologin " + exit 1 +fi + +echo "Configuring auto login. Only run this once per robot " + + +if [ ! -e $RSA_PUBLIC_KEY_FILE ] || [ ! -e $ID_RSA_FILE ]; then + echo "Generating a public key" + ssh-keygen -t rsa -N "" -f $ID_RSA_FILE +else + echo "Detected an exisiting public key, so won't generate a new one" +fi + +echo "Configuring remote robot with your public key." +echo "Please enter the password for the robot when promted:" +cat $RSA_PUBLIC_KEY_FILE | ssh $REMOTE_USERNAME@$1 'mkdir -p .ssh && cat >> .ssh/authorized_keys' + +echo "setup complete" diff --git a/vision/VisualFieldObject.h b/vision/VisualFieldObject.h index dbb5d2d4..5700f5a5 100644 --- a/vision/VisualFieldObject.h +++ b/vision/VisualFieldObject.h @@ -14,6 +14,7 @@ class VisualFieldObject; #include "VisionStructs.h" #include "VisionHelpers.h" #include "Blob.h" +#include "stdio.h" // This class should eventually inheret from VisualLandmark, once it is // cleaned a bit