Re: wander.cpp position update

原创 2005年04月28日 09:35:00

First of all, your code is after a 'run' so won't get called until the
robot has disconnected (ie you hit control C or reset the
microcontroller)... thats why you're always getting the same
position...  If you put in a 'runAsync' instead of a 'run' you'd get
more like the behavior your expect...  

You also shouldn't have a (time % 125) in there... just have your
sleep sleep for 125 and don't have the % 125 in there... since if you
really slept for 50 ms you'd never hit the 125 cycle... apparently it
is, but I don't know how (it should hit maybe every 250... but thats
the wrong way to approach timing).

The easier way to do all of this is to make a user task... you can see
a good example of how to do this in examples/simpleUserTask, you could
also just have a global function with an ArGlobalFunctor if you wanted
a simpler start.

User tasks get called every robot cycle... which is of course when you
want your data.  Unless you're getting into threading stuff you're
probably better off going with a user task... its also a lot easier to
combine different user tasks than it is loops like the one you have
below... ie you can make your code more modular so you can use
different bits and pieces together.

Matt LaFary
Activmedia Robotics


On Tue, Mar 19, 2002 at 12:26:36PM -0800, Aumack Steven wrote:
> I want to modify the wander.cpp file so that i can
> ouput (to a file) the X,Y,Th position, and time during
> the execution of this demo.  here is some of the code
> that I wrote so far.  it is not working properly.  any
> suggestions?
> 
> Thanks a lot,
> 
> i have included fstream.h and iomanip.h
> 
> i made sure to also write...so that is not a problem.
> 
> ArTime start;
> ArRobot robot;
> double PosX, PosY, PosTh;
> int time;
> 
> 
> 
> 
>   // add these actions
>   robot.addAction(&recover, 100);
>   robot.addAction(&bumpers, 75);
>   robot.addAction(&avoidFrontNear, 50);
>   robot.addAction(&avoidFrontFar, 49);
>   robot.addAction(&constantVelocity, 25);
>   
>   // start the robot running, true so that if we lose
> connection the run stops
>   robot.run(true);
> 
> 
> 
>   start.setToNow();
> 
>   f << "Wandering Around Aimlessly/n";
>   f << setw(11) << "X" << setw(11) << "Y" << setw(11)
> << "Th" << setw(11) << "T" << endl;
> 
>   int i = 0;
> 
>   while(1)
>   {
> 	  robot.lock();
> 	  time = start.mSecSince();
> 	  if ( (time % 125) == 0)
> 	  {
> 		  PosX = robot.getX();
> 		  PosY = robot.getY();
> 		  PosTh = robot.getTh();
> 		  time = start.mSecSince();
> 		  f << setw(11) << PosX << setw(11) << PosY <<
> setw(11) << PosTh << setw(11) << time << endl;
> 	  }
> 	  robot.unlock();
> 	  ArUtil::sleep(50);
>   }
> 
>   f.close;       //closes file
> 	  
>   // now exit
>   Aria::shutdown();
>   return 0;
> }
> 
> 
> 
> and here is a sample output...
> 
> 
> Wandering Around Aimlessly
>           X          Y         Th          T
>     1456.41          0          0          0
>     1456.41          0          0        125
>     1456.41          0          0        250
>     1456.41          0          0        375
>     1456.41          0          0        500
>     1456.41          0          0        625
>     1456.41          0          0        750
>     1456.41          0          0        875
>     1456.41          0          0       1000
>     1456.41          0          0       1125
>     1456.41          0          0       1250
>     1456.41          0          0       1375
>     1456.41          0          0       1500
>     1456.41          0          0       1625
>     1456.41          0          0       1750
>     1456.41          0          0       1875
>     1456.41          0          0       2000
> 
> as you can see, positions are not updating every 125
> ms.
> 
> what is wrong?

Re: Can't install nvidia devdriver in FC15 after kernel update to 2.6.40-4

Re: Can't install nvidia devdriver in FC15 after kernel update to 2.6.40-4 http://forums.fedora...

heterlist(update and annotation).cpp

  • 2016年01月15日 18:28
  • 12KB
  • 下载

【浙江集训】wander

题目描述给出一棵包含nn个点的森林。问按照以下规则行走,从uu走到vv的期望步数是多少。行走的伪代码如下:count = 0bool DFS( x, fa ) if ( x==v ) retu...
  • Yves___
  • Yves___
  • 2015年12月12日 02:04
  • 396

FTP Wander

  • 2012年06月13日 21:28
  • 2.65MB
  • 下载

position图片定位

  • 2016年01月12日 13:56
  • 1KB
  • 下载

Re:从零开始的Spring Security Oauth2(一)

前言今天来聊聊一个接口对接的场景,A厂家有一套HTTP接口需要提供给B厂家使用,由于是外网环境,所以需要有一套安全机制保障,这个时候oauth2就可以作为一个方案。关于oauth2,其实是一个规范,本...

Vigenère Cipher 维吉尼亚加解密算法

维吉尼亚的加解密有两种方法。   第一种是查表:第一行为明文,第一列为密钥,剩余的为对应的密文   ------------------...

viewpager position changed

  • 2015年06月12日 18:33
  • 4.96MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Re: wander.cpp position update
举报原因:
原因补充:

(最多只允许输入30个字)