G
Gregor Peter
Hi folks,
I've got a problem with calling a memberfunction from a inheriteded class.
It seems to work sometimes and sometimes not.
There is a Class 'Robot' that is derived from a foreigen class named 'CKR6'.
As far as I can say both of them worked fine till today.
The function I wanna use is 'moveP2P' from 'Robot'
that mainly calls 'movePTP' from class 'CKR6'.
Deklaration in file robot.h :
-----------------------------
Class Robot : CKR6 {
...
void moveP2P( const Frame& point, const int& status );
...
} // end Class robot : CKR6
Definition in file robot.cpp :
------------------------------
void Robot::moveP2P( const Frame& point, const int& status ){
...
CKR6::movePTP( calcJointAngles( point, status ));
...
} // moveP2P
I wrote a Programm 'hanoigame' that uses class 'robot' and it's
function 'moveP2P'.
Deklaration in file 'hanoigame.h'
-----------------------------------
class HanoiGame {
private:
Tower westTower, midTower, eastTower;
Robot threeCPO;//Deklaration of variable used in 'hanoigame.cpp'
public: HanoiGame();// std ctor
public: ~HanoiGame();//dtor moves the ropot back to home position
public: void start();// starts the game Towers of Hanoi
/** move as many discs as specifiyed
from the start- to destination-tower */
public: void move( Tower& start, Tower& help, Tower& destination,
const int& quantityDiscs );
}; // end CLASS HanoiGame
The constuctor of 'hanoigame' looks like this
(Code originaly does not contain the stuff sourrounded by 'MARK I')
Definition of 'hanoigame's ctor in 'hanoigame.cpp'
--------------------------------------------------
// creation of discs and stacking them on a tower
...
// instanciating of robot 'threeCPO' declared in 'hanoigame.h'
threeCPO = Robot( value1, value2, value3, value4, value5, value6 );
//// Begin MARK I ////
//
//Robot r2d2( coord1, coord2, coord3, coord4, coord5, coord6 );
//
//r2d2.moveP2P(Frame(Location(0,400,130),Orientation(0,90,-90)),110 );
//r2d2.moveP2P(Frame(Location(0,600,300),Orientation(0,90,-90)),110 );
//
//// End MARK I ////
// next line cause the crash
threeCPO.moveP2P(Frame(Location(0,550,330),Orientation(0,90,-90)),110 );
cerr << " Position reached!" << endl;
When I call the function 'movePTP' from class 'robot' the program
crashes. The debugger tells me that there are called some functions I've
never been seen before and that end up in
'kill()' from '/lib/libc.so.6'.
For me thats means my program runs into nirwana .... (and does not come
back
The strange thing is if I uncomment the statements in 'MARK I' it works
fine.
In 'MARK I' I declare and define second robot 'r2d2' and let it do some
movements.
I don't want to create always a temporaly robot when 'threeCPO' has to
move. This won't work anyway cause in other functions beyond the ctor
'hanoigame' crashes in the same way even when the 'MARK I' stuff is
uncommented in the ctor of 'hanoigame'.
Can anyone explain me why this happens?
(And tell me how to solve this problem?)
Thanks for reading this
G. Peter
I've got a problem with calling a memberfunction from a inheriteded class.
It seems to work sometimes and sometimes not.
There is a Class 'Robot' that is derived from a foreigen class named 'CKR6'.
As far as I can say both of them worked fine till today.
The function I wanna use is 'moveP2P' from 'Robot'
that mainly calls 'movePTP' from class 'CKR6'.
Deklaration in file robot.h :
-----------------------------
Class Robot : CKR6 {
...
void moveP2P( const Frame& point, const int& status );
...
} // end Class robot : CKR6
Definition in file robot.cpp :
------------------------------
void Robot::moveP2P( const Frame& point, const int& status ){
...
CKR6::movePTP( calcJointAngles( point, status ));
...
} // moveP2P
I wrote a Programm 'hanoigame' that uses class 'robot' and it's
function 'moveP2P'.
Deklaration in file 'hanoigame.h'
-----------------------------------
class HanoiGame {
private:
Tower westTower, midTower, eastTower;
Robot threeCPO;//Deklaration of variable used in 'hanoigame.cpp'
public: HanoiGame();// std ctor
public: ~HanoiGame();//dtor moves the ropot back to home position
public: void start();// starts the game Towers of Hanoi
/** move as many discs as specifiyed
from the start- to destination-tower */
public: void move( Tower& start, Tower& help, Tower& destination,
const int& quantityDiscs );
}; // end CLASS HanoiGame
The constuctor of 'hanoigame' looks like this
(Code originaly does not contain the stuff sourrounded by 'MARK I')
Definition of 'hanoigame's ctor in 'hanoigame.cpp'
--------------------------------------------------
// creation of discs and stacking them on a tower
...
// instanciating of robot 'threeCPO' declared in 'hanoigame.h'
threeCPO = Robot( value1, value2, value3, value4, value5, value6 );
//// Begin MARK I ////
//
//Robot r2d2( coord1, coord2, coord3, coord4, coord5, coord6 );
//
//r2d2.moveP2P(Frame(Location(0,400,130),Orientation(0,90,-90)),110 );
//r2d2.moveP2P(Frame(Location(0,600,300),Orientation(0,90,-90)),110 );
//
//// End MARK I ////
// next line cause the crash
threeCPO.moveP2P(Frame(Location(0,550,330),Orientation(0,90,-90)),110 );
cerr << " Position reached!" << endl;
When I call the function 'movePTP' from class 'robot' the program
crashes. The debugger tells me that there are called some functions I've
never been seen before and that end up in
'kill()' from '/lib/libc.so.6'.
For me thats means my program runs into nirwana .... (and does not come
back
The strange thing is if I uncomment the statements in 'MARK I' it works
fine.
In 'MARK I' I declare and define second robot 'r2d2' and let it do some
movements.
I don't want to create always a temporaly robot when 'threeCPO' has to
move. This won't work anyway cause in other functions beyond the ctor
'hanoigame' crashes in the same way even when the 'MARK I' stuff is
uncommented in the ctor of 'hanoigame'.
Can anyone explain me why this happens?
(And tell me how to solve this problem?)
Thanks for reading this
G. Peter