Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   How To Implement Axis Camera In Iterative Robot (http://www.chiefdelphi.com/forums/showthread.php?t=86677)

masoug 25-08-2010 22:34

How To Implement Axis Camera In Iterative Robot
 
Hi,
I am trying to implement the AxisCamera class into our Iterative Robot method, but unfortunately, the AixsCamera class has a difficult time initializing properly. We currently have:

Code:

...
AxisCamera* camera;
camera = &AxisCamera::GetInstance();
...

Is this how we can initialize it besides:

Code:

AxisCamera &camera = AxisCamera::GetInstance();
?

I am pretty novice to all this allocation and stuff, so I would love to have any sort of feedback!

Thanks!

-Masoug

byteit101 26-08-2010 10:36

Re: How To Implement Axis Camera In Iterative Robot
 
Do you have it just like that? or do you have the variable declared up top?

class yourRobotClass: public iterativebot
{
AxisCamera &camera;//declare here

public:
yourRobotClass()://constructor
camera(AxisCamera::GetInstance())//init here
{
}

masoug 26-08-2010 13:03

Re: How To Implement Axis Camera In Iterative Robot
 
Thanks for the quick reply!
Um, we had it like that.
Quote:

AxisCamera &camera;//declare here
isn't that the same as
Code:

AxisCamera* camera;
?
Sorry, I am not that familiar with C++ pointers and addresses...

Can you also explain your code a little more clearly? E.G.
Code:

camera(AxisCamera::GetInstance());
isn't the constructor private?

Thanks!

-Masoug

Radical Pi 26-08-2010 16:51

Re: How To Implement Axis Camera In Iterative Robot
 
constructors are public (in every program I've seen)

The & makes the variable camera a reference. A reference is similar to a pointer, however once it it set it cannot be changed, and it acts like a non-pointer variable after being set (Use the . operator to access funtions instead of -> )

The camera(AxisCamera::GetInstance()); sets the camera reference to the global AxisCamera object. From that point on if you want to do something like get an image the code is camera.GetImage(imageVar);

byteit101 27-08-2010 15:40

Re: How To Implement Axis Camera In Iterative Robot
 
Quote:

Originally Posted by Radical Pi (Post 972568)
constructors are public

not always, but at least one is usually available: the copy constructor (which is used here)
.net has quite a few classes that don't have public constructors (like Graphics)

masoug 28-08-2010 02:24

Re: How To Implement Axis Camera In Iterative Robot
 
Thanks!
Now it compiles, but I have a few questions:
Quote:

yourRobotClass()://constructor
camera(AxisCamera::GetInstance())//init here
what does
Code:

function() : another_thing(){}
really do? Is it like a class, where function() "inherits" another_thing()?
How does that exactly work?

-Masoug

Radical Pi 28-08-2010 11:43

Re: How To Implement Axis Camera In Iterative Robot
 
No inheritance here. another_thing is a variable defined somewhere else. It gets set with the value in the parentheses when the function is called.

masoug 28-08-2010 17:12

Re: How To Implement Axis Camera In Iterative Robot
 
Quote:

Originally Posted by Radical Pi (Post 972682)
No inheritance here. another_thing is a variable defined somewhere else. It gets set with the value in the parentheses when the function is called.

So then how is that different than
Code:

camera = AxisCamera::GetInstance()
?

I heard about "initialization list", but what/why is this a case to use it? What about AxisCamera class that it has to bee initialized as a reference?

Thanks!

-Masoug

byteit101 29-08-2010 20:51

Re: How To Implement Axis Camera In Iterative Robot
 
Quote:

Originally Posted by masoug (Post 972699)
So then how is that different than
Code:

camera = AxisCamera::GetInstance()
?

I heard about "initialization list", but what/why is this a case to use it? What about AxisCamera class that it has to bee initialized as a reference?

Thanks!

-Masoug

references can only point to one thing in there life, and you must set it at the very beginning. If you'd used a pointer, you could do that, since pointers can point to many things in their life

The GetInstance returns a reference, so it has to be a reference or a pointer

masoug 01-09-2010 20:25

Re: How To Implement Axis Camera In Iterative Robot
 
We still have the same problem, when I implement it in the method:
Code:

class yourRobotClass: public iterativebot
{
AxisCamera &camera;//declare here

public:
yourRobotClass()://constructor
camera(AxisCamera::GetInstance())//init here
{
}

the robot code will not work, complaining that:
Code:

Relocation value does not fit in 24 bits.
is there another problem that come along with the camera class?

Thanks!

-Masoug

Alan Anderson 01-09-2010 22:04

Re: How To Implement Axis Camera In Iterative Robot
 
Quote:

Originally Posted by masoug (Post 973108)
Code:

Relocation value does not fit in 24 bits.

A search of the forums for that error message yields a possibly relevant thread.

masoug 08-09-2010 21:26

Re: How To Implement Axis Camera In Iterative Robot
 
I checked and "-mlongcall" was already there and the cRIO still complains about "Relocation value does not fit in 24 bits."
Is there any other thing we can do?

Thanks!

-Masoug


All times are GMT -5. The time now is 12:36.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi