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:


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

Is this how we can initialize it besides:


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

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
{
}

Thanks for the quick reply!
Um, we had it like that.

AxisCamera &camera;//declare here

isn’t that the same as

 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.

 camera(AxisCamera::GetInstance()); 

isn’t the constructor private?

Thanks!

-Masoug

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);

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)

Thanks!
Now it compiles, but I have a few questions:

yourRobotClass()://constructor
camera(AxisCamera::GetInstance())//init here

what does

function() : another_thing(){}

really do? Is it like a class, where function() “inherits” another_thing()?
How does that exactly work?

-Masoug

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

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

We still have the same problem, when I implement it in the method:


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

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

the robot code will not work, complaining that:


Relocation value does not fit in 24 bits.

is there another problem that come along with the camera class?

Thanks!

-Masoug

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

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