From: Frederic S. <fsi...@te...> - 2008-07-10 15:33:38
|
Hello Players... I am having some trouble with my laser under player 2.1.1. I am creating a LaserProxy like this: PlayerClient client(DEFAULT_HOST); LaserProxy laserProxy; ... Position2dProxy position(&client,0); ... laserProxy = new LaserProxy(&client, 0); but when I try to get data in a loop with: laserProxy->GetRange(i); I will get a segfault with the following backtrace: #0 0x08058ec3 in PlayerCc::ClientProxy::GetVar<double> () #1 0x08058f08 in PlayerCc::LaserProxy::GetRange () #2 0x080547a6 in maincalc () #3 0x08056e88 in main () BUT playerv does display laserdata just fine. What am I doing wrong ?! Greetings Frederic |
From: Fred L. <ff...@ab...> - 2008-07-10 15:56:35
|
On Thursday 10 Jul 2008, Frederic Siepmann wrote: > Hello Players... > > I am having some trouble with my laser under player 2.1.1. I am creating > a LaserProxy like this: > > PlayerClient client(DEFAULT_HOST); > LaserProxy laserProxy; > ... > Position2dProxy position(&client,0); > ... > laserProxy = new LaserProxy(&client, 0); > > but when I try to get data in a loop with: > > laserProxy->GetRange(i); > > I will get a segfault with the following backtrace: > > #0 0x08058ec3 in PlayerCc::ClientProxy::GetVar<double> () > #1 0x08058f08 in PlayerCc::LaserProxy::GetRange () > #2 0x080547a6 in maincalc () > #3 0x08056e88 in main () > > BUT playerv does display laserdata just fine. > What am I doing wrong ?! Before doing a GetRange() for the first time (e.g. just after creating the laser proxy) you have to Read() until you get a number of ray that is not 0. I don't know if this is a bug or a feature, but that solves it... Fred |
From: Frederic S. <fsi...@te...> - 2008-07-10 16:00:23
|
Hi Fred Thank you ! That was the trick... Greetings Frederic Fred Labrosse wrote: > On Thursday 10 Jul 2008, Frederic Siepmann wrote: >> Hello Players... >> >> I am having some trouble with my laser under player 2.1.1. I am creating >> a LaserProxy like this: >> >> PlayerClient client(DEFAULT_HOST); >> LaserProxy laserProxy; >> ... >> Position2dProxy position(&client,0); >> ... >> laserProxy = new LaserProxy(&client, 0); >> >> but when I try to get data in a loop with: >> >> laserProxy->GetRange(i); >> >> I will get a segfault with the following backtrace: >> >> #0 0x08058ec3 in PlayerCc::ClientProxy::GetVar<double> () >> #1 0x08058f08 in PlayerCc::LaserProxy::GetRange () >> #2 0x080547a6 in maincalc () >> #3 0x08056e88 in main () >> >> BUT playerv does display laserdata just fine. >> What am I doing wrong ?! > > Before doing a GetRange() for the first time (e.g. just after creating the > laser proxy) you have to Read() until you get a number of ray that is not 0. > I don't know if this is a bug or a feature, but that solves it... > > Fred > > ------------------------------------------------------------------------- > Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! > Studies have shown that voting for your favorite open source project, > along with a healthy diet, reduces your potential for chronic lameness > and boredom. Vote Now at http://www.sourceforge.net/community/cca08 > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users -- Dipl. Inform. Frederic Siepmann fsi...@te... Office: M6-113 Phone: +49 (0)521-106-2950 Faculty of Technology Bielefeld University Applied Computer Science P.O. Box 10 01 31 D-33501 Bielefeld |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-25 14:07:31
|
Hi all im having the same problem with the GetRange() Sorry im still dont understand the Read() part. can anyone please give the example program.. Because when i put lp.Read() it said that laser proxy doesnt have the Read() function thanks -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19144501.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Geoffrey B. <gb...@ki...> - 2008-08-25 14:17:15
|
Please look in the examples/libplayerc++/ directory for examples of how to use the C++ client library. Geoff Thayne (Mech Stu) wrote: > Hi all > im having the same problem with the GetRange() > > Sorry im still dont understand the Read() part. can anyone please give the > example program.. Because when i put > > lp.Read() > > it said that laser proxy doesnt have the Read() function > > thanks |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-25 14:23:21
|
The only example that comes with it is only the laser obstacle avoidance, which they only have the GetMinRight and GetMinLeft which works fine. i just want to be able to get the distance of each degree increment (GetRange) and i still having trouble accessing it. gbiggs wrote: > > Please look in the examples/libplayerc++/ directory for examples of how > to use the C++ client library. > > Geoff > > Thayne (Mech Stu) wrote: >> Hi all >> im having the same problem with the GetRange() >> >> Sorry im still dont understand the Read() part. can anyone please give >> the >> example program.. Because when i put >> >> lp.Read() >> >> it said that laser proxy doesnt have the Read() function >> >> thanks > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > > -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19144801.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Fred L. <ff...@ab...> - 2008-08-26 09:55:47
|
On Mon, 25 August, 2008 3:23 pm, Thayne (Mech Stu) wrote: > > The only example that comes with it is only the laser obstacle avoidance, > which they only have the GetMinRight and GetMinLeft which works fine. i just > want to be able to get the distance of each degree increment (GetRange) and > i still having trouble accessing it. > So you should be able to replace GetMinLeft() by GetRange() and do something sensible with what that returns and it should work. Starting from examples kindly provided by the developers of Player/Stage is always a good idea. They are a very good way of starting to use PS. Hope this helps. Fred |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-27 10:38:22
|
PlayerClient robot(gHostname, gPort); Position2dProxy pp(&robot, gIndex); LaserProxy lp(&robot, gIndex); LaserProxy Read(); std::cout << robot << std::endl; pp.SetMotorEnable (true); for(;;) { double newspeed = 0; double newturnrate = 0; std::cout<< "points in scan: " << lp.GetCount() <<std::endl; std::cout<< "Max Range(m): " << lp.GetMaxRange() <<std::endl; std::cout<< "Resolution(D): " << rtod(lp.GetScanRes()) <<std::endl; std::cout<< "Range(mm): " << lp.GetCount() <<std::endl<<std::endl; std::cout<< lp.GetRange(1) <<std::endl; This is my modified program from the one inside the libplayer++ "laserobstacleavoidance" when i run the program it gave me "segmentation fault" for the GetRange. Can anyone help me? Cheers in advance.. -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19178427.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Fred L. <ff...@ab...> - 2008-08-27 11:08:55
|
On Wed, 27 August, 2008 11:38 am, Thayne (Mech Stu) wrote: > This is my modified program from the one inside the libplayer++ > "laserobstacleavoidance" > when i run the program it gave me "segmentation fault" for the GetRange. > Can anyone help me? This is then a very bad modification of it. And shows that you first need to learn c++ (sorry). > > > PlayerClient robot(gHostname, gPort); > Position2dProxy pp(&robot, gIndex); > LaserProxy lp(&robot, gIndex); > > LaserProxy Read(); The example has nothing like that above. That line above tells the compiler that you will somewhere define a function called Read that will return a LaserProxy (this is called a declaration, even a forward declaration in that case, IIRC). What the example has is, in the loop below, a call to the Read() method of the class PlayerClient through one of its instances, namely robot, created above. This is the "robot.Read()" of the example. > > std::cout << robot << std::endl; > > pp.SetMotorEnable (true); > > for(;;) > { > double newspeed = 0; > double newturnrate = 0; > std::cout<< "points in scan: " << lp.GetCount() <<std::endl; > std::cout<< "Max Range(m): " << lp.GetMaxRange() <<std::endl; > std::cout<< "Resolution(D): " << rtod(lp.GetScanRes()) <<std::endl; > std::cout<< "Range(mm): " << lp.GetCount() <<std::endl<<std::endl; > > std::cout<< lp.GetRange(1) <<std::endl; > On top of that, your loop does not terminate (and the indentations are awful ;-). As I also said in one of my posts on the lms200 driver is that you may have to Read() until something is indeed read (lp.GetCount() > 0). May I suggest that you first read a good book on c++ (just to name one, Josutti's "object oriented programming in c++" is very good). This would save you, and others on the list, a lot of time. Sorry if my answer sounds a bit harsh, but this list is not supposed to be about teaching c++ (or any programming language) but about using player/stage. Hope this helps. Fred |
From: gbiggs <gb...@ki...> - 2008-08-27 11:04:40
|
You appear to have removed the call to read() on the client object from the original example. // this blocks until new data comes; 10Hz by default robot.Read(); It looks like you replaced it with a LaserProxy object. Without this call, no data will be received and so trying to access the 2nd member of the ranges array using GetRange() will access an allocated block of memory. Geoff Thayne (Mech Stu) wrote: > > PlayerClient robot(gHostname, gPort); > Position2dProxy pp(&robot, gIndex); > LaserProxy lp(&robot, gIndex); > > LaserProxy Read(); > > std::cout << robot << std::endl; > > pp.SetMotorEnable (true); > > for(;;) > { > double newspeed = 0; > double newturnrate = 0; > std::cout<< "points in scan: " << lp.GetCount() <<std::endl; > std::cout<< "Max Range(m): " << lp.GetMaxRange() <<std::endl; > std::cout<< "Resolution(D): " << rtod(lp.GetScanRes()) <<std::endl; > std::cout<< "Range(mm): " << lp.GetCount() <<std::endl<<std::endl; > > std::cout<< lp.GetRange(1) <<std::endl; > > > > This is my modified program from the one inside the libplayer++ > "laserobstacleavoidance" > when i run the program it gave me "segmentation fault" for the GetRange. > Can anyone help me? > > Cheers in advance.. |
From: Fred L. <ff...@ab...> - 2008-08-27 11:10:06
|
On Wed, 27 August, 2008 12:04 pm, gbiggs wrote: > You appear to have removed the call to read() on the client object from > the original example. > > // this blocks until new data comes; 10Hz by default > robot.Read(); > > It looks like you replaced it with a LaserProxy object. > > Without this call, no data will be received and so trying to access the > 2nd member of the ranges array using GetRange() will access an allocated > block of memory. > > Geoff This is a much nicer answer than mine. Thanks Geoff and sorry Thayne. Fred > > Thayne (Mech Stu) wrote: >> >> PlayerClient robot(gHostname, gPort); >> Position2dProxy pp(&robot, gIndex); >> LaserProxy lp(&robot, gIndex); >> >> LaserProxy Read(); >> >> std::cout << robot << std::endl; >> >> pp.SetMotorEnable (true); >> >> for(;;) >> { >> double newspeed = 0; >> double newturnrate = 0; >> std::cout<< "points in scan: " << lp.GetCount() <<std::endl; >> std::cout<< "Max Range(m): " << lp.GetMaxRange() <<std::endl; >> std::cout<< "Resolution(D): " << rtod(lp.GetScanRes()) <<std::endl; >> std::cout<< "Range(mm): " << lp.GetCount() <<std::endl<<std::endl; >> >> std::cout<< lp.GetRange(1) <<std::endl; >> >> >> >> This is my modified program from the one inside the libplayer++ >> "laserobstacleavoidance" >> when i run the program it gave me "segmentation fault" for the GetRange. >> Can anyone help me? >> >> Cheers in advance.. > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-27 11:46:49
|
Thanks dude i'll try it again. hahaha i know my C++ sucks they didnt teach us enough and im stuck with a thesis that requires a lot of C++ so the "robot.Read()" should be outside the loop after the declaration of laser proxy or inside the loopbefore "GetRange()"? -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19179321.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Fred L. <ff...@ab...> - 2008-08-27 13:46:20
|
On Wed, 27 August, 2008 12:46 pm, Thayne (Mech Stu) wrote: > > Thanks dude i'll try it again. hahaha i know my C++ sucks they didnt teach us > enough and im stuck with a thesis that requires a lot of C++ so the > "robot.Read()" should be outside the loop after the declaration of laser > proxy or inside the loopbefore "GetRange()"? Now this is a player question. You only get the current state of the robot after doing a Read(), so unless you only want the first state, you need in the loop. Fred |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-28 04:04:05
|
Hi Fred thanks for the advice but for some apparent reason it still doesnt work... wht im trying to do with the program is to be able to get a range reading from each degree increment, so that later on i can put in my potential field program (thats why im only modifying the example program) the program now looks like this: #include <libplayerc++/playerc++.h> #include <iostream> #include "args.h" #include <stdlib.h> // for atof() #include <unistd.h> #include <math.h> #include <string> #define RAYS 32 int main(int argc, char **argv) { parse_args(argc,argv); // we throw exceptions on creation if we fail try { using namespace PlayerCc; PlayerClient robot(gHostname, gPort); Position2dProxy pp(&robot, gIndex); LaserProxy lp(&robot, gIndex); std::cout << robot << std::endl; pp.SetMotorEnable (true); // go into read-think-act loop for(;;) { double newspeed = 0; double newturnrate = 0; // this blocks until new data comes; 10Hz by default robot.Read(); double minR = lp.GetMinRight(); double minL = lp.GetMinLeft(); double ra = lp.GetRange(1); std::cout << "range" << ra << std::endl; // laser avoid (stolen from esben's java example) // std::cout << "minR: " << minR <<std::endl // << "minL: " << minL // << std::endl; double l = (1e5*minR)/500-100; double r = (1e5*minL)/500-100; if (l > 100) l = 100; if (r > 100) r = 100; newspeed = (r+l)/1e3; newturnrate = (r-l); newturnrate = limit(newturnrate, -40.0, 40.0); newturnrate = dtor(newturnrate); // std::cout << "speed: " << newspeed // << "turn: " << newturnrate // << std::endl; // write commands to robot pp.SetSpeed(newspeed, newturnrate); } } catch (PlayerCc::PlayerError e) { std::cerr << e << std::endl; return -1; } } when i run it i still get the same : localhost: 6665 Segmentation fault any idea what i did wrong? THanks Fred Labrosse wrote: > > On Wed, 27 August, 2008 12:46 pm, Thayne (Mech Stu) wrote: >> >> Thanks dude i'll try it again. hahaha i know my C++ sucks they didnt >> teach us >> enough and im stuck with a thesis that requires a lot of C++ so the >> "robot.Read()" should be outside the loop after the declaration of laser >> proxy or inside the loopbefore "GetRange()"? > > Now this is a player question. > > You only get the current state of the robot after doing a Read(), so > unless > you only want the first state, you need in the loop. > > Fred > > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19193853.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Geoff <gb...@ki...> - 2008-08-28 06:17:45
|
<200...@ab...> <487...@te...> <191...@ta...> <48B...@ki...> <191...@ta...> <399...@we...> <191...@ta...> <48B...@ki...> <345...@we...> <191...@ta...> <523...@we...> <191...@ta...> Message-ID: <c44...@ih...> X-Sender: gb...@ki... SenderIP: 150.29.97.232 Received: from [150.29.97.232] (150.29.97.232) (login=Z19iaWdnc0BpaHVnLmNvLm56) by webmail.ihug.co.nz (running Vodafone Webmail/0.1) via TCP with HTTP/1.1 id <c44...@ih...>; 28 Aug 2008 18:17:12 +1200 User-Agent: Vodafone Webmail/0.1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit robot.Read() returning is no guarantee that laser range data was received. As Fred said earlier: > As I also said in one of my posts on the lms200 driver is that you may > have to Read() until something is indeed read (lp.GetCount() > 0). Geoff On Wed, 27 Aug 2008 21:04:14 -0700 (PDT), "Thayne (Mech Stu)" <tha...@ho...> wrote: > > Hi Fred thanks for the advice but for some apparent reason it still doesnt > work... wht im trying to do with the program is to be able to get a range > reading from each degree increment, so that later on i can put in my > potential field program (thats why im only modifying the example program) > the program now looks like this: > > #include <libplayerc++/playerc++.h> > #include <iostream> > > #include "args.h" > > #include <stdlib.h> // for atof() > #include <unistd.h> > > #include <math.h> > #include <string> > > #define RAYS 32 > > > int > main(int argc, char **argv) > { > parse_args(argc,argv); > > // we throw exceptions on creation if we fail > try > { > using namespace PlayerCc; > > > PlayerClient robot(gHostname, gPort); > Position2dProxy pp(&robot, gIndex); > LaserProxy lp(&robot, gIndex); > > std::cout << robot << std::endl; > > > pp.SetMotorEnable (true); > > > // go into read-think-act loop > for(;;) > { > > double newspeed = 0; > double newturnrate = 0; > > > > // this blocks until new data comes; 10Hz by default > robot.Read(); > > double minR = lp.GetMinRight(); > double minL = lp.GetMinLeft(); > double ra = lp.GetRange(1); > > std::cout << "range" << ra << std::endl; > > // laser avoid (stolen from esben's java example) > // std::cout << "minR: " << minR <<std::endl > // << "minL: " << minL > // << std::endl; > > double l = (1e5*minR)/500-100; > double r = (1e5*minL)/500-100; > > if (l > 100) > l = 100; > if (r > 100) > r = 100; > > newspeed = (r+l)/1e3; > > newturnrate = (r-l); > newturnrate = limit(newturnrate, -40.0, 40.0); > newturnrate = dtor(newturnrate); > > // std::cout << "speed: " << newspeed > // << "turn: " << newturnrate > // << std::endl; > > // write commands to robot > pp.SetSpeed(newspeed, newturnrate); > } > } > catch (PlayerCc::PlayerError e) > { > std::cerr << e << std::endl; > return -1; > } > } > > > when i run it i still get the same : > > localhost: 6665 > Segmentation fault > > any idea what i did wrong? > > THanks > > > > > Fred Labrosse wrote: >> >> On Wed, 27 August, 2008 12:46 pm, Thayne (Mech Stu) wrote: >>> >>> Thanks dude i'll try it again. hahaha i know my C++ sucks they didnt >>> teach us >>> enough and im stuck with a thesis that requires a lot of C++ so the >>> "robot.Read()" should be outside the loop after the declaration of > laser >>> proxy or inside the loopbefore "GetRange()"? >> >> Now this is a player question. >> >> You only get the current state of the robot after doing a Read(), so >> unless >> you only want the first state, you need in the loop. >> >> Fred >> >> >> >> > ------------------------------------------------------------------------- >> This SF.Net email is sponsored by the Moblin Your Move Developer's >> challenge >> Build the coolest Linux based applications with Moblin SDK & win great >> prizes >> Grand prize is a trip for two to an Open Source event anywhere in the >> world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> Playerstage-users mailing list >> Pla...@li... >> https://lists.sourceforge.net/lists/listinfo/playerstage-users >> > > -- > View this message in context: > http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19193853.html > Sent from the playerstage-users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the > world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-28 07:51:36
|
Yupp i got it now Thanks for that.. but when i connect it to the real laser and for some reason it doesnt like the "Read()" command more than 1x. when i run it the player will just frezee. but when i went back to the original program which only have 1 Read() command. the laser works fine, and i can even output it on PlayerV as well. Any suggestion? -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19195826.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Fred L. <ff...@ab...> - 2008-08-28 11:28:13
|
On Thu, 28 August, 2008 8:51 am, Thayne (Mech Stu) wrote: > > Yupp i got it now Thanks for that.. but when i connect it to the real laser > and for some reason it doesnt like the "Read()" command more than 1x. when i > run it the player will just frezee. How do you have the command "more than 1x"? Send us the bit of code. > but when i went back to the original > program which only have 1 Read() command. the laser works fine, and i can > even output it on PlayerV as well. Any suggestion? I suspect laserobstacleavoid works because it only uses GetMinRight() and GetMinLeft() that probably don't do anything if there is no data (I didn't check). The randomwalk example has the loop until GetCount()==0 but wallfollow probably fails in the same way as your program (might be worth updating the example ;-). Fred > -- > View this message in context: > http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19195826.html > Sent from the playerstage-users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > |
From: Thayne (M. Stu) <tha...@ho...> - 2008-08-28 12:36:53
|
here is the program that doesnt work when i put it in the real laser #include <libplayerc++/playerc++.h> #include <iostream> #include "args.h" #include <stdlib.h> // for atof() #include <unistd.h> #include <math.h> #include <string> #define RAYS 32 int main(int argc, char **argv) { parse_args(argc,argv); // we throw exceptions on creation if we fail try { using namespace PlayerCc; PlayerClient robot(gHostname, gPort); Position2dProxy pp(&robot, gIndex); LaserProxy lp(&robot, gIndex); std::cout << robot << std::endl; for(iii=0; iii<2; iii++) //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< robot.Read(); pp.SetMotorEnable (true); // go into read-think-act loop for(;;) { double newspeed = 0; double newturnrate = 0; // this blocks until new data comes; 10Hz by default robot.Read(); double minR = lp.GetMinRight(); double minL = lp.GetMinLeft(); std::cout <<lp.GetRange(1)<< std::endl; // laser avoid (stolen from esben's java example) // std::cout << "minR: " << minR <<std::endl // << "minL: " << minL // << std::endl; double l = (1e5*minR)/500-100; double r = (1e5*minL)/500-100; if (l > 100) l = 100; if (r > 100) r = 100; newspeed = (r+l)/1e3; newturnrate = (r-l); newturnrate = limit(newturnrate, -40.0, 40.0); newturnrate = dtor(newturnrate); // std::cout << "speed: " << newspeed // << "turn: " << newturnrate // << std::endl; // write commands to robot pp.SetSpeed(newspeed, newturnrate); } } catch (PlayerCc::PlayerError e) { std::cerr << e << std::endl; return -1; } } This Program Gives The GetRange reading beautifully when in simulation however when it is applied to real Sick laser it just frezee the simulation along with playerV. but when i erase: for(iii=0; iii<2; iii++) //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< robot.Read(); and replace this std::cout <<lp.GetRange(1)<< std::endl; with this std::cout <<lp<< std::endl; and run it again in simulation with playerV it does gives me the real reading from the laser. but the GetRange() function did not work again.. any ideas? Thanks sorry for any wrong terminology(noobie) -- View this message in context: http://www.nabble.com/lms200-segfault-on-GetRange%28%29---player-2.1.1-tp18385599p19199654.html Sent from the playerstage-users mailing list archive at Nabble.com. |
From: Fred L. <ff...@ab...> - 2008-08-28 13:05:39
|
On Thu, 28 August, 2008 1:37 pm, Thayne (Mech Stu) wrote: > > here is the program that doesnt work when i put it in the real laser > #include <libplayerc++/playerc++.h> > #include <iostream> > > #include "args.h" > > #include <stdlib.h> // for atof() > #include <unistd.h> > > #include <math.h> > #include <string> > > #define RAYS 32 > > > int > main(int argc, char **argv) > { > parse_args(argc,argv); > > // we throw exceptions on creation if we fail > try > { > using namespace PlayerCc; > > > PlayerClient robot(gHostname, gPort); > Position2dProxy pp(&robot, gIndex); > LaserProxy lp(&robot, gIndex); > > std::cout << robot << std::endl; > > for(iii=0; iii<2; iii++) > //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > robot.Read(); > > pp.SetMotorEnable (true); > > > // go into read-think-act loop > for(;;) > { > > double newspeed = 0; > double newturnrate = 0; > > > > // this blocks until new data comes; 10Hz by default > robot.Read(); > > double minR = lp.GetMinRight(); > double minL = lp.GetMinLeft(); > > std::cout <<lp.GetRange(1)<< std::endl; > > // laser avoid (stolen from esben's java example) > // std::cout << "minR: " << minR <<std::endl > // << "minL: " << minL > // << std::endl; > > double l = (1e5*minR)/500-100; > double r = (1e5*minL)/500-100; > > if (l > 100) > l = 100; > if (r > 100) > r = 100; > > newspeed = (r+l)/1e3; > > newturnrate = (r-l); > newturnrate = limit(newturnrate, -40.0, 40.0); > newturnrate = dtor(newturnrate); > > // std::cout << "speed: " << newspeed > // << "turn: " << newturnrate > // << std::endl; > > // write commands to robot > pp.SetSpeed(newspeed, newturnrate); > } > } > catch (PlayerCc::PlayerError e) > { > std::cerr << e << std::endl; > return -1; > } > } > > > This Program Gives The GetRange reading beautifully when in simulation But it's only a simulation and it does not simulate many of the behaviour (imperfections) of the real device. > however when it is applied to real > Sick laser it just frezee the simulation along with playerV. What do you mean by "simulation", I thought that was with the real laser...? > > but when i erase: > > for(iii=0; iii<2; iii++) > //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > robot.Read(); This is certainly not how you want to do that anyway. From the randomwalk.cc example: lp = new LaserProxy (&robot, gIndex); // make sure we get some data while(lp->GetCount() == 0) { robot.Read(); } Hope this helps. Fred |