0

when i comple this code it says,
wander.cc:28: error: 'Wander' was not declared in this scope

I got this code from Jenny Owen's tuorial on Player/Stage. In that one th Wander function is not decalred. Could you please tell me why I am getting this error and how to declare the function.

following is my code

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


int main(int argc, char *argv[])
{
  using namespace PlayerCc;
//  double Wander (forwardSpeed, turnSpeed);
  PlayerClient robot("localhost", 6665);

  Position2dProxy p2dProxy(&robot, 0);

  double forwardSpeed, turnSpeed;

  srand(time(NULL));

  p2dProxy.SetMotorEnable(1);

  p2dProxy.RequestGeom();

 // robot.Read();
  while(true)
  {
    robot.Read();
    printf("wandering\n");
    Wander( &forwardSpeed, &turnSpeed);

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

}

void Wander(double *forwardSpeed, double *turnSpeed)
 {

   int maxSpeed = 1;
 int maxTurn  = 90;
   double fspeed, tspeed;

fspeed = rand()%11;
fspeed = (fspeed/10*maxSpeed);
tspeed = rand()%(2*maxTurn);

tspeed = tspeed - maxTurn;

*forwardSpeed = fspeed;
*turnSpeed = tspeed;

 }

Edited by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by thomas_naveen
0

You could try giving the prototype of the function at the start of the program.

void Wander(double *forwardSpeed, double *turnSpeed);

Kindly use code tags while posting code..

Edited by thomas_naveen: added info regarding code tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.