|
From: <ge...@us...> - 2008-04-17 19:51:25
|
Revision: 117
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=117&view=rev
Author: gerkey
Date: 2008-04-17 12:51:25 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
Modified Paths:
--------------
pkg/trunk/gmapping/gui/gsp_thread.cpp
pkg/trunk/gmapping/gui/gsp_thread.h
pkg/trunk/gmapping/utils/gvalues.h
Added Paths:
-----------
pkg/trunk/gmapping/playerwrapper/
pkg/trunk/gmapping/playerwrapper/Makefile
pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
pkg/trunk/gmapping/playerwrapper/playergfswrapper.h
Modified: pkg/trunk/gmapping/gui/gsp_thread.cpp
===================================================================
--- pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-17 19:49:41 UTC (rev 116)
+++ pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-17 19:51:25 UTC (rev 117)
@@ -504,6 +504,12 @@
pthread_create(&gfs_thread, 0, (void * (*)(void *))fastslamthread, (void *) this);
}
+void GridSlamProcessorThread::start(PlayerGFSWrapper* pwrapper)
+{
+ m_pwrapper = pwrapper;
+ start();
+}
+
void GridSlamProcessorThread::stop(){
if (! running){
cout << "PORCO CAZZO" << endl;
Modified: pkg/trunk/gmapping/gui/gsp_thread.h
===================================================================
--- pkg/trunk/gmapping/gui/gsp_thread.h 2008-04-17 19:49:41 UTC (rev 116)
+++ pkg/trunk/gmapping/gui/gsp_thread.h 2008-04-17 19:51:25 UTC (rev 117)
@@ -36,6 +36,11 @@
using namespace std;
using namespace GMapping;
+#ifdef PLAYER_SUPPORT
+namespace GMapping {
+class PlayerGFSWrapper;
+}
+#endif
#define MAX_STRING_LENGTH 1024
@@ -82,6 +87,10 @@
EventDeque getEvents();
+#ifdef PLAYER_SUPPORT
+ PlayerGFSWrapper* m_pwrapper;
+ void start(PlayerGFSWrapper* pwrapper);
+#endif
void start();
void stop();
Added: pkg/trunk/gmapping/playerwrapper/Makefile
===================================================================
--- pkg/trunk/gmapping/playerwrapper/Makefile (rev 0)
+++ pkg/trunk/gmapping/playerwrapper/Makefile 2008-04-17 19:51:25 UTC (rev 117)
@@ -0,0 +1,16 @@
+OBJS= playergfswrapper.o
+APPS=
+
+#LIBS+= -L$(CARMEN_HOME)/lib -lnavigator_interface -lsimulator_interface -lrobot_interface -llaser_interface -lparam_interface -lglobal -lipc -lm -lutils -lsensor_range -llog -lscanmatcher -lpthread -lz
+LIBS+= `pkg-config --libs playercore` -lsensor_range
+#-L$(CARMEN_HOME)/lib -lnavigator_interface -lsimulator_interface -lrobot_interface -llaser_interface -lparam_interface -lglobal -lipc -lm -lutils -lsensor_range -llog -lscanmatcher -lpthread -lz
+CPPFLAGS+=-I../sensor `pkg-config --cflags playercore`
+
+-include ../global.mk
+
+ifeq ($(PLAYERSUPPORT), 0)
+OBJS=
+ -include ../build_tools/Makefile.app
+else
+ -include ../build_tools/Makefile.generic-shared-object
+endif
Added: pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp (rev 0)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-17 19:51:25 UTC (rev 117)
@@ -0,0 +1,178 @@
+/*****************************************************************
+ *
+ * This file is part of the GMAPPING project
+ *
+ * Player wrapper code (c) 2008 Brian Gerkey
+ *
+ * GMAPPING Copyright (c) 2004 Giorgio Grisetti,
+ * Cyrill Stachniss, and Wolfram Burgard
+ *
+ * This software is licensed under the "Creative Commons
+ * License (Attribution-NonCommercial-ShareAlike 2.0)"
+ * and is copyrighted by Giorgio Grisetti, Cyrill Stachniss,
+ * and Wolfram Burgard.
+ *
+ * Further information on this license can be found at:
+ * http://creativecommons.org/licenses/by-nc-sa/2.0/
+ *
+ * GMAPPING is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ *
+ *****************************************************************/
+
+
+#include "playergfswrapper.h"
+
+using namespace GMapping;
+
+PlayerGFSWrapper::PlayerGFSWrapper(ConfigFile* cf, int section)
+ : Driver(cf, section)
+{
+ memset(&this->position_id, 0, sizeof(player_devaddr_t));
+ memset(&this->map_id, 0, sizeof(player_devaddr_t));
+
+ // Do we create a position interface?
+ if(cf->ReadDeviceAddr(&(this->position_id), section, "provides",
+ PLAYER_POSITION2D_CODE, -1, NULL) == 0)
+ {
+ if(this->AddInterface(this->position_id))
+ {
+ this->SetError(-1);
+ return;
+ }
+ }
+
+ // Do we create a map interface?
+ if(cf->ReadDeviceAddr(&(this->map_id), section, "provides",
+ PLAYER_MAP_CODE, -1, NULL) == 0)
+ {
+ if(this->AddInterface(this->map_id))
+ {
+ this->SetError(-1);
+ return;
+ }
+ }
+
+ // Must have a laser device to read from
+ if(cf->ReadDeviceAddr(&(this->laser_id), section, "requires",
+ PLAYER_LASER_CODE, -1, NULL) != 0)
+ {
+ PLAYER_ERROR("must have a laser device from which to read");
+ this->SetError(-1);
+ return;
+ }
+}
+
+int
+PlayerGFSWrapper::Setup()
+{
+ // Subscribe to the laser device.
+ if(!(this->laser = deviceTable->GetDevice(this->laser_id)))
+ {
+ PLAYER_ERROR("unable to locate suitable laser device");
+ return(-1);
+ }
+ if(this->laser->Subscribe(this->InQueue) != 0)
+ {
+ PLAYER_ERROR("unable to subscribe to laser device");
+ return(-1);
+ }
+
+ pthread_mutex_init(&this->rangeDeque_mutex, NULL);
+
+ // TODO: get laser geometry
+
+ this->gsp = new GridSlamProcessorThread();
+
+ // TODO: create this->laser_rs
+
+ // TODO: compute GFS "sensorMap"
+
+ // start GFS thread
+ this->gsp->start(this);
+
+ this->StartThread();
+ return(0);
+}
+
+int
+PlayerGFSWrapper::Shutdown()
+{
+ this->StopThread();
+
+ this->laser->Unsubscribe(this->InQueue);
+
+ // stop GFS thread
+ this->gsp->stop();
+
+ delete this->gsp;
+
+ pthread_mutex_destroy(&this->rangeDeque_mutex);
+
+ return(0);
+}
+
+void
+PlayerGFSWrapper::Main()
+{
+ for(;;)
+ {
+ this->ProcessMessages();
+
+ // TODO: check for new pose / map from GFS thread
+ }
+}
+
+bool
+PlayerGFSWrapper::getReading(RangeReading& reading)
+{
+ bool ret=false;
+ pthread_mutex_lock(&this->rangeDeque_mutex);
+ if(!this->rangeDeque.empty())
+ {
+ reading=this->rangeDeque.front();
+ this->rangeDeque.pop_front();
+ ret=true;
+ }
+ pthread_mutex_unlock(&this->rangeDeque_mutex);
+ return(ret);
+}
+
+int
+PlayerGFSWrapper::ProcessMessage(QueuePointer & resp_queue,
+ player_msghdr * hdr,
+ void * data)
+{
+ // TODO: handle:
+ // map requests
+ //
+ // laser scanpose messages (convert and cache them for consumption by
+ // GFS thread)
+ if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_DATA,
+ PLAYER_LASER_DATA_SCANPOSE,
+ this->laser_id))
+ {
+ this->ProcessLaser(hdr, (player_laser_data_scanpose_t*)data);
+ return(0);
+ }
+ else
+ return(-1);
+}
+
+void
+PlayerGFSWrapper::ProcessLaser(player_msghdr_t* hdr,
+ player_laser_data_scanpose_t* data)
+{
+ RangeReading reading(this->laser_rs,hdr->timestamp);
+ for(unsigned int i=0;i<data->scan.ranges_count;i++)
+ reading[i] = data->scan.ranges[i];
+ reading.setPose(OrientedPoint(data->pose.px,
+ data->pose.py,
+ data->pose.pa));
+
+ pthread_mutex_lock(&this->rangeDeque_mutex);
+ this->rangeDeque.push_back(reading);
+ pthread_mutex_unlock(&this->rangeDeque_mutex);
+}
Added: pkg/trunk/gmapping/playerwrapper/playergfswrapper.h
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.h (rev 0)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.h 2008-04-17 19:51:25 UTC (rev 117)
@@ -0,0 +1,151 @@
+/*****************************************************************
+ *
+ * This file is part of the GMAPPING project
+ *
+ * Player wrapper code (c) 2008 Brian Gerkey
+ *
+ * GMAPPING Copyright (c) 2004 Giorgio Grisetti,
+ * Cyrill Stachniss, and Wolfram Burgard
+ *
+ * This software is licensed under the "Creative Commons
+ * License (Attribution-NonCommercial-ShareAlike 2.0)"
+ * and is copyrighted by Giorgio Grisetti, Cyrill Stachniss,
+ * and Wolfram Burgard.
+ *
+ * Further information on this license can be found at:
+ * http://creativecommons.org/licenses/by-nc-sa/2.0/
+ *
+ * GMAPPING is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ *
+ *****************************************************************/
+
+
+#ifndef PLAYERWRAPPER_H
+#define PLAYERWRAPPER_H
+
+//#include <iostream>
+#include <deque>
+#include <pthread.h>
+//#include <semaphore.h>
+
+//#include <carmen/carmen.h>
+//#include <carmen/global.h>
+//#include <log/carmenconfiguration.h>
+
+#include <libplayercore/playercore.h>
+
+#include <gui/gsp_thread.h>
+
+//#include <sensor/sensor_base/sensor.h>
+//#include <log/sensorstream.h>
+//#include <log/sensorlog.h>
+#include <sensor/sensor_range/rangesensor.h>
+#include <sensor/sensor_range/rangereading.h>
+
+namespace GMapping {
+
+class PlayerGFSWrapper : public Driver
+{
+ private:
+ virtual void Main();
+ int SetupLaser();
+
+ // Devices we provide
+ player_devaddr_t position_id;
+ player_devaddr_t map_id;
+
+ // Devices to which we subscribe
+ player_devaddr_t laser_id;
+ Device* laser;
+ RangeSensor* laser_rs;
+
+ // The GFS object
+ GridSlamProcessorThread* gsp;
+
+ // Queue of range readings, with mutex
+ std::deque<RangeReading> rangeDeque;
+ pthread_mutex_t rangeDeque_mutex;
+
+ void ProcessLaser(player_msghdr_t* hdr,
+ player_laser_data_scanpose_t* data);
+
+ public:
+ PlayerGFSWrapper(ConfigFile* cf, int section);
+ virtual int Setup();
+ virtual int Shutdown();
+ virtual int ProcessMessage(QueuePointer & resp_queue,
+ player_msghdr * hdr,
+ void * data);
+
+ bool getReading(RangeReading& reading);
+
+ /*
+ void initializeIPC(const char* name);
+ bool start(const char* name);
+ bool isRunning();
+ void lock();
+ void unlock();
+ int registerLocalizationMessages();
+
+ int queueLength();
+ OrientedPoint getTruePos();
+ bool getReading(RangeReading& reading);
+ void addReading(RangeReading& reading);
+ const SensorMap& sensorMap();
+ bool sensorMapComputed();
+ bool isStopped();
+
+ // conversion function
+ carmen_robot_laser_message reading2carmen(const RangeReading& reading);
+ RangeReading carmen2reading(const carmen_robot_laser_message& msg);
+ carmen_point_t point2carmen (const OrientedPoint& p);
+ OrientedPoint carmen2point (const carmen_point_t& p);
+
+
+ // carmen interaction
+ void robot_frontlaser_handler(carmen_robot_laser_message* frontlaser);
+ void robot_rearlaser_handler(carmen_robot_laser_message* frontlaser);
+ void simulator_truepos_handler(carmen_simulator_truepos_message* truepos);
+ //babsi:
+ void navigator_go_handler(MSG_INSTANCE msgRef, BYTE_ARRAY callData, void*) ;
+ void navigator_stop_handler(MSG_INSTANCE msgRef, BYTE_ARRAY callData, void*) ;
+
+ //babsi:
+ void publish_globalpos(carmen_localize_summary_p summary);
+ void publish_particles(carmen_localize_particle_filter_p filter,
+ carmen_localize_summary_p summary);
+
+ void shutdown_module(int sig);
+
+ private:
+ std::deque<RangeReading> m_rangeDeque;
+ sem_t m_dequeSem;
+ pthread_mutex_t m_mutex, m_lock;
+ pthread_t m_readingThread;
+ void * m_reading_function(void*);
+ bool m_threadRunning;
+ SensorMap m_sensorMap;
+ RangeSensor* m_frontLaser, *m_rearLaser;
+ OrientedPoint m_truepos;
+ bool stopped;
+ */
+};
+
+} //end namespace
+
+
+
+#endif
+/*
+int main (int argc, char** argv) {
+
+ CarmenWrapper::init_carmen(argc, argv);
+ while (true) {
+ IPC_listenWait(100);
+ }
+ return 1;
+}
+*/
Modified: pkg/trunk/gmapping/utils/gvalues.h
===================================================================
--- pkg/trunk/gmapping/utils/gvalues.h 2008-04-17 19:49:41 UTC (rev 116)
+++ pkg/trunk/gmapping/utils/gvalues.h 2008-04-17 19:51:25 UTC (rev 117)
@@ -8,7 +8,7 @@
#include <limits.h>
#include <math.h>
#define MAXDOUBLE 1e1000
- #define isnan(x) (x==FP_NAN)
+ //#define isnan(x) (x==FP_NAN)
#endif
#ifdef _WIN32
#include <limits>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-04-18 00:50:50
|
Revision: 127
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=127&view=rev
Author: gerkey
Date: 2008-04-17 17:50:56 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
working on gmapping
Modified Paths:
--------------
pkg/trunk/gmapping/Makefile
pkg/trunk/gmapping/build_tools/testlib
pkg/trunk/gmapping/gridfastslam/Makefile
pkg/trunk/gmapping/gridfastslam/gridslamprocessor_tree.cpp
pkg/trunk/gmapping/gui/Makefile
pkg/trunk/gmapping/gui/gfs2img.cpp
pkg/trunk/gmapping/gui/gsp_thread.cpp
pkg/trunk/gmapping/gui/gsp_thread.h
pkg/trunk/gmapping/manual.mk
pkg/trunk/gmapping/playerwrapper/Makefile
pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
pkg/trunk/gmapping/playerwrapper/playergfswrapper.h
pkg/trunk/gmapping/scanmatcher/Makefile
pkg/trunk/gmapping/scanmatcher/scanmatcherprocessor.cpp
pkg/trunk/gmapping/scanmatcher/scanmatcherprocessor.h
pkg/trunk/gmapping/utils/Makefile
pkg/trunk/gmapping/utils/stat.cpp
Added Paths:
-----------
pkg/trunk/gmapping/playerwrapper/examples/
pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg
pkg/trunk/gmapping/playerwrapper/examples/writelog_2008_04_17_13_15_20.log.gz
pkg/trunk/gmapping/scanmatcher/eig3.c
pkg/trunk/gmapping/scanmatcher/eig3.h
Modified: pkg/trunk/gmapping/Makefile
===================================================================
--- pkg/trunk/gmapping/Makefile 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/Makefile 2008-04-18 00:50:56 UTC (rev 127)
@@ -3,12 +3,16 @@
ifeq ($(CARMENSUPPORT),1)
SUBDIRS=utils sensor log configfile scanmatcher carmenwrapper gridfastslam gui gfs-carmen
else
+ifeq ($(PLAYERSUPPORT),1)
+SUBDIRS=utils sensor log configfile scanmatcher gridfastslam playerwrapper gui
+else
ifeq ($(MACOSX),1)
SUBDIRS=utils sensor log configfile scanmatcher gridfastslam
else
SUBDIRS=utils sensor log configfile scanmatcher gridfastslam gui
endif
endif
+endif
LDFLAGS+=
CPPFLAGS+= -I../sensor
Modified: pkg/trunk/gmapping/build_tools/testlib
===================================================================
--- pkg/trunk/gmapping/build_tools/testlib 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/build_tools/testlib 2008-04-18 00:50:56 UTC (rev 127)
@@ -3,6 +3,9 @@
echo "Syntax: rtestlib <library>"
exit 1
fi
+
+exit 0
+
FNAME=`mktemp rtestlibXXXXXX`
echo "int main() { return 0; }" > $FNAME.cpp
Modified: pkg/trunk/gmapping/gridfastslam/Makefile
===================================================================
--- pkg/trunk/gmapping/gridfastslam/Makefile 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/gridfastslam/Makefile 2008-04-18 00:50:56 UTC (rev 127)
@@ -1,8 +1,10 @@
OBJS= gridslamprocessor_tree.o motionmodel.o gridslamprocessor.o gfsreader.o
-APPS= gfs2log gfs2rec gfs2neff gfs2stat
+APPS= gfs2log gfs2rec gfs2neff #gfs2stat
-LDFLAGS+= -lutils -lsensor_range -llog -lscanmatcher -lsensor_base -lsensor_odometry $(GSL_LIB)
-CPPFLAGS+=-I../sensor $(GSL_INCLUDE)
+#LDFLAGS+= -lutils -lsensor_range -llog -lscanmatcher -lsensor_base -lsensor_odometry $(GSL_LIB)
+LDFLAGS+= -lutils -lsensor_range -llog -lscanmatcher -lsensor_base -lsensor_odometry
+#CPPFLAGS+=-I../sensor $(GSL_INCLUDE)
+CPPFLAGS+=-I../sensor
-include ../global.mk
-include ../build_tools/Makefile.generic-shared-object
Modified: pkg/trunk/gmapping/gridfastslam/gridslamprocessor_tree.cpp
===================================================================
--- pkg/trunk/gmapping/gridfastslam/gridslamprocessor_tree.cpp 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/gridfastslam/gridslamprocessor_tree.cpp 2008-04-18 00:50:56 UTC (rev 127)
@@ -4,7 +4,7 @@
#include <map>
#include <set>
#include <fstream>
-#include <gsl/gsl_blas.h>
+//#include <gsl/gsl_blas.h>
#include <utils/stat.h>
#include "gridslamprocessor.h"
Modified: pkg/trunk/gmapping/gui/Makefile
===================================================================
--- pkg/trunk/gmapping/gui/Makefile 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/gui/Makefile 2008-04-18 00:50:56 UTC (rev 127)
@@ -9,6 +9,11 @@
LDFLAGS+= -lcarmenwrapper
endif
+ifeq ($(PLAYERSUPPORT),1)
+CPPFLAGS+= `pkg-config --cflags playercore`
+LDFLAGS+= -lplayerwrapper `pkg-config --libs playerxdr playercore`
+endif
+
CPPFLAGS+= -I../sensor $(QT_INCLUDE) $(KDE_INCLUDE) -I$(CARMEN_HOME)/include
Modified: pkg/trunk/gmapping/gui/gfs2img.cpp
===================================================================
--- pkg/trunk/gmapping/gui/gfs2img.cpp 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/gui/gfs2img.cpp 2008-04-18 00:50:56 UTC (rev 127)
@@ -203,6 +203,7 @@
}
}
+ /*
cout << "painting trajectories" << endl;
for (int p=0; p<particles; p++){
painter.setPen(QColor(Qt::red));
@@ -240,6 +241,7 @@
}
}
paths[bestIdx].destroyReferences();;
+ */
cout << " DONE" << endl;
cout << "writing image" << endl;
QImage img=pixmap.convertToImage();
Modified: pkg/trunk/gmapping/gui/gsp_thread.cpp
===================================================================
--- pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-18 00:50:56 UTC (rev 127)
@@ -20,6 +20,9 @@
*
*****************************************************************/
+#ifdef PLAYER_SUPPORT
+ #include <playerwrapper/playergfswrapper.h>
+#endif
#include "gsp_thread.h"
#include <utils/commandline.h>
@@ -45,7 +48,7 @@
CMD_PARSE_END_SILENT;
if (configfilename.length()>0){
- ConfigFile cfg(configfilename);
+ GMapping::ConfigFile cfg(configfilename);
filename = (std::string) cfg.value("gfs","filename",filename);
outfilename = (std::string) cfg.value("gfs","outfilename",outfilename);
@@ -281,8 +284,9 @@
//if started online retrieve the settings from the connection
+ if (gpt->onLine)
+ {
#ifdef CARMEN_SUPPORT
- if (gpt->onLine){
cout << "starting the process:" << endl;
CarmenWrapper::initializeIPC(gpt->m_argv[0]);
CarmenWrapper::start(gpt->m_argv[0]);
@@ -293,15 +297,25 @@
}
gpt->sensorMap=CarmenWrapper::sensorMap();
cout << "Connected " << endl;
- }
#else
- if (gpt->onLine){
+ #ifdef PLAYER_SUPPORT
+ cout << "Waiting for retrieving the sensor map:" << endl;
+ while (!gpt->m_pwrapper->sensorMapComputed()){
+ usleep(100000);
+ cout << "." << flush;
+ }
+ gpt->sensorMap=gpt->m_pwrapper->getSensorMap();
+ cout << "Connected " << endl;
+
+ #else
+
cout << "FATAL ERROR: cannot run online without the carmen support" << endl;
DoneEvent *done=new DoneEvent;
gpt->addEvent(done);
return 0;
+ #endif // PLAYER_SUPPORT
+#endif // CARMEN_SUPPORT
}
-#endif
gpt->setSensorMap(gpt->sensorMap);
gpt->setMatchingParameters(gpt->maxUrange, gpt->maxrange, gpt->sigma, gpt->kernelSize, gpt->lstep, gpt->astep, gpt->iterations, gpt->lsigma, gpt->ogain, gpt->lskip);
@@ -412,6 +426,21 @@
}
}
}
+#else
+ #ifdef PLAYER_SUPPORT
+ if (gpt->onLine){
+ while (1){
+ RangeReading* nr;
+ while((nr = gpt->m_pwrapper->getReading()))
+ {
+ gpt->processScan(*nr);
+ delete nr;
+ }
+ usleep(1000);
+ pthread_testcancel();
+ }
+ }
+ #endif
#endif
ofstream rawpath("rawpath.dat");
if (!gpt->onLine){
@@ -504,11 +533,14 @@
pthread_create(&gfs_thread, 0, (void * (*)(void *))fastslamthread, (void *) this);
}
+#ifdef PLAYER_SUPPORT
void GridSlamProcessorThread::start(PlayerGFSWrapper* pwrapper)
{
m_pwrapper = pwrapper;
+ onLine = true;
start();
}
+#endif
void GridSlamProcessorThread::stop(){
if (! running){
@@ -517,6 +549,7 @@
}
running=false;
void * retval;
+ pthread_cancel(gfs_thread);
pthread_join(gfs_thread, &retval);
}
Modified: pkg/trunk/gmapping/gui/gsp_thread.h
===================================================================
--- pkg/trunk/gmapping/gui/gsp_thread.h 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/gui/gsp_thread.h 2008-04-18 00:50:56 UTC (rev 127)
@@ -33,15 +33,14 @@
#include <log/sensorstream.h>
#include <gridfastslam/gridslamprocessor.h>
-using namespace std;
-using namespace GMapping;
-
#ifdef PLAYER_SUPPORT
-namespace GMapping {
class PlayerGFSWrapper;
-}
#endif
+using namespace std;
+using namespace GMapping;
+
+
#define MAX_STRING_LENGTH 1024
Modified: pkg/trunk/gmapping/manual.mk
===================================================================
--- pkg/trunk/gmapping/manual.mk 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/manual.mk 2008-04-18 00:50:56 UTC (rev 127)
@@ -1,6 +1,6 @@
#CPPFLAGS+= -DNDEBUG
-CXXFLAGS+= -O3 -Wall -ffast-math
-#CXXFLAGS+= -g -O0 -Wall
+#CXXFLAGS+= -O3 -Wall -ffast-math
+CXXFLAGS+= -g -O0 -Wall
PROFILE= false
Modified: pkg/trunk/gmapping/playerwrapper/Makefile
===================================================================
--- pkg/trunk/gmapping/playerwrapper/Makefile 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/playerwrapper/Makefile 2008-04-18 00:50:56 UTC (rev 127)
@@ -1,11 +1,12 @@
-OBJS= playergfswrapper.o
+OBJS= ../gui/gsp_thread.o ../gui/qparticleviewer.o ../gui/qgraphpainter.o ../gui/qmappainter.o playergfswrapper.o
APPS=
-#LIBS+= -L$(CARMEN_HOME)/lib -lnavigator_interface -lsimulator_interface -lrobot_interface -llaser_interface -lparam_interface -lglobal -lipc -lm -lutils -lsensor_range -llog -lscanmatcher -lpthread -lz
-LIBS+= `pkg-config --libs playercore` -lsensor_range
-#-L$(CARMEN_HOME)/lib -lnavigator_interface -lsimulator_interface -lrobot_interface -llaser_interface -lparam_interface -lglobal -lipc -lm -lutils -lsensor_range -llog -lscanmatcher -lpthread -lz
-CPPFLAGS+=-I../sensor `pkg-config --cflags playercore`
+LIBS+= `pkg-config --libs playercore playerxdr` -lsensor_range -lgridfastslam
+CPPFLAGS+=-Wall -I../sensor `pkg-config --cflags playercore`
+LDFLAGS+=$(QT_LIB)
+CPPFLAGS+=$(QT_INCLUDE)
+
-include ../global.mk
ifeq ($(PLAYERSUPPORT), 0)
Added: pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg
===================================================================
--- pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg (rev 0)
+++ pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg 2008-04-18 00:50:56 UTC (rev 127)
@@ -0,0 +1,26 @@
+driver
+(
+ name "readlog"
+ filename "writelog_2008_04_17_13_15_20.log"
+ speed 1
+ provides ["log:0" "laser:0" "position2d:0"]
+ autoplay 1
+ alwayson 0
+)
+
+driver
+(
+ name "laserposeinterpolator"
+ requires ["laser:0" "position2d:0"]
+ provides ["laser:1"]
+)
+
+driver
+(
+ name "playergfswrapper"
+ plugin "libplayerwrapper"
+ requires [ "laser:1"]
+ provides ["position2d:1"]
+ alwayson 1
+)
+
Added: pkg/trunk/gmapping/playerwrapper/examples/writelog_2008_04_17_13_15_20.log.gz
===================================================================
(Binary files differ)
Property changes on: pkg/trunk/gmapping/playerwrapper/examples/writelog_2008_04_17_13_15_20.log.gz
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 00:50:56 UTC (rev 127)
@@ -22,11 +22,56 @@
*
*****************************************************************/
+#include <gui/qparticleviewer.h>
+#include <gui/qgraphpainter.h>
+#include <qapplication.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qvbox.h>
+#include <qmainwindow.h>
+
#include "playergfswrapper.h"
-using namespace GMapping;
+class GFSMainWindow: public QMainWindow{
+public:
+ GFSMainWindow(GridSlamProcessorThread* t){
+ gsp_thread=t;
+ QVBoxLayout* layout=new QVBoxLayout(this);
+ pviewer=new QParticleViewer(this,0,0,gsp_thread);
+ pviewer->setGeometry(0,0,500,500);
+ pviewer->setFocusPolicy(QParticleViewer::ClickFocus);
+ layout->addWidget(pviewer);
+
+ gpainter=new QGraphPainter(this);
+ gpainter->setFixedHeight(100);
+ layout->addWidget(gpainter);
+ gpainter->setRange(0,1);
+ gpainter->setTitle("Neff");
+
+ help = new QLabel(QString("+/- - zoom | b - show/hide best path | p - show/hide all paths | c - center robot "),this);
+ help->setMaximumHeight(30);
+ layout->addWidget(help);
+
+ QObject::connect( pviewer, SIGNAL(neffChanged(double) ), gpainter, SLOT(valueAdded(double)) );
+ setTabOrder(pviewer, pviewer);
+ }
+
+ void start(int c){
+ pviewer->start(c);
+ gpainter->start(c);
+ }
+protected:
+ GridSlamProcessorThread* gsp_thread;
+ QVBoxLayout* layout;
+ QParticleViewer* pviewer;
+ QGraphPainter* gpainter;
+ QLabel* help;
+};
+
+
PlayerGFSWrapper::PlayerGFSWrapper(ConfigFile* cf, int section)
: Driver(cf, section)
{
@@ -63,8 +108,32 @@
this->SetError(-1);
return;
}
+
+ this->laser_rs = NULL;
+ this->sensorMap_ready = false;
}
+void*
+GUI_thread(void* d)
+{
+ PlayerGFSWrapper* pd = (PlayerGFSWrapper*)d;
+ int argc;
+ char* argv[1];
+
+ argv[0] = "playergfswrapper";
+ argc=1;
+
+ QApplication app(argc,argv);
+ GFSMainWindow* mainWin=new GFSMainWindow(pd->gsp);
+ app.setMainWidget(mainWin);
+ mainWin->show();
+ //pd->gsp->setEventBufferSize(10000);
+ pd->gsp->start(pd);
+ mainWin->start(1000);
+ app.exec();
+ return(NULL);
+}
+
int
PlayerGFSWrapper::Setup()
{
@@ -86,12 +155,15 @@
this->gsp = new GridSlamProcessorThread();
- // TODO: create this->laser_rs
+ if(this->laser_rs)
+ {
+ delete this->laser_rs;
+ this->laser_rs = NULL;
+ }
- // TODO: compute GFS "sensorMap"
-
// start GFS thread
- this->gsp->start(this);
+ //this->gsp->start(this);
+ pthread_create(&this->gui_thread, 0, GUI_thread, this);
this->StartThread();
return(0);
@@ -119,24 +191,29 @@
{
for(;;)
{
+ pthread_testcancel();
+
+ this->InQueue->Wait();
+
this->ProcessMessages();
// TODO: check for new pose / map from GFS thread
}
}
-bool
-PlayerGFSWrapper::getReading(RangeReading& reading)
+GMapping::RangeReading*
+PlayerGFSWrapper::getReading()
{
- bool ret=false;
+ GMapping::RangeReading* ret = NULL;
pthread_mutex_lock(&this->rangeDeque_mutex);
if(!this->rangeDeque.empty())
{
- reading=this->rangeDeque.front();
+ ret=this->rangeDeque.front();
this->rangeDeque.pop_front();
- ret=true;
}
pthread_mutex_unlock(&this->rangeDeque_mutex);
+ if(ret)
+ puts("returned a reading");
return(ret);
}
@@ -165,14 +242,58 @@
PlayerGFSWrapper::ProcessLaser(player_msghdr_t* hdr,
player_laser_data_scanpose_t* data)
{
- RangeReading reading(this->laser_rs,hdr->timestamp);
+ if(!this->laser_rs)
+ {
+ // create this->laser_rs
+ std::string lasername = "FLASER";
+ this->laser_rs =
+ new GMapping::RangeSensor(lasername,
+ data->scan.ranges_count,
+ data->scan.resolution,
+ //OrientedPoint(0,0,laser_pose.pa-robot_pose.theta),
+ GMapping::OrientedPoint(0,0,-data->pose.pa),
+ 0, data->scan.max_range);
+ this->laser_rs->updateBeamsLookup();
+ this->sensorMap.insert(make_pair(lasername, this->laser_rs));
+ this->sensorMap_ready = true;
+ }
+
+ GMapping::RangeReading* reading = new GMapping::RangeReading(this->laser_rs,hdr->timestamp);
+ reading->resize(data->scan.ranges_count);
for(unsigned int i=0;i<data->scan.ranges_count;i++)
- reading[i] = data->scan.ranges[i];
- reading.setPose(OrientedPoint(data->pose.px,
+ (*reading)[i] = data->scan.ranges[i];
+ reading->setPose(GMapping::OrientedPoint(data->pose.px,
data->pose.py,
data->pose.pa));
pthread_mutex_lock(&this->rangeDeque_mutex);
this->rangeDeque.push_back(reading);
+ printf("queue size: %d\n", this->rangeDeque.size());
pthread_mutex_unlock(&this->rangeDeque_mutex);
}
+
+////////////////////////////////////////////////////////////////////////////////
+// Extra stuff for building a shared object.
+
+// A factory creation function, declared outside of the class so that it
+// can be invoked without any object context (alternatively, you can
+// declare it static in the class). In this function, we create and return
+// (as a generic Driver*) a pointer to a new instance of this driver.
+Driver*
+PlayerGFSWrapper_Init(ConfigFile* cf, int section)
+{
+ // Create and return a new instance of this driver
+ return((Driver*)(new PlayerGFSWrapper(cf, section)));
+}
+
+/* need the extern to avoid C++ name-mangling */
+extern "C" {
+ int player_driver_init(DriverTable* table)
+ {
+ puts("PlayerGFSWrapper driver initializing");
+ table->AddDriver("playergfswrapper", PlayerGFSWrapper_Init);
+ puts("PlayerGFSWrapper driver done");
+ return(0);
+ }
+}
+
Modified: pkg/trunk/gmapping/playerwrapper/playergfswrapper.h
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.h 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.h 2008-04-18 00:50:56 UTC (rev 127)
@@ -26,26 +26,15 @@
#ifndef PLAYERWRAPPER_H
#define PLAYERWRAPPER_H
-//#include <iostream>
#include <deque>
#include <pthread.h>
-//#include <semaphore.h>
-//#include <carmen/carmen.h>
-//#include <carmen/global.h>
-//#include <log/carmenconfiguration.h>
-
-#include <libplayercore/playercore.h>
-
#include <gui/gsp_thread.h>
-//#include <sensor/sensor_base/sensor.h>
-//#include <log/sensorstream.h>
-//#include <log/sensorlog.h>
#include <sensor/sensor_range/rangesensor.h>
#include <sensor/sensor_range/rangereading.h>
-namespace GMapping {
+#include <libplayercore/playercore.h>
class PlayerGFSWrapper : public Driver
{
@@ -60,18 +49,20 @@
// Devices to which we subscribe
player_devaddr_t laser_id;
Device* laser;
- RangeSensor* laser_rs;
+ GMapping::RangeSensor* laser_rs;
- // The GFS object
- GridSlamProcessorThread* gsp;
+ GMapping::SensorMap sensorMap;
+ bool sensorMap_ready;
// Queue of range readings, with mutex
- std::deque<RangeReading> rangeDeque;
+ std::deque<RangeReading*> rangeDeque;
pthread_mutex_t rangeDeque_mutex;
void ProcessLaser(player_msghdr_t* hdr,
player_laser_data_scanpose_t* data);
+ pthread_t gui_thread;
+
public:
PlayerGFSWrapper(ConfigFile* cf, int section);
virtual int Setup();
@@ -80,72 +71,14 @@
player_msghdr * hdr,
void * data);
- bool getReading(RangeReading& reading);
-
- /*
- void initializeIPC(const char* name);
- bool start(const char* name);
- bool isRunning();
- void lock();
- void unlock();
- int registerLocalizationMessages();
-
- int queueLength();
- OrientedPoint getTruePos();
- bool getReading(RangeReading& reading);
- void addReading(RangeReading& reading);
- const SensorMap& sensorMap();
- bool sensorMapComputed();
- bool isStopped();
-
- // conversion function
- carmen_robot_laser_message reading2carmen(const RangeReading& reading);
- RangeReading carmen2reading(const carmen_robot_laser_message& msg);
- carmen_point_t point2carmen (const OrientedPoint& p);
- OrientedPoint carmen2point (const carmen_point_t& p);
-
-
- // carmen interaction
- void robot_frontlaser_handler(carmen_robot_laser_message* frontlaser);
- void robot_rearlaser_handler(carmen_robot_laser_message* frontlaser);
- void simulator_truepos_handler(carmen_simulator_truepos_message* truepos);
- //babsi:
- void navigator_go_handler(MSG_INSTANCE msgRef, BYTE_ARRAY callData, void*) ;
- void navigator_stop_handler(MSG_INSTANCE msgRef, BYTE_ARRAY callData, void*) ;
-
- //babsi:
- void publish_globalpos(carmen_localize_summary_p summary);
- void publish_particles(carmen_localize_particle_filter_p filter,
- carmen_localize_summary_p summary);
-
- void shutdown_module(int sig);
-
- private:
- std::deque<RangeReading> m_rangeDeque;
- sem_t m_dequeSem;
- pthread_mutex_t m_mutex, m_lock;
- pthread_t m_readingThread;
- void * m_reading_function(void*);
- bool m_threadRunning;
- SensorMap m_sensorMap;
- RangeSensor* m_frontLaser, *m_rearLaser;
- OrientedPoint m_truepos;
- bool stopped;
- */
+ // Interface used by the GFS thread
+ GMapping::RangeReading* getReading();
+ bool sensorMapComputed() { return(this->sensorMap_ready); }
+ const SensorMap& getSensorMap() { return(this->sensorMap); }
+
+ // The GFS object (public so that it can be accessed from the GUI
+ // thread)
+ GridSlamProcessorThread* gsp;
};
-} //end namespace
-
-
-
#endif
-/*
-int main (int argc, char** argv) {
-
- CarmenWrapper::init_carmen(argc, argv);
- while (true) {
- IPC_listenWait(100);
- }
- return 1;
-}
-*/
Modified: pkg/trunk/gmapping/scanmatcher/Makefile
===================================================================
--- pkg/trunk/gmapping/scanmatcher/Makefile 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/scanmatcher/Makefile 2008-04-18 00:50:56 UTC (rev 127)
@@ -1,8 +1,10 @@
-OBJS= smmap.o scanmatcher.o scanmatcherprocessor.o
+OBJS= smmap.o scanmatcher.o scanmatcherprocessor.o eig3.o
APPS= scanmatch_test icptest
-LDFLAGS+= $(GSL_LIB) -lutils -lsensor_range -llog
-CPPFLAGS+=-I../sensor $(GSL_INCLUDE)
+#LDFLAGS+= $(GSL_LIB) -lutils -lsensor_range -llog
+LDFLAGS+= -lutils -lsensor_range -llog
+#CPPFLAGS+=-I../sensor $(GSL_INCLUDE)
+CPPFLAGS+=-I../sensor
-include ../global.mk
-include ../build_tools/Makefile.generic-shared-object
Added: pkg/trunk/gmapping/scanmatcher/eig3.c
===================================================================
--- pkg/trunk/gmapping/scanmatcher/eig3.c (rev 0)
+++ pkg/trunk/gmapping/scanmatcher/eig3.c 2008-04-18 00:50:56 UTC (rev 127)
@@ -0,0 +1,271 @@
+
+/* Eigen decomposition code for symmetric 3x3 matrices, copied from the public
+ domain Java Matrix library JAMA. */
+
+#include <math.h>
+
+#ifndef MAX
+#define MAX(a, b) ((a)>(b)?(a):(b))
+#endif
+
+//#define n 3
+static int n = 3;
+
+static double hypot2(double x, double y) {
+ return sqrt(x*x+y*y);
+}
+
+// Symmetric Householder reduction to tridiagonal form.
+
+static void tred2(double V[n][n], double d[n], double e[n]) {
+
+// This is derived from the Algol procedures tred2 by
+// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
+// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
+// Fortran subroutine in EISPACK.
+
+ int i,j,k;
+ double f,g,h,hh;
+ for (j = 0; j < n; j++) {
+ d[j] = V[n-1][j];
+ }
+
+ // Householder reduction to tridiagonal form.
+
+ for (i = n-1; i > 0; i--) {
+
+ // Scale to avoid under/overflow.
+
+ double scale = 0.0;
+ double h = 0.0;
+ for (k = 0; k < i; k++) {
+ scale = scale + fabs(d[k]);
+ }
+ if (scale == 0.0) {
+ e[i] = d[i-1];
+ for (j = 0; j < i; j++) {
+ d[j] = V[i-1][j];
+ V[i][j] = 0.0;
+ V[j][i] = 0.0;
+ }
+ } else {
+
+ // Generate Householder vector.
+
+ for (k = 0; k < i; k++) {
+ d[k] /= scale;
+ h += d[k] * d[k];
+ }
+ f = d[i-1];
+ g = sqrt(h);
+ if (f > 0) {
+ g = -g;
+ }
+ e[i] = scale * g;
+ h = h - f * g;
+ d[i-1] = f - g;
+ for (j = 0; j < i; j++) {
+ e[j] = 0.0;
+ }
+
+ // Apply similarity transformation to remaining columns.
+
+ for (j = 0; j < i; j++) {
+ f = d[j];
+ V[j][i] = f;
+ g = e[j] + V[j][j] * f;
+ for (k = j+1; k <= i-1; k++) {
+ g += V[k][j] * d[k];
+ e[k] += V[k][j] * f;
+ }
+ e[j] = g;
+ }
+ f = 0.0;
+ for (j = 0; j < i; j++) {
+ e[j] /= h;
+ f += e[j] * d[j];
+ }
+ hh = f / (h + h);
+ for (j = 0; j < i; j++) {
+ e[j] -= hh * d[j];
+ }
+ for (j = 0; j < i; j++) {
+ f = d[j];
+ g = e[j];
+ for (k = j; k <= i-1; k++) {
+ V[k][j] -= (f * e[k] + g * d[k]);
+ }
+ d[j] = V[i-1][j];
+ V[i][j] = 0.0;
+ }
+ }
+ d[i] = h;
+ }
+
+ // Accumulate transformations.
+
+ for (i = 0; i < n-1; i++) {
+ V[n-1][i] = V[i][i];
+ V[i][i] = 1.0;
+ h = d[i+1];
+ if (h != 0.0) {
+ for (k = 0; k <= i; k++) {
+ d[k] = V[k][i+1] / h;
+ }
+ for (j = 0; j <= i; j++) {
+ g = 0.0;
+ for (k = 0; k <= i; k++) {
+ g += V[k][i+1] * V[k][j];
+ }
+ for (k = 0; k <= i; k++) {
+ V[k][j] -= g * d[k];
+ }
+ }
+ }
+ for (k = 0; k <= i; k++) {
+ V[k][i+1] = 0.0;
+ }
+ }
+ for (j = 0; j < n; j++) {
+ d[j] = V[n-1][j];
+ V[n-1][j] = 0.0;
+ }
+ V[n-1][n-1] = 1.0;
+ e[0] = 0.0;
+}
+
+// Symmetric tridiagonal QL algorithm.
+
+static void tql2(double V[n][n], double d[n], double e[n]) {
+
+// This is derived from the Algol procedures tql2, by
+// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
+// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
+// Fortran subroutine in EISPACK.
+
+ int i,j,m,l,k;
+ double g,p,r,dl1,h,f,tst1,eps;
+ double c,c2,c3,el1,s,s2;
+
+ for (i = 1; i < n; i++) {
+ e[i-1] = e[i];
+ }
+ e[n-1] = 0.0;
+
+ f = 0.0;
+ tst1 = 0.0;
+ eps = pow(2.0,-52.0);
+ for (l = 0; l < n; l++) {
+
+ // Find small subdiagonal element
+
+ tst1 = MAX(tst1,fabs(d[l]) + fabs(e[l]));
+ m = l;
+ while (m < n) {
+ if (fabs(e[m]) <= eps*tst1) {
+ break;
+ }
+ m++;
+ }
+
+ // If m == l, d[l] is an eigenvalue,
+ // otherwise, iterate.
+
+ if (m > l) {
+ int iter = 0;
+ do {
+ iter = iter + 1; // (Could check iteration count here.)
+
+ // Compute implicit shift
+
+ g = d[l];
+ p = (d[l+1] - g) / (2.0 * e[l]);
+ r = hypot2(p,1.0);
+ if (p < 0) {
+ r = -r;
+ }
+ d[l] = e[l] / (p + r);
+ d[l+1] = e[l] * (p + r);
+ dl1 = d[l+1];
+ h = g - d[l];
+ for (i = l+2; i < n; i++) {
+ d[i] -= h;
+ }
+ f = f + h;
+
+ // Implicit QL transformation.
+
+ p = d[m];
+ c = 1.0;
+ c2 = c;
+ c3 = c;
+ el1 = e[l+1];
+ s = 0.0;
+ s2 = 0.0;
+ for (i = m-1; i >= l; i--) {
+ c3 = c2;
+ c2 = c;
+ s2 = s;
+ g = c * e[i];
+ h = c * p;
+ r = hypot2(p,e[i]);
+ e[i+1] = s * r;
+ s = e[i] / r;
+ c = p / r;
+ p = c * d[i] - s * g;
+ d[i+1] = h + s * (c * g + s * d[i]);
+
+ // Accumulate transformation.
+
+ for (k = 0; k < n; k++) {
+ h = V[k][i+1];
+ V[k][i+1] = s * V[k][i] + c * h;
+ V[k][i] = c * V[k][i] - s * h;
+ }
+ }
+ p = -s * s2 * c3 * el1 * e[l] / dl1;
+ e[l] = s * p;
+ d[l] = c * p;
+
+ // Check for convergence.
+
+ } while (fabs(e[l]) > eps*tst1);
+ }
+ d[l] = d[l] + f;
+ e[l] = 0.0;
+ }
+
+ // Sort eigenvalues and corresponding vectors.
+
+ for (i = 0; i < n-1; i++) {
+ k = i;
+ p = d[i];
+ for (j = i+1; j < n; j++) {
+ if (d[j] < p) {
+ k = j;
+ p = d[j];
+ }
+ }
+ if (k != i) {
+ d[k] = d[i];
+ d[i] = p;
+ for (j = 0; j < n; j++) {
+ p = V[j][i];
+ V[j][i] = V[j][k];
+ V[j][k] = p;
+ }
+ }
+ }
+}
+
+void eigen_decomposition(double A[n][n], double V[n][n], double d[n]) {
+ int i,j;
+ double e[n];
+ for (i = 0; i < n; i++) {
+ for (j = 0; j < n; j++) {
+ V[i][j] = A[i][j];
+ }
+ }
+ tred2(V, d, e);
+ tql2(V, d, e);
+}
Added: pkg/trunk/gmapping/scanmatcher/eig3.h
===================================================================
--- pkg/trunk/gmapping/scanmatcher/eig3.h (rev 0)
+++ pkg/trunk/gmapping/scanmatcher/eig3.h 2008-04-18 00:50:56 UTC (rev 127)
@@ -0,0 +1,19 @@
+
+/* Eigen-decomposition for symmetric 3x3 real matrices.
+ Public domain, copied from the public domain Java library JAMA. */
+
+#ifndef _eig_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Symmetric matrix A => eigenvectors in columns of V, corresponding
+ eigenvalues in d. */
+void eigen_decomposition(double A[3][3], double V[3][3], double d[3]);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Modified: pkg/trunk/gmapping/scanmatcher/scanmatcherprocessor.cpp
===================================================================
--- pkg/trunk/gmapping/scanmatcher/scanmatcherprocessor.cpp 2008-04-18 00:35:41 UTC (rev 126)
+++ pkg/trunk/gmapping/scanmatcher/scanmatcherprocessor.cpp 2008-04-18 00:50:56 UTC (rev 127)
@@ -1,5 +1,6 @@
#include <iostream>
#include "scanmatcherprocessor.h"
+#include "eig3.h"
//#define SCANMATHCERPROCESSOR_DEBUG
namespace GMapping {
@@ -14,7 +15,7 @@
m_maxMove=1;
m_beams=0;
m_computeCovariance=false;
- m_eigenspace=gsl_eigen_symmv_alloc(3);
+ //m_eigenspace=gsl_eigen_symmv_alloc(3);
useICP=false;
}
@@ -27,12 +28,12 @@
m_maxMove=1;
m_beams=0;
m_computeCovariance=false;
- m_eigenspace=gsl_eigen_symmv_alloc(3);
+ //m_eigenspace=gsl_eigen_symmv_alloc(3);
useICP=false;
}
ScanMatcherProcessor::~ScanMatcherProcessor (){
- gsl_eigen_symmv_free(m_eigenspace);
+ //gsl_eigen_symmv_free(m_eigenspace);
}
@@ -143,19 +144,36 @@
if(m_computeCovariance){
ScanMatcher::CovarianceMatrix cov;
score=m_matcher.optimize(newPose, cov, m_map, m_pose, plainReading);
+ /*
gsl_matrix* m=gsl_matrix_alloc(3,3);
gsl_matrix_set(m,0,0,cov.xx); gsl_matrix_set(m,0,1,cov.xy); gsl_matrix_set(m,0,2,cov.xt);
gsl_matrix_set(m,1,0,co...
[truncated message content] |
|
From: <ge...@us...> - 2008-04-18 01:22:01
|
Revision: 129
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=129&view=rev
Author: gerkey
Date: 2008-04-17 18:22:06 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
fixed OSX build problems
Modified Paths:
--------------
pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object
pkg/trunk/gmapping/gui/Makefile
pkg/trunk/gmapping/log/carmenconfiguration.cpp
pkg/trunk/gmapping/log/log_plot.cpp
pkg/trunk/gmapping/particlefilter/particlefilter.h
pkg/trunk/gmapping/playerwrapper/Makefile
pkg/trunk/gmapping/scanmatcher/Makefile
pkg/trunk/gmapping/scanmatcher/eig3.h
pkg/trunk/gmapping/sensor/sensor_range/rangereading.cpp
Added Paths:
-----------
pkg/trunk/gmapping/scanmatcher/eig3.cpp
Removed Paths:
-------------
pkg/trunk/gmapping/scanmatcher/eig3.c
Modified: pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object
===================================================================
--- pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object 2008-04-18 01:22:06 UTC (rev 129)
@@ -32,7 +32,7 @@
$(SONAME): $(OBJS) $(COBJS)
@$(MESSAGE) "Creating library lib$(LIBNAME).so"
ifeq ($(MACOSX),1)
- @$(PRETTY) "$(CXX) $(LDFLAGS) -dynamiclib $(OBJS) $(COBJS) -L$(LIBDIR) $(LIBS) -install_name $@ -o $@"
+ @$(PRETTY) "$(CXX) $(LDFLAGS) -dynamiclib $(OBJS) $(COBJS) -L$(LIBDIR) $(LIBS) -install_name $@ -o $@"
endif
ifeq ($(LINUX),1)
@$(PRETTY) "$(CXX) $(LDFLAGS) -fPIC -shared $(OBJS) $(COBJS) -L $(LIBDIR) $(LIBS) -o $@"
Modified: pkg/trunk/gmapping/gui/Makefile
===================================================================
--- pkg/trunk/gmapping/gui/Makefile 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/gui/Makefile 2008-04-18 01:22:06 UTC (rev 129)
@@ -3,7 +3,7 @@
OBJS= gsp_thread.o qparticleviewer.o qgraphpainter.o qmappainter.o
APPS= gfs_nogui gfs_simplegui gfs2img
-LDFLAGS+= $(QT_LIB) $(KDE_LIB) -lutils -lsensor_range -llog -lgridfastslam -lpthread -lconfigfile
+LDFLAGS+= $(QT_LIB) $(KDE_LIB) -lutils -lsensor_range -llog -lgridfastslam -lpthread -lconfigfile -lsensor_base -lscanmatcher
ifeq ($(CARMENSUPPORT),1)
LDFLAGS+= -lcarmenwrapper
Modified: pkg/trunk/gmapping/log/carmenconfiguration.cpp
===================================================================
--- pkg/trunk/gmapping/log/carmenconfiguration.cpp 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/log/carmenconfiguration.cpp 2008-04-18 01:22:06 UTC (rev 129)
@@ -2,6 +2,7 @@
#include <iostream>
#include <sstream>
#include <assert.h>
+#include <sys/types.h>
#include <sensor_odometry/odometrysensor.h>
#include <sensor_range/rangesensor.h>
Modified: pkg/trunk/gmapping/log/log_plot.cpp
===================================================================
--- pkg/trunk/gmapping/log/log_plot.cpp 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/log/log_plot.cpp 2008-04-18 01:22:06 UTC (rev 129)
@@ -1,5 +1,6 @@
#include <fstream>
#include <iostream>
+#include <sys/types.h>
#include <log/carmenconfiguration.h>
#include <log/sensorlog.h>
Modified: pkg/trunk/gmapping/particlefilter/particlefilter.h
===================================================================
--- pkg/trunk/gmapping/particlefilter/particlefilter.h 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/particlefilter/particlefilter.h 2008-04-18 01:22:06 UTC (rev 129)
@@ -1,6 +1,7 @@
#ifndef PARTICLEFILTER_H
#define PARTICLEFILTER_H
#include <stdlib.h>
+#include <sys/types.h>
#include<vector>
#include<utility>
#include<cmath>
Modified: pkg/trunk/gmapping/playerwrapper/Makefile
===================================================================
--- pkg/trunk/gmapping/playerwrapper/Makefile 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/playerwrapper/Makefile 2008-04-18 01:22:06 UTC (rev 129)
@@ -1,7 +1,7 @@
OBJS= ../gui/gsp_thread.o ../gui/qparticleviewer.o ../gui/qgraphpainter.o ../gui/qmappainter.o playergfswrapper.o
APPS=
-LIBS+= `pkg-config --libs playercore playerxdr` -lsensor_range -lgridfastslam
+LIBS+= `pkg-config --libs playercore playerxdr` -lsensor_range -lgridfastslam -llog -lutils -lconfigfile -lsensor_base
CPPFLAGS+=-Wall -I../sensor `pkg-config --cflags playercore`
LDFLAGS+=$(QT_LIB)
Modified: pkg/trunk/gmapping/scanmatcher/Makefile
===================================================================
--- pkg/trunk/gmapping/scanmatcher/Makefile 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/scanmatcher/Makefile 2008-04-18 01:22:06 UTC (rev 129)
@@ -2,7 +2,7 @@
APPS= scanmatch_test icptest
#LDFLAGS+= $(GSL_LIB) -lutils -lsensor_range -llog
-LDFLAGS+= -lutils -lsensor_range -llog
+LDFLAGS+= -lutils -lsensor_range -lsensor_base -llog
#CPPFLAGS+=-I../sensor $(GSL_INCLUDE)
CPPFLAGS+=-I../sensor
Deleted: pkg/trunk/gmapping/scanmatcher/eig3.c
===================================================================
--- pkg/trunk/gmapping/scanmatcher/eig3.c 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/scanmatcher/eig3.c 2008-04-18 01:22:06 UTC (rev 129)
@@ -1,271 +0,0 @@
-
-/* Eigen decomposition code for symmetric 3x3 matrices, copied from the public
- domain Java Matrix library JAMA. */
-
-#include <math.h>
-
-#ifndef MAX
-#define MAX(a, b) ((a)>(b)?(a):(b))
-#endif
-
-//#define n 3
-static int n = 3;
-
-static double hypot2(double x, double y) {
- return sqrt(x*x+y*y);
-}
-
-// Symmetric Householder reduction to tridiagonal form.
-
-static void tred2(double V[n][n], double d[n], double e[n]) {
-
-// This is derived from the Algol procedures tred2 by
-// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
-// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
-// Fortran subroutine in EISPACK.
-
- int i,j,k;
- double f,g,h,hh;
- for (j = 0; j < n; j++) {
- d[j] = V[n-1][j];
- }
-
- // Householder reduction to tridiagonal form.
-
- for (i = n-1; i > 0; i--) {
-
- // Scale to avoid under/overflow.
-
- double scale = 0.0;
- double h = 0.0;
- for (k = 0; k < i; k++) {
- scale = scale + fabs(d[k]);
- }
- if (scale == 0.0) {
- e[i] = d[i-1];
- for (j = 0; j < i; j++) {
- d[j] = V[i-1][j];
- V[i][j] = 0.0;
- V[j][i] = 0.0;
- }
- } else {
-
- // Generate Householder vector.
-
- for (k = 0; k < i; k++) {
- d[k] /= scale;
- h += d[k] * d[k];
- }
- f = d[i-1];
- g = sqrt(h);
- if (f > 0) {
- g = -g;
- }
- e[i] = scale * g;
- h = h - f * g;
- d[i-1] = f - g;
- for (j = 0; j < i; j++) {
- e[j] = 0.0;
- }
-
- // Apply similarity transformation to remaining columns.
-
- for (j = 0; j < i; j++) {
- f = d[j];
- V[j][i] = f;
- g = e[j] + V[j][j] * f;
- for (k = j+1; k <= i-1; k++) {
- g += V[k][j] * d[k];
- e[k] += V[k][j] * f;
- }
- e[j] = g;
- }
- f = 0.0;
- for (j = 0; j < i; j++) {
- e[j] /= h;
- f += e[j] * d[j];
- }
- hh = f / (h + h);
- for (j = 0; j < i; j++) {
- e[j] -= hh * d[j];
- }
- for (j = 0; j < i; j++) {
- f = d[j];
- g = e[j];
- for (k = j; k <= i-1; k++) {
- V[k][j] -= (f * e[k] + g * d[k]);
- }
- d[j] = V[i-1][j];
- V[i][j] = 0.0;
- }
- }
- d[i] = h;
- }
-
- // Accumulate transformations.
-
- for (i = 0; i < n-1; i++) {
- V[n-1][i] = V[i][i];
- V[i][i] = 1.0;
- h = d[i+1];
- if (h != 0.0) {
- for (k = 0; k <= i; k++) {
- d[k] = V[k][i+1] / h;
- }
- for (j = 0; j <= i; j++) {
- g = 0.0;
- for (k = 0; k <= i; k++) {
- g += V[k][i+1] * V[k][j];
- }
- for (k = 0; k <= i; k++) {
- V[k][j] -= g * d[k];
- }
- }
- }
- for (k = 0; k <= i; k++) {
- V[k][i+1] = 0.0;
- }
- }
- for (j = 0; j < n; j++) {
- d[j] = V[n-1][j];
- V[n-1][j] = 0.0;
- }
- V[n-1][n-1] = 1.0;
- e[0] = 0.0;
-}
-
-// Symmetric tridiagonal QL algorithm.
-
-static void tql2(double V[n][n], double d[n], double e[n]) {
-
-// This is derived from the Algol procedures tql2, by
-// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
-// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
-// Fortran subroutine in EISPACK.
-
- int i,j,m,l,k;
- double g,p,r,dl1,h,f,tst1,eps;
- double c,c2,c3,el1,s,s2;
-
- for (i = 1; i < n; i++) {
- e[i-1] = e[i];
- }
- e[n-1] = 0.0;
-
- f = 0.0;
- tst1 = 0.0;
- eps = pow(2.0,-52.0);
- for (l = 0; l < n; l++) {
-
- // Find small subdiagonal element
-
- tst1 = MAX(tst1,fabs(d[l]) + fabs(e[l]));
- m = l;
- while (m < n) {
- if (fabs(e[m]) <= eps*tst1) {
- break;
- }
- m++;
- }
-
- // If m == l, d[l] is an eigenvalue,
- // otherwise, iterate.
-
- if (m > l) {
- int iter = 0;
- do {
- iter = iter + 1; // (Could check iteration count here.)
-
- // Compute implicit shift
-
- g = d[l];
- p = (d[l+1] - g) / (2.0 * e[l]);
- r = hypot2(p,1.0);
- if (p < 0) {
- r = -r;
- }
- d[l] = e[l] / (p + r);
- d[l+1] = e[l] * (p + r);
- dl1 = d[l+1];
- h = g - d[l];
- for (i = l+2; i < n; i++) {
- d[i] -= h;
- }
- f = f + h;
-
- // Implicit QL transformation.
-
- p = d[m];
- c = 1.0;
- c2 = c;
- c3 = c;
- el1 = e[l+1];
- s = 0.0;
- s2 = 0.0;
- for (i = m-1; i >= l; i--) {
- c3 = c2;
- c2 = c;
- s2 = s;
- g = c * e[i];
- h = c * p;
- r = hypot2(p,e[i]);
- e[i+1] = s * r;
- s = e[i] / r;
- c = p / r;
- p = c * d[i] - s * g;
- d[i+1] = h + s * (c * g + s * d[i]);
-
- // Accumulate transformation.
-
- for (k = 0; k < n; k++) {
- h = V[k][i+1];
- V[k][i+1] = s * V[k][i] + c * h;
- V[k][i] = c * V[k][i] - s * h;
- }
- }
- p = -s * s2 * c3 * el1 * e[l] / dl1;
- e[l] = s * p;
- d[l] = c * p;
-
- // Check for convergence.
-
- } while (fabs(e[l]) > eps*tst1);
- }
- d[l] = d[l] + f;
- e[l] = 0.0;
- }
-
- // Sort eigenvalues and corresponding vectors.
-
- for (i = 0; i < n-1; i++) {
- k = i;
- p = d[i];
- for (j = i+1; j < n; j++) {
- if (d[j] < p) {
- k = j;
- p = d[j];
- }
- }
- if (k != i) {
- d[k] = d[i];
- d[i] = p;
- for (j = 0; j < n; j++) {
- p = V[j][i];
- V[j][i] = V[j][k];
- V[j][k] = p;
- }
- }
- }
-}
-
-void eigen_decomposition(double A[n][n], double V[n][n], double d[n]) {
- int i,j;
- double e[n];
- for (i = 0; i < n; i++) {
- for (j = 0; j < n; j++) {
- V[i][j] = A[i][j];
- }
- }
- tred2(V, d, e);
- tql2(V, d, e);
-}
Copied: pkg/trunk/gmapping/scanmatcher/eig3.cpp (from rev 127, pkg/trunk/gmapping/scanmatcher/eig3.c)
===================================================================
--- pkg/trunk/gmapping/scanmatcher/eig3.cpp (rev 0)
+++ pkg/trunk/gmapping/scanmatcher/eig3.cpp 2008-04-18 01:22:06 UTC (rev 129)
@@ -0,0 +1,270 @@
+
+/* Eigen decomposition code for symmetric 3x3 matrices, copied from the public
+ domain Java Matrix library JAMA. */
+
+#include <math.h>
+
+#ifndef MAX
+#define MAX(a, b) ((a)>(b)?(a):(b))
+#endif
+
+#define n 3
+
+static double hypot2(double x, double y) {
+ return sqrt(x*x+y*y);
+}
+
+// Symmetric Householder reduction to tridiagonal form.
+
+static void tred2(double V[n][n], double d[n], double e[n]) {
+
+// This is derived from the Algol procedures tred2 by
+// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
+// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
+// Fortran subroutine in EISPACK.
+
+ int i,j,k;
+ double f,g,h,hh;
+ for (j = 0; j < n; j++) {
+ d[j] = V[n-1][j];
+ }
+
+ // Householder reduction to tridiagonal form.
+
+ for (i = n-1; i > 0; i--) {
+
+ // Scale to avoid under/overflow.
+
+ double scale = 0.0;
+ double h = 0.0;
+ for (k = 0; k < i; k++) {
+ scale = scale + fabs(d[k]);
+ }
+ if (scale == 0.0) {
+ e[i] = d[i-1];
+ for (j = 0; j < i; j++) {
+ d[j] = V[i-1][j];
+ V[i][j] = 0.0;
+ V[j][i] = 0.0;
+ }
+ } else {
+
+ // Generate Householder vector.
+
+ for (k = 0; k < i; k++) {
+ d[k] /= scale;
+ h += d[k] * d[k];
+ }
+ f = d[i-1];
+ g = sqrt(h);
+ if (f > 0) {
+ g = -g;
+ }
+ e[i] = scale * g;
+ h = h - f * g;
+ d[i-1] = f - g;
+ for (j = 0; j < i; j++) {
+ e[j] = 0.0;
+ }
+
+ // Apply similarity transformation to remaining columns.
+
+ for (j = 0; j < i; j++) {
+ f = d[j];
+ V[j][i] = f;
+ g = e[j] + V[j][j] * f;
+ for (k = j+1; k <= i-1; k++) {
+ g += V[k][j] * d[k];
+ e[k] += V[k][j] * f;
+ }
+ e[j] = g;
+ }
+ f = 0.0;
+ for (j = 0; j < i; j++) {
+ e[j] /= h;
+ f += e[j] * d[j];
+ }
+ hh = f / (h + h);
+ for (j = 0; j < i; j++) {
+ e[j] -= hh * d[j];
+ }
+ for (j = 0; j < i; j++) {
+ f = d[j];
+ g = e[j];
+ for (k = j; k <= i-1; k++) {
+ V[k][j] -= (f * e[k] + g * d[k]);
+ }
+ d[j] = V[i-1][j];
+ V[i][j] = 0.0;
+ }
+ }
+ d[i] = h;
+ }
+
+ // Accumulate transformations.
+
+ for (i = 0; i < n-1; i++) {
+ V[n-1][i] = V[i][i];
+ V[i][i] = 1.0;
+ h = d[i+1];
+ if (h != 0.0) {
+ for (k = 0; k <= i; k++) {
+ d[k] = V[k][i+1] / h;
+ }
+ for (j = 0; j <= i; j++) {
+ g = 0.0;
+ for (k = 0; k <= i; k++) {
+ g += V[k][i+1] * V[k][j];
+ }
+ for (k = 0; k <= i; k++) {
+ V[k][j] -= g * d[k];
+ }
+ }
+ }
+ for (k = 0; k <= i; k++) {
+ V[k][i+1] = 0.0;
+ }
+ }
+ for (j = 0; j < n; j++) {
+ d[j] = V[n-1][j];
+ V[n-1][j] = 0.0;
+ }
+ V[n-1][n-1] = 1.0;
+ e[0] = 0.0;
+}
+
+// Symmetric tridiagonal QL algorithm.
+
+static void tql2(double V[n][n], double d[n], double e[n]) {
+
+// This is derived from the Algol procedures tql2, by
+// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
+// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
+// Fortran subroutine in EISPACK.
+
+ int i,j,m,l,k;
+ double g,p,r,dl1,h,f,tst1,eps;
+ double c,c2,c3,el1,s,s2;
+
+ for (i = 1; i < n; i++) {
+ e[i-1] = e[i];
+ }
+ e[n-1] = 0.0;
+
+ f = 0.0;
+ tst1 = 0.0;
+ eps = pow(2.0,-52.0);
+ for (l = 0; l < n; l++) {
+
+ // Find small subdiagonal element
+
+ tst1 = MAX(tst1,fabs(d[l]) + fabs(e[l]));
+ m = l;
+ while (m < n) {
+ if (fabs(e[m]) <= eps*tst1) {
+ break;
+ }
+ m++;
+ }
+
+ // If m == l, d[l] is an eigenvalue,
+ // otherwise, iterate.
+
+ if (m > l) {
+ int iter = 0;
+ do {
+ iter = iter + 1; // (Could check iteration count here.)
+
+ // Compute implicit shift
+
+ g = d[l];
+ p = (d[l+1] - g) / (2.0 * e[l]);
+ r = hypot2(p,1.0);
+ if (p < 0) {
+ r = -r;
+ }
+ d[l] = e[l] / (p + r);
+ d[l+1] = e[l] * (p + r);
+ dl1 = d[l+1];
+ h = g - d[l];
+ for (i = l+2; i < n; i++) {
+ d[i] -= h;
+ }
+ f = f + h;
+
+ // Implicit QL transformation.
+
+ p = d[m];
+ c = 1.0;
+ c2 = c;
+ c3 = c;
+ el1 = e[l+1];
+ s = 0.0;
+ s2 = 0.0;
+ for (i = m-1; i >= l; i--) {
+ c3 = c2;
+ c2 = c;
+ s2 = s;
+ g = c * e[i];
+ h = c * p;
+ r = hypot2(p,e[i]);
+ e[i+1] = s * r;
+ s = e[i] / r;
+ c = p / r;
+ p = c * d[i] - s * g;
+ d[i+1] = h + s * (c * g + s * d[i]);
+
+ // Accumulate transformation.
+
+ for (k = 0; k < n; k++) {
+ h = V[k][i+1];
+ V[k][i+1] = s * V[k][i] + c * h;
+ V[k][i] = c * V[k][i] - s * h;
+ }
+ }
+ p = -s * s2 * c3 * el1 * e[l] / dl1;
+ e[l] = s * p;
+ d[l] = c * p;
+
+ // Check for convergence.
+
+ } while (fabs(e[l]) > eps*tst1);
+ }
+ d[l] = d[l] + f;
+ e[l] = 0.0;
+ }
+
+ // Sort eigenvalues and corresponding vectors.
+
+ for (i = 0; i < n-1; i++) {
+ k = i;
+ p = d[i];
+ for (j = i+1; j < n; j++) {
+ if (d[j] < p) {
+ k = j;
+ p = d[j];
+ }
+ }
+ if (k != i) {
+ d[k] = d[i];
+ d[i] = p;
+ for (j = 0; j < n; j++) {
+ p = V[j][i];
+ V[j][i] = V[j][k];
+ V[j][k] = p;
+ }
+ }
+ }
+}
+
+void eigen_decomposition(double A[n][n], double V[n][n], double d[n]) {
+ int i,j;
+ double e[n];
+ for (i = 0; i < n; i++) {
+ for (j = 0; j < n; j++) {
+ V[i][j] = A[i][j];
+ }
+ }
+ tred2(V, d, e);
+ tql2(V, d, e);
+}
Modified: pkg/trunk/gmapping/scanmatcher/eig3.h
===================================================================
--- pkg/trunk/gmapping/scanmatcher/eig3.h 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/scanmatcher/eig3.h 2008-04-18 01:22:06 UTC (rev 129)
@@ -4,16 +4,8 @@
#ifndef _eig_h
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/* Symmetric matrix A => eigenvectors in columns of V, corresponding
eigenvalues in d. */
void eigen_decomposition(double A[3][3], double V[3][3], double d[3]);
-#ifdef __cplusplus
-}
#endif
-
-#endif
Modified: pkg/trunk/gmapping/sensor/sensor_range/rangereading.cpp
===================================================================
--- pkg/trunk/gmapping/sensor/sensor_range/rangereading.cpp 2008-04-18 01:13:41 UTC (rev 128)
+++ pkg/trunk/gmapping/sensor/sensor_range/rangereading.cpp 2008-04-18 01:22:06 UTC (rev 129)
@@ -1,5 +1,6 @@
#include <iostream>
#include <assert.h>
+#include <sys/types.h>
#include <utils/gvalues.h>
#include "rangereading.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-04-18 02:26:51
|
Revision: 134
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=134&view=rev
Author: gerkey
Date: 2008-04-17 19:26:32 -0700 (Thu, 17 Apr 2008)
Log Message:
-----------
added pthread condition variable logics to sync up mapper and driver thread
Modified Paths:
--------------
pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object
pkg/trunk/gmapping/gui/gsp_thread.cpp
pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg
pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
pkg/trunk/gmapping/playerwrapper/playergfswrapper.h
Modified: pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object
===================================================================
--- pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object 2008-04-18 02:26:07 UTC (rev 133)
+++ pkg/trunk/gmapping/build_tools/Makefile.generic-shared-object 2008-04-18 02:26:32 UTC (rev 134)
@@ -33,6 +33,7 @@
@$(MESSAGE) "Creating library lib$(LIBNAME).so"
ifeq ($(MACOSX),1)
@$(PRETTY) "$(CXX) $(LDFLAGS) -dynamiclib $(OBJS) $(COBJS) -L$(LIBDIR) $(LIBS) -install_name $@ -o $@"
+ ln -sf $@ $(LIBDIR)/lib$(LIBNAME).so
endif
ifeq ($(LINUX),1)
@$(PRETTY) "$(CXX) $(LDFLAGS) -fPIC -shared $(OBJS) $(COBJS) -L $(LIBDIR) $(LIBS) -o $@"
Modified: pkg/trunk/gmapping/gui/gsp_thread.cpp
===================================================================
--- pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-18 02:26:07 UTC (rev 133)
+++ pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-18 02:26:32 UTC (rev 134)
@@ -430,13 +430,22 @@
#ifdef PLAYER_SUPPORT
if (gpt->onLine){
while (1){
- RangeReading* nr;
- while((nr = gpt->m_pwrapper->getReading()))
- {
- gpt->processScan(*nr);
- delete nr;
+ // getReading() will block until data is available
+ RangeReading* nr = gpt->m_pwrapper->getReading();
+
+ gpt->processScan(*nr);
+ const OdometryReading* o=dynamic_cast<const OdometryReading*>(nr);
+ if (o && gpt->running){
+ gpt->processTruePos(*o);
+ TruePosEvent* truepos=new TruePosEvent;
+ truepos->pose=o->getPose();
}
- usleep(1000);
+
+ // Should we delete this reading, or does the mapper
+ // still need it?
+ //delete nr;
+
+ // Give ourselves a chance to be canceled.
pthread_testcancel();
}
}
Modified: pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg
===================================================================
--- pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg 2008-04-18 02:26:07 UTC (rev 133)
+++ pkg/trunk/gmapping/playerwrapper/examples/readlog.cfg 2008-04-18 02:26:32 UTC (rev 134)
@@ -13,12 +13,14 @@
name "laserposeinterpolator"
requires ["laser:0" "position2d:0"]
provides ["laser:1"]
+ update_thresh [0.5 10.0]
+ send_all_scans 0
)
driver
(
name "playergfswrapper"
- plugin "libplayerwrapper"
+ plugin "../../lib/libplayerwrapper"
requires [ "laser:1"]
provides ["position2d:1"]
alwayson 1
Modified: pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 02:26:07 UTC (rev 133)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 02:26:32 UTC (rev 134)
@@ -150,6 +150,8 @@
}
pthread_mutex_init(&this->rangeDeque_mutex, NULL);
+ pthread_cond_init(&this->rangeDeque_cond, NULL);
+ pthread_mutex_init(&this->rangeDeque_cond_mutex, NULL);
// TODO: get laser geometry
@@ -182,6 +184,8 @@
delete this->gsp;
pthread_mutex_destroy(&this->rangeDeque_mutex);
+ pthread_mutex_destroy(&this->rangeDeque_cond_mutex);
+ pthread_cond_destroy(&this->rangeDeque_cond);
return(0);
}
@@ -204,16 +208,31 @@
GMapping::RangeReading*
PlayerGFSWrapper::getReading()
{
- GMapping::RangeReading* ret = NULL;
+ // Do we need to wait?
+ bool needtowait;
pthread_mutex_lock(&this->rangeDeque_mutex);
- if(!this->rangeDeque.empty())
+ needtowait = this->rangeDeque.empty();
+ pthread_mutex_unlock(&this->rangeDeque_mutex);
+
+ if(needtowait)
{
- ret=this->rangeDeque.front();
- this->rangeDeque.pop_front();
+ pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock,
+ (void*)&this->rangeDeque_cond_mutex);
+ pthread_mutex_lock(&this->rangeDeque_cond_mutex);
+ pthread_cond_wait(&this->rangeDeque_cond,&this->rangeDeque_cond_mutex);
+ pthread_mutex_unlock(&this->rangeDeque_cond_mutex);
+ pthread_cleanup_pop(0);
}
+
+ // Now there must be data
+ pthread_mutex_lock(&this->rangeDeque_mutex);
+ assert(!this->rangeDeque.empty());
+
+ // remove the reading
+ GMapping::RangeReading* ret=this->rangeDeque.front();
+ this->rangeDeque.pop_front();
+
pthread_mutex_unlock(&this->rangeDeque_mutex);
- if(ret)
- puts("returned a reading");
return(ret);
}
@@ -268,6 +287,12 @@
pthread_mutex_lock(&this->rangeDeque_mutex);
this->rangeDeque.push_back(reading);
+
+ // Signal that data is available on the queue
+ pthread_mutex_lock(&this->rangeDeque_cond_mutex);
+ pthread_cond_broadcast(&this->rangeDeque_cond);
+ pthread_mutex_unlock(&this->rangeDeque_cond_mutex);
+
printf("queue size: %d\n", this->rangeDeque.size());
pthread_mutex_unlock(&this->rangeDeque_mutex);
}
Modified: pkg/trunk/gmapping/playerwrapper/playergfswrapper.h
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.h 2008-04-18 02:26:07 UTC (rev 133)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.h 2008-04-18 02:26:32 UTC (rev 134)
@@ -57,6 +57,8 @@
// Queue of range readings, with mutex
std::deque<RangeReading*> rangeDeque;
pthread_mutex_t rangeDeque_mutex;
+ pthread_cond_t rangeDeque_cond;
+ pthread_mutex_t rangeDeque_cond_mutex;
void ProcessLaser(player_msghdr_t* hdr,
player_laser_data_scanpose_t* data);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-04-18 15:24:47
|
Revision: 136
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=136&view=rev
Author: gerkey
Date: 2008-04-18 08:24:51 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
added svn:ignore properties for generated files
Property Changed:
----------------
pkg/trunk/gmapping/
pkg/trunk/gmapping/bin/
pkg/trunk/gmapping/configfile/
pkg/trunk/gmapping/gridfastslam/
pkg/trunk/gmapping/gui/
pkg/trunk/gmapping/lib/
pkg/trunk/gmapping/log/
pkg/trunk/gmapping/playerwrapper/
pkg/trunk/gmapping/playerwrapper/examples/
pkg/trunk/gmapping/scanmatcher/
pkg/trunk/gmapping/sensor/sensor_base/
pkg/trunk/gmapping/sensor/sensor_odometry/
pkg/trunk/gmapping/sensor/sensor_range/
pkg/trunk/gmapping/utils/
Property changes on: pkg/trunk/gmapping
___________________________________________________________________
Name: svn:ignore
- *.d
+ global.mk
Property changes on: pkg/trunk/gmapping/bin
___________________________________________________________________
Name: svn:ignore
+ log_plot
gfs2neff
gfs_nogui
log_test
scanmatch_test
gfs2log
configfile_test
scanstudio2carmen
rdk2carmen
gfs2rec
icptest
autoptr_test
gfs_simplegui
gfs2img
Property changes on: pkg/trunk/gmapping/configfile
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/gridfastslam
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/gui
___________________________________________________________________
Name: svn:ignore
+ *.d
moc_*.cpp
Property changes on: pkg/trunk/gmapping/lib
___________________________________________________________________
Name: svn:ignore
+ *.dylib
*.so
Property changes on: pkg/trunk/gmapping/log
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/playerwrapper
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/playerwrapper/examples
___________________________________________________________________
Name: svn:ignore
+ writelog_2008_04_17_13_15_20.log
.player
Property changes on: pkg/trunk/gmapping/scanmatcher
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/sensor/sensor_base
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/sensor/sensor_odometry
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/sensor/sensor_range
___________________________________________________________________
Name: svn:ignore
+ *.d
Property changes on: pkg/trunk/gmapping/utils
___________________________________________________________________
Name: svn:ignore
+ *.d
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-04-18 16:57:17
|
Revision: 137
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=137&view=rev
Author: gerkey
Date: 2008-04-18 09:57:07 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
sped up map updates
Modified Paths:
--------------
pkg/trunk/gmapping/gui/gsp_thread.cpp
pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
Modified: pkg/trunk/gmapping/gui/gsp_thread.cpp
===================================================================
--- pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-18 15:24:51 UTC (rev 136)
+++ pkg/trunk/gmapping/gui/gsp_thread.cpp 2008-04-18 16:57:07 UTC (rev 137)
@@ -547,6 +547,7 @@
{
m_pwrapper = pwrapper;
onLine = true;
+ mapUpdateTime = 1;
start();
}
#endif
Modified: pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 15:24:51 UTC (rev 136)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 16:57:07 UTC (rev 137)
@@ -113,6 +113,8 @@
this->sensorMap_ready = false;
}
+QApplication* app;
+
void*
GUI_thread(void* d)
{
@@ -123,14 +125,14 @@
argv[0] = "playergfswrapper";
argc=1;
- QApplication app(argc,argv);
+ app = new QApplication(argc,argv);
GFSMainWindow* mainWin=new GFSMainWindow(pd->gsp);
- app.setMainWidget(mainWin);
+ app->setMainWidget(mainWin);
mainWin->show();
- //pd->gsp->setEventBufferSize(10000);
+ pd->gsp->setEventBufferSize(10000);
pd->gsp->start(pd);
mainWin->start(1000);
- app.exec();
+ app->exec();
return(NULL);
}
@@ -179,7 +181,8 @@
this->laser->Unsubscribe(this->InQueue);
// stop GFS thread
- this->gsp->stop();
+ app->exit();
+ //this->gsp->stop();
delete this->gsp;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ge...@us...> - 2008-04-18 20:31:50
|
Revision: 139
http://personalrobots.svn.sourceforge.net/personalrobots/?rev=139&view=rev
Author: gerkey
Date: 2008-04-18 13:31:13 -0700 (Fri, 18 Apr 2008)
Log Message:
-----------
working on extracting map
Modified Paths:
--------------
pkg/trunk/gmapping/manual.mk
pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
Modified: pkg/trunk/gmapping/manual.mk
===================================================================
--- pkg/trunk/gmapping/manual.mk 2008-04-18 19:46:20 UTC (rev 138)
+++ pkg/trunk/gmapping/manual.mk 2008-04-18 20:31:13 UTC (rev 139)
@@ -1,6 +1,6 @@
#CPPFLAGS+= -DNDEBUG
-#CXXFLAGS+= -O3 -Wall -ffast-math
-CXXFLAGS+= -g -O0 -Wall
+CXXFLAGS+= -O3 -Wall -ffast-math
+#CXXFLAGS+= -g -O0 -Wall
PROFILE= false
Modified: pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp
===================================================================
--- pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 19:46:20 UTC (rev 138)
+++ pkg/trunk/gmapping/playerwrapper/playergfswrapper.cpp 2008-04-18 20:31:13 UTC (rev 139)
@@ -166,8 +166,8 @@
}
// start GFS thread
- //this->gsp->start(this);
- pthread_create(&this->gui_thread, 0, GUI_thread, this);
+ this->gsp->start(this);
+ //pthread_create(&this->gui_thread, 0, GUI_thread, this);
this->StartThread();
return(0);
@@ -204,7 +204,52 @@
this->ProcessMessages();
- // TODO: check for new pose / map from GFS thread
+ // check for new pose / map from GFS thread
+ GridSlamProcessorThread::EventDeque events=this->gsp->getEvents();
+ for(GridSlamProcessorThread::EventDeque::const_iterator it=events.begin();
+ it!=events.end();
+ it++)
+ {
+ GridSlamProcessorThread::MapEvent* mapEvent =
+ dynamic_cast<GridSlamProcessorThread::MapEvent*>(*it);
+ if(mapEvent)
+ {
+ int sx, sy;
+ double res;
+ sx = mapEvent->pmap->getMapSizeX();
+ sy = mapEvent->pmap->getMapSizeY();
+ res = mapEvent->pmap->getResolution();
+ printf("got a %d X %d map @ %.3f m / pix\n", sx,sy,res);
+ double v;
+ for(int j=0;j<sy;j++)
+ {
+ for(int i=0;i<sx;i++)
+ {
+ v = mapEvent->pmap->cell(i,j);
+ if (v>=0)
+ {
+ int grayValue=255-(int)(255.*v);
+ }
+ }
+ }
+ }
+ else
+ {
+ GridSlamProcessorThread::DoneEvent* doneEvent =
+ dynamic_cast<GridSlamProcessorThread::DoneEvent*>(*it);
+ if(doneEvent)
+ {
+ this->gsp->stop();
+ delete doneEvent;
+ }
+ else
+ {
+ // TODO: handle other events somehow
+ //history.push_back(*it);
+ }
+ }
+
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|