|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
delay in Player-StageHey Everyone
I am implementing a Extended Kalman Filter in Player-Stage, my prior estimation of the position is based on the velocity model. Because I use the velocity model, then I need a small delay before I can do feature extraction of the environment, here I use clock() from the time.h to measure the difference in time. The new problem is that when my program enters the loop, the robot in my Stage simulation stops moving, so when the loop finished, the robot is far from the position the velocity model estimated. Is it possible to make a delay with a while-loop or something else while keeping the robot moving? Ps. a short code piece is shown below begin = clock(); ...... PriorEstimate(); ...... do { end = clock(); } while((double)(end-start)/CLOCKS_PER_SEC < delta_t); .... FeatureExtraction(); Thanks for your help Regards Sebastian ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
|
|
Re: delay in Player-StageOn Thu, Nov 5, 2009 at 9:06 AM, Aslund <sebastian.aslund@...> wrote:
> Hey Everyone > > I am implementing a Extended Kalman Filter in Player-Stage, my prior > estimation of the position is based on the velocity model. Because I use the > velocity model, then I need a small delay before I can do feature extraction > of the environment, here I use clock() from the time.h to measure the > difference in time. The new problem is that when my program enters the loop, > the robot in my Stage simulation stops moving, Can you explain what's happening here? Why does the robot stop moving? - rtv so when the loop finished, > the robot is far from the position the velocity model estimated. Is it > possible to make a delay with a while-loop or something else while keeping > the robot moving? > Ps. a short code piece is shown below > > begin = clock(); > ...... > PriorEstimate(); > ...... > do > { > end = clock(); > } > while((double)(end-start)/CLOCKS_PER_SEC < delta_t); > .... > FeatureExtraction(); > > Thanks for your help > > Regards > > Sebastian > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Playerstage-users mailing list > Playerstage-users@... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > > -- Richard Vaughan Autonomy Lab / Computing Science / Simon Fraser University ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
|
|
Re: delay in Player-StageHey Richard
Why it stops moving is exactly my problem and I don't know why. What happens is that I predict my future position based on a translational and rational velocity, and a time step delta_t. Before I can do a laser scan and make a feature extraction on the enviroment, then I have to wait delta_t before I preform the scan. In the short moment it takes to make the prior position estimat, the robot moves, but as soon it hits the loop where the program waits for delta_t to have passed, the robot does'nt move and I have no idea why. Hope this distribution clarifies the problem and hope a solution can be found. Regards Sebastian ps. I have added my main file if that have any interest.
2009/11/5 Richard Vaughan <rtvaughan@...>
[main.cpp] #include <iostream> #include <time.h> #include <math.h> #include "libplayerc++/playerc++.h" #include "MathTools.h" #include "MathStruct.h" #include "FeatureExtraction.h" #include "ExtendedKalman.h" #include "gnuplot_i.hpp" using namespace std; using namespace PlayerCc; typedef pair<double,double> Pair; ///Get our algoritmes MathTools MathTool; void initGlobVar(double& GlobVarX, double& GlobVarY, double& GlobVarYaw) { ///Request an initial value for the global position cout << "Enter the robots position, defined in meters and degree\n" << "X: "; cin >> GlobVarX; cout << "Y: "; cin >> GlobVarY; cout << "Yaw: "; cin >> GlobVarYaw; MathTool.convToRad(GlobVarYaw); } ///---------------- Main ---------------------------------------------------------------------- int main(int argc, char *argv[]) { ///Setting up the robot and its proxies PlayerClient robot("localhost"); LaserProxy sp(&robot,0); Position2dProxy pp(&robot,0); ///Vectors and matrixes. vector<double> dataX, dataY, x_k(3); vector<Pair> Z; matrix<double> x_cov(3,3); ///Defines double GlobX, GlobY, GlobYaw = 0; double speed = 1.0, turnrate = -1.0 * double(2.0/9.0); int count; ///Time clock_t start, end; ///Map vector<Pair> Map; Map.push_back( make_pair(7.86992, MathTool.getPi()/2.0 )); Map.push_back( make_pair(7.86992, MathTool.getPi() )); Map.push_back( make_pair(7.86992, -1*MathTool.getPi()/2.0 )); Map.push_back( make_pair(2.8, -0.527 )); cout << "--- Map ----" << endl; MathTool.printPairs(Map); cout << "------------" << endl; ///First read, initilize the proxies robot.Read(); ///Set global positioning initGlobVar(GlobX, GlobY, GlobYaw); pp.SetOdometry(GlobX, GlobY, GlobYaw); pp.SetSpeed(speed, turnrate); ///Set initial position x_k[0] = GlobX; x_k[1] = GlobY; x_k[2] = GlobYaw; ///Set intial covariance matrix for(int row = 0; row < 3; row++) for(int col = 0; col < 3; col++) x_cov[row][col] = 0; ///Initialize extended kalman filter ExtendedKalman Kalman(x_k, x_cov); ///Set first time start = clock(); // for(;;) // { ///Set robot speed pp.SetSpeed(speed, turnrate); ///Set speed in the kalman filter Kalman.setMotion(speed, turnrate); ///Set motion error Kalman.setMotionError(0.05, 0.10); ///-------------------- Prior Estimate -------------------------------------------------------------------- x_k = Kalman.getX_Prior(); ///-------------------------------------------------------------------------------------------------------- end = clock(); ///Wait until 2.086s have passed ///No motion while loop is running??? do { end = clock(); } while((double)(end-start)/CLOCKS_PER_SEC < 2.086); /// read from the proxies robot.Read(); // pp.SetSpeed(speed, turnrate); ///Update time start = end; ///Get number of laser samples count = sp.GetCount(); ///Store the laser data in cartesian coordinates for(int i = 0; i < count; i++) { if(sp.GetRange(i) < 7.9) { dataX.push_back( sp.GetRange(i) * cos(sp.GetBearing(i)) ); dataY.push_back( sp.GetRange(i) * sin(sp.GetBearing(i)) ); } } ///-------------------- Feature Extraction ------------------------------------------------------------------ ///Pass laser scans to the algoritmen FeatureExtraction Feature(false, dataX, dataY); ///Preform feature extration according to DACSAC2 Feature.DACSAC2(); ///---------------------------------------------------------------------------------------------------------- ///Get result of feature extraction Z = Feature.getMeasurement(); cout << "Feature Extraction result: " << endl; MathTool.printPairs(Z); ///-------------------- Post Estimate ----------------------------------------------------------------------- x_k = Kalman.getX_Post(Map, Z); ///---------------------------------------------------------------------------------------------------------- // } } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
|
|
Re: delay in Player-StageOn Thu, Nov 5, 2009 at 10:39 AM, Aslund <sebastian.aslund@...> wrote:
> Hey Richard > > Why it stops moving is exactly my problem and I don't know why. > What happens is that I predict my future position based on a translational > and rational velocity, and a time step delta_t. > Before I can do a laser scan and make a feature extraction on the > enviroment, then I have to wait delta_t before I preform the scan. In the > short moment it takes to make the prior position estimat, the robot moves, > but as soon it hits the loop where the program waits for delta_t to have > passed, the robot does'nt move and I have no idea why. That's because Stage runs in Player's main thread. If your work is happening there too, no simulated time can pass. - rtv > Hope this distribution clarifies the problem and hope a solution can be > found. > > Regards > > Sebastian > > ps. > I have added my main file if that have any interest. > > > 2009/11/5 Richard Vaughan <rtvaughan@...> >> >> On Thu, Nov 5, 2009 at 9:06 AM, Aslund <sebastian.aslund@...> wrote: >> > Hey Everyone >> > >> > I am implementing a Extended Kalman Filter in Player-Stage, my prior >> > estimation of the position is based on the velocity model. Because I use >> > the >> > velocity model, then I need a small delay before I can do feature >> > extraction >> > of the environment, here I use clock() from the time.h to measure the >> > difference in time. The new problem is that when my program enters the >> > loop, >> > the robot in my Stage simulation stops moving, >> >> Can you explain what's happening here? Why does the robot stop moving? >> >> - rtv >> >> >> so when the loop finished, >> > the robot is far from the position the velocity model estimated. Is it >> > possible to make a delay with a while-loop or something else while >> > keeping >> > the robot moving? >> > Ps. a short code piece is shown below >> > >> > begin = clock(); >> > ...... >> > PriorEstimate(); >> > ...... >> > do >> > { >> > end = clock(); >> > } >> > while((double)(end-start)/CLOCKS_PER_SEC < delta_t); >> > .... >> > FeatureExtraction(); >> > >> > Thanks for your help >> > >> > Regards >> > >> > Sebastian >> > >> > >> > ------------------------------------------------------------------------------ >> > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> > 30-Day >> > trial. Simplify your report design, integration and deployment - and >> > focus >> > on >> > what you do best, core application coding. Discover what's new with >> > Crystal Reports now. http://p.sf.net/sfu/bobj-july >> > _______________________________________________ >> > Playerstage-users mailing list >> > Playerstage-users@... >> > https://lists.sourceforge.net/lists/listinfo/playerstage-users >> > >> > >> >> >> >> -- >> Richard Vaughan >> Autonomy Lab / Computing Science / Simon Fraser University >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Playerstage-users mailing list >> Playerstage-users@... >> https://lists.sourceforge.net/lists/listinfo/playerstage-users > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Playerstage-users mailing list > Playerstage-users@... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > > -- Richard Vaughan Autonomy Lab / Computing Science / Simon Fraser University ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
|
|
Re: delay in Player-StageI see, quite a problem.
Is there a way to count the time without blocking for stage? Regards Sebastian 2009/11/5 Richard Vaughan <rtvaughan@...>
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
|
|
Re: delay in Player-StageIs it possible that the simulation is just slowing down a lot
because your client program is hammering your CPU during the while loop?
Try adding a small delay, like calling usleep(100000); [100 ms] inside of the while
loop to free up system resources for everything else that’s trying to
run. It looks like your update interval is somewhere around 2 seconds, so
pausing for 100ms should make your delay time between about 2 and 2.1
seconds. Cut the usleep by an order of magnitude (i.e. remove a 0) and you
should get a delay time between about 2 and 2.01 seconds. I don’t think it has anything to do with you actually
stopping Player or Stage, since your program is running on its own and just using
the client libraries to tie in to Player via the network. It sounds more
like a system-wide resource issue to me. Rich From: Aslund
[mailto:sebastian.aslund@...] Hey Richard 2009/11/5 Richard Vaughan <rtvaughan@...> On Thu, Nov 5, 2009 at 9:06 AM,
Aslund <sebastian.aslund@...>
wrote: Can you explain what's happening here? Why does the robot
stop moving?
> ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
|
|
Re: delay in Player-StageThanks for all the help.
usleep did the trick and it works, nealy. Got some timming issues with the laser scanning, seems to come to early, but I am hoping that I can overcome it soon :) Regards Sebastian 2009/11/5 Rich Mattes <jpgr87@...>
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-users mailing list Playerstage-users@... https://lists.sourceforge.net/lists/listinfo/playerstage-users |
| Free embeddable forum powered by Nabble | Forum Help |