Rocket-Ticket Questionthread (... haha)

Introduce your project and write about your work.

Moderator: PPS-Leaders

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by x3n » Sat May 01, 2010 4:28 pm

i assume the rocket gets destroyed if it hits something, but it doesn't delete the controller. so when the controller tries to delete the rocket, the pointer isn't valid anymore. so you probably have to delete the controller in the destructor of SimpleRocket.

i know it's a mess, because there's usually a player associated to a controllable entity which manages both controller and the entity. but in this case there's no player, so we need some workarounds ;)


i don't know why the rocket isn't visible. maybe it gets destroyed right after it spawns? add some debug output to the constructor and the destructor of simplerocket, so you can see when it gets created and destroyed.
Fabian 'x3n' Landau, Orxonox developer

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Sun May 02, 2010 11:35 am

ah that with the output is a good idea, why didn't I think of this?

If I try to destroy the controller of the simplerocket in the destructor of the simplerocket (delete this->getController()) then orxonox cannot start, it seems to destroy one SimpleRocket while starting...
again i've attached a screenshot and committed this version.
Attachments
orxonox_fail_002.JPG
At this point orxonox fails to continue and freezes.
orxonox_fail_002.JPG (86.25 KiB) Viewed 15182 times

User avatar
greenman
Baron Vladimir Harkonnen
Posts: 360
Joined: Wed Oct 03, 2007 2:53 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by greenman » Sun May 02, 2010 6:13 pm

this is probably because of the factory creation (mentioned in the introduction). you need to check whether the controller is 0 or not and (in the ctor of the rocket) set the ctroller pointer to 0 by default

Code: Select all

if( this->controller_ ) delete this->controller_
something like this

also: i saw that you do delete this in the RocketController destructor. this is always a bad idea and probably just a mistake ;)
There are only 10 types of people in the world: Those who understand binary, and those who don't.

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Sun May 02, 2010 7:54 pm

ah yes I wanted to use something like

Code: Select all

if( this->controller_ ) delete this->controller_
but it tells me I cannot access this private variable.
I used

Code: Select all

if (this->hasLocalController()) delete this->getController();
but Orxonox still crashes while starting...

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by x3n » Sun May 02, 2010 7:59 pm

yes, orxonox creates and destroys one instance of each object on startup. however the constructor stops at RegisterObject(...), so you can't initialize your object.

try this in the destructor:

Code: Select all

SimpleRocket::~SimpleRocket()
{
    if (this->isInitialized())
    {
        COUT(0)<< "simplerocket destroyed\n";
        delete this->getController();
    }
}
isInitialized() is an inherited function from BaseObject
Fabian 'x3n' Landau, Orxonox developer

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Sun May 02, 2010 9:03 pm

ah now Orxonox can start again.
but the rocket still isn't visible after constructing it (controller as well as rocket get successfully constructed as well as destroyed when going back to the mainmenu.

User avatar
greenman
Baron Vladimir Harkonnen
Posts: 360
Joined: Wed Oct 03, 2007 2:53 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by greenman » Mon May 03, 2010 9:21 am

i made some changes and the rocket is visible now
however the "spawnpoint", the velocity and the scaling are still wrong

had to change setMeshSource("Rocket.mesh") to "rocket.mesh" but i think this was not a problem on windows
There are only 10 types of people in the world: Those who understand binary, and those who don't.

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Mon May 03, 2010 10:04 am

cool. For me up to now the important thing has been to get the rocket to spawn. Now that that works I hope I can progress faster :)

thank you very much :)

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Mon May 03, 2010 11:45 am

okay the first step is done. The rocket spawns near the spaceship.
I'll post again if I get stuck (and I'm sure I will ...)
thanks again

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Fri May 07, 2010 2:15 pm

Ok I ran into the next problem.
When i invoke "destroy()" from the Simplerocket (or from the rocketcontroller) orxonox crashes.
If I don't invoke destroy() the rocket doesn't get destructed even though it crashes with things (e.g. a drone) and explodes.

User avatar
greenman
Baron Vladimir Harkonnen
Posts: 360
Joined: Wed Oct 03, 2007 2:53 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by greenman » Fri May 07, 2010 4:18 pm

without a backtrace (orxonox_crash.log) it's hard to say, but do you have any references to the rocketcontroller (not in the simplerocket) which are invalid when you destroy the rocket (and also the controller) ?
There are only 10 types of people in the world: Those who understand binary, and those who don't.

tyderion
Noxonian Brolghormeg
Posts: 36
Joined: Tue Mar 02, 2010 5:26 pm

Re: Rocket-Ticket Questionthread (... haha)

Post by tyderion » Fri May 07, 2010 5:15 pm

hmm I can't find this file... (orxonox_crash.log).
Right now I am looking for references to the controller.
When I construct the controller in the function SimpleRocketFire.fire() I use a pointer but this pointer isn't existing anymore later is it? (I'm a bit confused :? )

User avatar
greenman
Baron Vladimir Harkonnen
Posts: 360
Joined: Wed Oct 03, 2007 2:53 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by greenman » Sun May 09, 2010 2:58 pm

the file is in build/log/orxonox_crash.log

about the pointer it depends. as long as you don't delete (or destroy) the controller the pointer is valid, or what exactly do you mean?
There are only 10 types of people in the world: Those who understand binary, and those who don't.

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by x3n » Sun May 09, 2010 6:08 pm

the file doesn't exist on windows. on linux, see greenmans post.

i suggest to visit us in the PPS tomorrow, this makes it easier for us to reproduce and debug the problem.
Fabian 'x3n' Landau, Orxonox developer

User avatar
greenman
Baron Vladimir Harkonnen
Posts: 360
Joined: Wed Oct 03, 2007 2:53 pm
Contact:

Re: Rocket-Ticket Questionthread (... haha)

Post by greenman » Mon May 10, 2010 1:39 pm

fixed a problem with the rocket

it successfully collides against an asteroid now (not yet tested with bots)
There are only 10 types of people in the world: Those who understand binary, and those who don't.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests