The main function of my program is to realize a client base to the physical Robot and it receives the parameters from the robot. after some processing it links to the webot environment for visual display. so i have used a two classes with the member functions. i have given the code below. i have a class called mywebot, where the client base is initialized and the class called Output handler where it polls the robot from the clientbase and receives the data from the robot. i have given the code below.

//webot.h
class myWebot{
public:
    myWebot();
     myWebot(ArClientBase *xclient, int argc, char **argv);
     static void myWebotReset();
     static int myWebotRun(int index);
     ArClientBase * getMyArClientBase();
Protected:
        ArClientBase *myclient;
};

//handler.h

class OutputHandler
{
public:
  OutputHandler(ArClientBase *client);
  virtual ~OutputHandler(void);

protected:
     ArClientBase *myClient;
};


//webot.cpp

ArClientBase * myWebot::getMyArClientBase(){
    return myClient;
}

int myWebot::myWebotRun(int ms)

{
   OutputHandler outputHandler(getMyArClientBase());  


   while (getMyArClientBase()->getRunningWithLock())
  {

   }
}

when i am building the above program the compiler gives me the following errorcode error C2352 - illegal call of a non-static member function. i have listed out the error code given by the compiler

c:my_Projwebotclientcontrollerswebotclientwebot.cpp(194) : error C2352: 'myWebot::getMyArClientBase' : illegal call of non-static member function
c:my_Projwebotclientcontrollerswebotclientwebot.h(33) : see declaration of 'myWebot::getMyArClientBase'
c:my_Projwebotclientcontrollerswebotclientwebot.cpp(204) : error C2352: 'myWebot::getMyArClientBase' : illegal call of non-static member function
c:my_Projwebotclientcontrollerswebotclientwebot.h(33) : see declaration of 'myWebot::getMyArClientBase'
c:my_Projwebotclientcontrollerswebotclientwebot.cpp(204) : error C2227: left of '->getRunningWithLock' must point to class/struct/union

can anybody help me in solving this problem. i have also attached my files with this thread.

Edited 3 Years Ago by Dani: Formatting fixed

Attachments
// handler.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "handler.h"


OutputHandler::OutputHandler(ArClientBase *client) :
  myClient(client),
  myHandleOutputCB(this, &OutputHandler::handleOutput),
 // myHandleBatteryInfoCB(this, &OutputHandler::handleBatteryInfo),
 // myHandlePhysicalInfoCB(this, &OutputHandler::handlePhysicalInfo),
  myNeedToPrintHeader(false),
  myGotBatteryInfo(true)
{
  


  /* Add a handler for general info, and request it to be called every 100 ms */
  myClient->addHandler("update", &myHandleOutputCB);
  myClient->request("update", 100);
}

OutputHandler::~OutputHandler(void)
{
  /* Halt the request for data updates */
  myClient->requestStop("update");
}

void OutputHandler::handleOutput(ArNetPacket *packet)
{
  /* Extract the data from the update packet. Its format is status and
   * mode (null-terminated strings), then 6 doubles for battery voltage, 
   * x position, y position and orientation (theta) (from odometry), current
   * translational velocity, and current rotational velocity. Translation is
   * always milimeters, rotation in degrees.
   */
  memset(myStatus, 0, sizeof(myStatus));
  memset(myMode, 0, sizeof(myMode));
  packet->bufToStr(myStatus, sizeof(myStatus));
  packet->bufToStr(myMode, sizeof(myMode));
  myVoltage = ( (double) packet->bufToByte2() )/10.0;
  myX = (double) packet->bufToByte4();
  myY = (double) packet->bufToByte4();
  myTh = (double) packet->bufToByte2();
  myVel = (double) packet->bufToByte2();
  myRotVel = (double) packet->bufToByte2();
  myLeftVel= (double) packet->bufToByte2();
  myRightVel= (double) packet->bufToByte2();
  if(myNeedToPrintHeader) 
  {
    printf("\n%6s|%6s|%6s|%6s|%6s|%6s|%6s|%6s|%15s|%20s|\n",
      "x","y","theta", "vel", "rotVel", "LeftVel", "RightVel", "volts", "mode","status");
    fflush(stdout);
    myNeedToPrintHeader = false;
  }
  if (myGotBatteryInfo)
    printf("%6.2f|%6.2f|%6.2f|%6.2f|%6.2f|%6.2f|%6.2f|%6.2f|%15s|%20s|\r",
	   myX, myY, myTh, myVel, myRotVel,myLeftVel,myRightVel, myVoltage, myMode, myStatus);
  
  fflush(stdout);
}
#ifndef HANDLER_H
#define HANDLER_H

#include "Aria.h"
#include "ArNetworking.h"

class OutputHandler
{
public:
  OutputHandler(ArClientBase *client);
  virtual ~OutputHandler(void);
  
  /// This callback is called when an update on general robot state arrives
  void handleOutput(ArNetPacket *packet);

  /// This callback is called when an update on the battery configuration changes
 // void handleBatteryInfo(ArNetPacket *packet);
  /// This is called when the physical robot information comes back
  //void handlePhysicalInfo(ArNetPacket *packet);

  inline double getX(){return myX;}
  inline double getY(){return myY;}
  inline double getTh(){return myTh;}
  inline double getVel(){return myVel;}
  inline double getRotVel(){return myRotVel;}
  inline double getLeftVel(){return myLeftVel;}
  inline double getRightVel(){return myRightVel;}

protected:

  /// The results from the data update are stored in these variables
  //@{
  double myX;
  double myY;
  double myTh;
  double myVel;
  double myRotVel;
  double myVoltage;
  double myRightVel;
  double myLeftVel;
  char myStatus[256];
  char myMode[32];
  //@}
  ArClientBase *myClient;

  /** These functor objects are given to the client to receive updates when they
   * arrive from the server.
   */
  //@{
  ArFunctor1C<OutputHandler, ArNetPacket *> myHandleOutputCB;
  //ArFunctor1C<OutputHandler, ArNetPacket *> myHandleBatteryInfoCB;
  //ArFunctor1C<OutputHandler, ArNetPacket *> myHandlePhysicalInfoCB;
  //@}
  
  /// A header for the columns in the data printout is sometimes printed
  bool myNeedToPrintHeader;
  /// Don't print any information until we get the battery info
  bool myGotBatteryInfo;
};

#endif
/// Controllers.cpp : Defines the entry point for the console application.
//
/*
 * File:         pioneer_keyoard.c
 * Date:         November 24, 2007
 * Description:  The controller used to move the pioneer with the keyboard.
 * Author:       S M Tareeq
 * Modifications: 
 *
 * Copyright (c) 2007 NII www.nii.ac.jp
 */
#include "stdafx.h"
#include "Aria.h"
#include "ArNetworking.h"
#include "handler.h"

#include "webot.h"
#include <string.h>
#include <stdio.h>
#include <device/robot.h>
#include <device/differential_wheels.h>
#include <device/pen.h>
#include <device/distance_sensor.h>
#include <iomanip>
#include <fstream>
#include <string>
#include <math.h>

#define PI 3.14159
#define TIME_STEP 100


using namespace std;
//using namespace myWebot;
using std::ofstream;
void escape(void)
{
  printf("esc pressed, shutting down aria\n");
  Aria::shutdown();
}
myWebot::myWebot(){}
myWebot::myWebot(ArClientBase *pclient, int argc, char **argv):myClient(pclient),myX(0.00),myY(0.00),myTh(0.00),myVel(0.00),myRotVel(0.00),myLeftVel(0.00),flag(0)

{

/* Aria initialization: */
     Aria::init();
	 
  /* myX=0.00;
   myY=0.00;
   myTh=0.00;
   myVel=0.00;
   myRotVel=0.00;
   myRightVel=0.00;
   myLeftVel=0.00;
   flag=0;*/

  /* Create our client object. This is the object which connects with a remote
   * server over the network, and which manages all of our communication with it
   * once connected by sending data "requests".  Requests may be sent once, or
   * may be repeated at any frequency. Requests and replies to requsets contain 
   * payload "packets", into which various data types may be packed (when making a 
   * request), and from which they may also be extracted (when handling a reply). 
   * See the InputHandler and OutputHandler classes above for
   * examples of making requests and reading/writing the data in packets.
   */

  /* Aria components use this to get options off the command line: */
  ArArgumentParser parser(&argc, argv);

  /* This will be used to connect our client to the server, including
   * various bits of handshaking (e.g. sending a password, retrieving a list
   * of data requests and commands...)
   * It will get the hostname from the -host command line argument: */
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }

  
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(myClient))
  {
    if (myClient->wasRejected())
      printf("Server '%s' rejected connection, exiting\n", myClient->getHost());
    else
      printf("Could not connect to server '%s', exiting\n", myClient->getHost());
    exit(1);
  } 
  printf("Connected to server.\n");

  ArKeyHandler keyHandler;
  Aria::setKeyHandler(&keyHandler);
  
  
  ArGlobalFunctor escapeCB(&escape);
  keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);
  /* Global escape-key handler to shut everythnig down */
  

  /* Now that we're connected, we can run the client in a background thread, 
   * sending requests and receiving replies. When a reply to a request arrives,
   * or the server makes a request of the client, a handler functor is invoked. 
   * The handlers for this program are registered with the client by the 
   * InputHandler and OutputHandler classes (in their constructors, above) */
  myClient->runAsync(); 
}

ArClientBase * myWebot::getMyArClientBase(){
	return myClient;
}



void myWebot::myWebotReset(void)
{
    char sensors_name[5]="ds0";
	int i;
//    actuator = robot_get_device();
    for (i = 0; i < MAX_SENSOR_NUMBER; i++) {
        sensors[i] = robot_get_device(sensors_name);
       // distance_sensor_enable(sensors[i], TIME_STEP);

        if ((i + 1) >= 10) {
            sensors_name[2] = '1';
            sensors_name[3]++;

            if ((i + 1) == 10) {
                sensors_name[3] = '0';
                sensors_name[4] = (char) '\0';
            }
        } else {
            sensors_name[2]++;
        }
	}
       
   //   robot_step(1000 * TIME_STEP);
      robot_keyboard_enable(TIME_STEP);
   // return 0;
}


int myWebot::myWebotRun(int ms)

{
	
   //ArClientBase client;
	int left_speed = 0, right_speed = 0;int i;char movement;
  unsigned short ds_value[MAX_SENSOR_NUMBER];
   double Val1, Val2;
	char timestamp[24];
 double XLpos, YLpos, Xfpos, Yfpos, ThL, Thf, VRL,VRf, VLL,VLf, Xfpos1,Yfpos1, TVel, RtVel, dx, dy,X , X1, Y, Y1, X2, Y2, Y3, X3;
 double Th, RotVel, RightVel, LeftVel, Vel;
 

   
   
  /* Create a key handler and also tell Aria about it */
  
    
  /* While the client is still running (getRunningWithLock locks the "running"
   * flag until it returns), check keys on the key handler (which will call
   * our callbacks), then tell the input handler to send drive commands. 
   * Sleep a fraction of a second as well to avoid using
   * too much CPU time, and give other threads time to work.
   */
	if(getFlag()==0)
	{
	
   double dx=30,dy=60, X =0, X1=0, Y=0, Y1=0, X2=0, Y2=0, Y3=0, X3=0;
   Xfpos1 = 0; Yfpos1=0; VRf=0; VLf=0;Xfpos=0; Yfpos=0;TVel=0; RtVel=0;

   
  ofstream myfile("mydatanew1.xls");
  ofstream mydata("followernew1.xls");
  myfile<<"This Remote Client program connects with the server robot and make the robot wander around, avoiding obstacles, \n" <<endl;
  myfile<<" and collects some data events through polling the robot once in every 1000ms. Press Ctrl-C to exit. \n"<<endl;
  myfile<<"Time"<<"\t"<<"Xpos" << "\t" << "Ypos" << "\t" << "Theta" << "\t" << "Trans Vel" << "\t" << " Rot Vel" << "\t"<<"LeftVel"<<"\t"<<"RightVel"<<endl;
  myfile<< "\n\n";
  mydata<< " This is a Virtual Follower which follows the server robot with the distance seperation of dx = 30 and dy 60.\n"<<endl;
  mydata<<"Time"<<"\t"<<"XLpos" << "\t" << "YLpos" << "\t" << "Xfpos" << "\t" << "Yfpos" << "\t" << "ThL" << "\t"<<"Thf"<<"\t"<< "Xfpos1"<< "\t" <<"Yfpos1"<<endl;
  mydata<< "\n\n";
 
	}
  
  //char *data= "This is a test";  // char data

	OutputHandler outputHandler(getMyArClientBase());  

     ArUtil::sleep(500);
////////////////////////////////////////////////
     

 X=outputHandler.getX();
 Y=outputHandler.getY();
  int xxx=1;
  
  while (getMyArClientBase()->getRunningWithLock())
  {
	time_t t = time(NULL);
	strftime(timestamp, 24, "%Y-%m-%d %H:%M:%S", localtime(&t));
	X=outputHandler.getX();
	Y=outputHandler.getY();
	Th=outputHandler.getTh();
	RotVel=outputHandler.getRotVel();
	LeftVel=outputHandler.getLeftVel();
	RightVel=outputHandler.getRightVel();

 	/*myX=outputHandler.getX();
	myY=outputHandler.getY();
	myTh=outputHandler.getTh();
	myVel=outputHandler.getVel();
    myRotVel=outputHandler.getRotVel();
	myLeftVel=outputHandler.getLeftVel();
	myRightVel=outputHandler.getRightVel();*/

	//myfile<<timestamp<<"\t"<<X<<"\t"<<Y<<"\t"<<Th <<"\t"<<Vel<<"\t"<<RotVel<<"\t"<<LeftVel<<"\t"<<RightVel<<endl;
   
	// assign to the follower variables
    XLpos = X; YLpos = Y; ThL=Th;  VRL=RightVel; VLL=LeftVel; TVel= Vel; RtVel= RotVel;
	ThL=(Th*(PI/180));
	Thf=ThL; 
	VRf=VRL; 
	VLf=VLL;
	
	if(XLpos<0 )
	
	{ Xfpos = XLpos + dx;
	  Yfpos = YLpos - dy;
	}
	else 
	{
	Xfpos = XLpos - dx; 
	Yfpos = YLpos - dy;
	}
	
	if (xxx>1) {
    X1 = ((0.5 * (VRL+VLL) * cos(ThL))- (((VRL-VLL)/320) * 1 * sin(ThL))) * 0.1; // 
	Y1 = ((0.5 * ( VRL+VLL) * sin(ThL))+ (((VRL-VLL)/320) * 1 * cos(ThL)))* 0.1;
	X=X+X1;
	Y=Y+Y1;
	}
	Xfpos1 = X;
	Yfpos1 = Y;
	
	
   //mydata<<timestamp<<"\t"<< XLpos << "\t" << YLpos << "\t" << Xfpos << "\t" << Yfpos << "\t" << ThL << "\t" << Thf << "\t" << Xfpos1 << "\t" << Yfpos1 <<endl;
  
   // scn->sendDouble(Xfpos,Yfpos); // send two data to the client. In the client side check for the + sign and take the value.
   
   double VLLRad = (((2 * VLL)/320) * 10);
   double VRLRad = (((2 * VRL)/320) *10);
   left_speed = (int)VLLRad; 
   right_speed = (int)VRLRad;
  
///////////////////////////////////////////////
	differential_wheels_set_speed(left_speed, right_speed);
	return TIME_STEP;  /* run one step */
  
}
  }


int mainLoop ()
{
	
	robot_live(myWebotReset);
    robot_run(myWebotRun);
	
	return 0;
}
#ifndef WEBOT_H
#define WEBOT_H

#include "stdafx.h"
#include <string.h>
#include <stdio.h>
#include "handler.h"
#include <device/robot.h>
#include <device/differential_wheels.h>
#include <device/camera.h>
#include <device/distance_sensor.h>

#define FORWARD_SPEED 10
#define TURN_SPEED 5
//#define RANGE (1024 / 2)

#define MAX_SENSOR_NUMBER 16
#define TIME_STEP 100


static DeviceTag sensors[MAX_SENSOR_NUMBER];


class myWebot{

public:
	myWebot();
	 myWebot(ArClientBase *xclient, int argc, char **argv);
	 static void myWebotReset();
	 static int myWebotRun(int index);
	 ArClientBase * getMyArClientBase();
	 void mainLoop();

  inline double getX(){return myX;}
  inline double getY(){return myY;}
  inline double getTh(){return myTh;}
  inline double getVel(){return myVel;}
  inline double getRotVel(){return myRotVel;}
  inline double getLeftVel(){return myLeftVel;}
  inline double getRightVel(){return myRightVel;}
   int getFlag() {return flag;}

  inline void setX(int x){myX=x;}
  inline void setY(int y){myY=y;}
  inline void setTh(int th){myTh=th;}
  inline void setVel(int vel){ myVel=vel;}
  inline void setRotVel(int Rvel){myRotVel = Rvel;}
  inline void setLeftVel(int LVel){myLeftVel = LVel;}
  inline void setRightVel(int Rvel){myRightVel = Rvel;}
  inline void setFlag(int F){flag = F;}
   
   
protected:
  ArClientBase *myClient;
  double myX;
  double myY;
  double myTh;
  double myVel;
  double myRotVel;
  double myLeftVel;
  double myRightVel;
  int flag;
  
};


#endif

First please fix your instructions on what you are doing...then where is your main funcion?

Static methods can not call non-static methods. You will have to design some other solution to calling that method, such as making it static also.

This article has been dead for over six months. Start a new discussion instead.