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
Playerstage-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-users