problem in running control code for bigbob robot simulation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem in running control code for bigbob robot simulation

irobo
Hello,

I am using Player 3.0.2 and Stage 4.1.1. I am having problem in running the bigbob code (.cc file) from jennifer owen's tutorial. I have made necessary changes for the rangerproxy everywhere in cfg and world file according to stage 4.1.1. My cfg file is running perfect. But when I am trying to run the .cc file which has simple reading of GetElementCount then it is giving me zero. Please help me out to sort this problem.
The .cc code is attached below:

******************************************************************************
#include <stdio.h>
#include <libplayerc++/playerc++.h>
#include<time.h>
#include<unistd.h>
#include<iostream>

using namespace PlayerCc;
using namespace std;
void Wander(double *, double * );


int main(int argc, char *argv[])
{
/*need to do this line in c++ only*/
//using namespace PlayerCc;
PlayerClient robot("localhost");
Position2dProxy p2dProxy(&robot,0);
RangerProxy sonarProxy(&robot,0);   //for sonar
BlobfinderProxy blobProxy(&robot,0);
RangerProxy laserProxy(&robot,1);   // for laser
p2dProxy.SetMotorEnable(1);
p2dProxy.RequestGeom();
sonarProxy.RequestGeom();
laserProxy.RequestGeom();
double forwardSpeed, turnSpeed;
uint32_t count;
//double range;
srand(time(NULL));

//some control code
robot.Read();
while(true)
{
// read from the proxies
robot.Read();
//wander
Wander(&forwardSpeed, &turnSpeed);
count = sonarProxy.GetElementCount();
//range = laserProxy.GetRange(1);
printf("count = %d\n",count);



p2dProxy.SetSpeed(forwardSpeed, dtor(turnSpeed));
sleep(1);
}

return 0;
}

void Wander(double *forwardSpeed, double *turnSpeed)
{
int maxSpeed = 1;
int maxTurn = 90;
double fspeed, tspeed;
//fspeed is between 0 and 10
fspeed = rand()%11;
//(fspeed/10) is between 0 and 1
fspeed = (fspeed/10)*maxSpeed;
tspeed = rand()%(2*maxTurn);
tspeed = tspeed-maxTurn;
//tspeed is between -maxTurn and +maxTurn
*forwardSpeed = fspeed;
*turnSpeed = tspeed;
}
*******************************************************************************

The following is the output which I get:
playerc warning   : warning : [Player v.3.0.2] connected on [localhost:6665] with sock 4

count = 0
count = 0
count = 0
count = 0
count = 0
count = 0
count = 0
count = 0
...
...
******************************************************************************

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: problem in running control code for bigbob robot simulation

light86
hi you must use change stage 3.2
stage 4 it not compatible with this code (the interface laser don't exist in stage 4)