Prosilica PvAPI: can't get/set attributes

When I access a prosilica GigE camera over PvAPI *not* within an orocos component, I can successfully open the camera and get/set attributes.

Copying the same code into the constructor, configuration or start hook of an orocos component, I successfully can open the camera, but I can not get/set attributes.

The system is a x64 Intel, Ubuntu 10.04.

A function call for setting an attribute has the following signature:

tPvErr PVDECL PvAttrUint32Get(tPvHandle Camera,
                              const char* Name,
                              tPvUint32* pValue);

where tPvErr is an enum, tPvHandle is of

typedef void*           tPvHandle; 

The function returns an error code 6, which means "Camera or attribute not found".

Since I can open the camera successfully (I can read out model number) I really don't know what the problem might be.

Does the PvAPI not work properly when called from an orocos component?

Best, Dani

Re: Prosilica PvAPI: can't get/set attributes

Eberli Dani wrote:
When I access a prosilica GigE camera over PvAPI *not* within an orocos component, I can successfully open the camera and get/set attributes.

Copying the same code into the constructor, configuration or start hook of an orocos component, I successfully can open the camera, but I can not get/set attributes.

The system is a x64 Intel, Ubuntu 10.04.

A function call for setting an attribute has the following signature:

tPvErr PVDECL PvAttrUint32Get(tPvHandle Camera,
                              const char* Name,
                              tPvUint32* pValue);

where tPvErr is an enum, tPvHandle is of

typedef void*           tPvHandle; 

The function returns an error code 6, which means "Camera or attribute not found".

Since I can open the camera successfully (I can read out model number) I really don't know what the problem might be.

Does the PvAPI not work properly when called from an orocos component?

Best, Dani

well, I probably should have mentioned that. I am a ROS-user, and I'm using the orocos-toolchain-ros. Now I installed the orocos-toolchain (I removed ROS_PATH (...)) from bashrc and have actually a non-ros installation.

Using *orocos-toolchain* it's working from beginning (lua not tested). So there must somewhere be an issue with the orocos-toolchain-ros!

I'm happy to be able to work with the camera :)

Prosilica PvAPI: can't get/set attributes

We internally have an orocos/prosilica camera driver that SHOULD be
published in rock already (hint hint to alex that I added in CC:)

To Alex: maybe you could just put it on gitorious so that he can at
least have a look ...

Sylvain

Prosilica PvAPI: can't get/set attributes

On Friday 27 May 2011 13:09:33 eberlid [..] ... wrote:
> When I access a prosilica GigE camera over PvAPI *not* within an orocos
> component, I can successfully open the camera and get/set attributes.
>
> Copying the same code into the constructor, configuration or start hook of
> an orocos component, I successfully can open the camera, but I can not
> get/set attributes.
>
> The system is a x64 Intel, Ubuntu 10.04.
>
> A function call for setting an attribute has the following signature:
>

> tPvErr PVDECL PvAttrUint32Get(tPvHandle Camera,
>                               const char* Name,
>                               tPvUint32* pValue);
> 

>
> where tPvErr is an enum, tPvHandle is of
>
> typedef void*           tPvHandle;
> 

>
> The function returns an error code 6, which means "Camera or attribute not
> found".
>
> Since I can open the camera successfully (I can read out model number) I
> really don't know what the problem might be.
>
> Does the PvAPI not work properly when called from an orocos component?

It certainly should ! Orocos has no magic influence :-)

I suspect that you forgot to call configure() ? If you want to force a
component to be configured, pass the 'PreOperational' parameter to the
constructor of the TaskContext base class.

How do you run/deploy your component ?

Peter

Prosilica PvAPI: can't get/set attributes

I usually load and kick-start the component by an xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "cpf.dtd">
<properties>
    <simple name="Import" type="string"><value>camera_prosilica</value></simple>
    <struct name="prosilica_component" type="Camera_prosilica">
        <struct name="Activity" type="PeriodicActivity">
            <simple name="Scheduler" type="string"><value>ORO_SCHED_RT</value></simple>
            <simple name="Period" type="double"><value>1.0</value></simple>
            <simple name="Priority" type="short"><value>1.0</value></simple>
        </struct>
 
        <simple name="AutoConf" type="boolean"><value>1</value></simple>
        <simple name="AutoStart" type="boolean"><value>1</value></simple>
        <simple name="AutoConnect" type="boolean"><value>1</value></simple>
 
    </struct>
</properties>

Now I tried it by starting manually. So I start the depoloyer-gnulinux and import the component (DisplayComponentTypes shows me the component) and I load it and then I configure it.

Since I actually put the camera setup procedure in the config-hook it starts to configure the camera.

component constructor:

Camera_prosilica::Camera_prosilica(string const& name)
        : TaskContext(name, PreOperational) {
    std::cout << "Camera_prosilica constructed !" <<std::endl;
}

the code of the configuration hook:

bool Camera_prosilica::configureHook() {
    tPvHandle camera;
    tPvAccessFlags flags = ePvAccessMaster;
    tPvErr err;
    unsigned long inetAddr = inet_addr("192.168.0.101");
 
 
    if(!PvInitialize()) {
        fprintf(stdout, "\n-- Successfully initialized API!\n");
    }
    else {
        fprintf(stderr, "\n-- Failed to initialize API!\n");
        return false;
    }
 
    Sleep(2000);
 
    err = PvCameraOpenByAddr(inetAddr,flags,&camera);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error opening camera by address: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully opened camera by address!\n");
 
    Sleep(500);
 
    err = PvCaptureAdjustPacketSize(camera,1500);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error adjusting packet size: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully set packet size!\n");
 
    Sleep(500);
 
    err = PvCaptureStart(camera);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error capture start: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully started capture!\n");
 
    Sleep(500);
 
    unsigned long FrameSize = 0;
    err = PvAttrUint32Get(camera,"TotalBytesPerFrame",&FrameSize);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error getting TotalBytesPerFrame: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully got TotalBytesPerFrame!\n");
 
    return true;
}

which gives me as output:

-- Successfully initialized API!
-- Successfully opened camera by address!
-- Successfully set packet size!
-- Successfully started capture!
-- Error getting TotalBytesPerFrame: 6

As I said, I can copy&paste this code into a usual (non-orocos component) C++ main function and it runs successfully.

That seems to be magic :-)

Prosilica PvAPI: can't

On Friday 27 May 2011 13:48:02 eberlid [..] ... wrote:
> I usually load and kick-start the component by an xml file:
>

> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE properties SYSTEM "cpf.dtd">
> <properties>
> 	<simple name="Import"
> type="string"><value>camera_prosilica</value></simple> <struct
> name="prosilica_component" type="Camera_prosilica">
> 		<struct name="Activity" type="PeriodicActivity">
> 			<simple name="Scheduler"
> type="string"><value>ORO_SCHED_RT</value></simple> <simple name="Period"
> type="double"><value>1.0</value></simple> <simple name="Priority"
> type="short"><value>1.0</value></simple> </struct>
> 
> 		<simple name="AutoConf" type="boolean"><value>1</value></simple>
> 		<simple name="AutoStart" type="boolean"><value>1</value></simple>
> 		<simple name="AutoConnect" type="boolean"><value>1</value></simple>
> 
> 	</struct>
> </properties>
> 

>
> Now I tried it by starting manually. So I start the depoloyer-gnulinux and
> import the component (DisplayComponentTypes shows me the component) and I
> load it and then I configure it.
>
> Since I actually put the camera setup procedure in the config-hook it
> starts to configure the camera.
>
> component constructor:
>
> Camera_prosilica::Camera_prosilica(string const& name)
> 
>         : TaskContext(name, PreOperational) {
> 
> 	std::cout << "Camera_prosilica constructed !" <<std::endl;
> }
> 

>
> the code of the configuration hook:
>
> bool Camera_prosilica::configureHook() {
> 	tPvHandle camera;
> 	tPvAccessFlags flags = ePvAccessMaster;
> 	tPvErr err;
> 	unsigned long inetAddr = inet_addr("192.168.0.101");
> 
> 
> 	if(!PvInitialize()) {
> 		fprintf(stdout, "\n-- Successfully initialized API!\n");
> 	}
> 	else {
> 		fprintf(stderr, "\n-- Failed to initialize API!\n");
> 		return false;
> 	}
> 
> 	Sleep(2000);
> 
> 	err = PvCameraOpenByAddr(inetAddr,flags,&camera);
> 	if(err != ePvErrSuccess) {
> 		fprintf(stderr, "-- Error opening camera by address: %d\n",
> static_cast<int>(err)); return false;
> 	}
> 	else
> 		fprintf(stdout, "-- Successfully opened camera by address!\n");
> 
> 	Sleep(500);
> 
> 	err = PvCaptureAdjustPacketSize(camera,1500);
> 	if(err != ePvErrSuccess) {
> 		fprintf(stderr, "-- Error adjusting packet size: %d\n",
> static_cast<int>(err)); return false;
> 	}
> 	else
> 		fprintf(stdout, "-- Successfully set packet size!\n");
> 
> 	Sleep(500);
> 
> 	err = PvCaptureStart(camera);
> 	if(err != ePvErrSuccess) {
> 		fprintf(stderr, "-- Error capture start: %d\n", static_cast<int>(err));
> 		return false;
> 	}
> 	else
> 		fprintf(stdout, "-- Successfully started capture!\n");
> 
> 	Sleep(500);
> 
> 	unsigned long FrameSize = 0;
> 	err = PvAttrUint32Get(camera,static_cast<const
> char*>("TotalBytesPerFrame"),&FrameSize); if(err != ePvErrSuccess) {
> 		fprintf(stderr, "-- Error getting TotalBytesPerFrame: %d\n",
> static_cast<int>(err)); return false;
> 	}
> 	else
> 		fprintf(stdout, "-- Successfully got TotalBytesPerFrame!\n");
> 
> 	return true;
> }
> 

>
> which gives me as output:
>
> -- Successfully initialized API!
> -- Successfully opened camera by address!
> -- Successfully set packet size!
> -- Successfully started capture!
> -- Error getting TotalBytesPerFrame: 6
> 

>
> As I said, I can copy&paste this code into a usual (non-orocos component)
> C++ main function and it runs successfully.

What's even more surprisingly is that the other functions do work fine. Don't
you have to set the binning and region of interest before the bytes per frame
can be read ?

>
> That seems to be magic :-)

The only difference is the presence of the deployer and taskbrowser. The
taskbrowser sets some signal handlers. If the prosilica camera uses these too,
maybe there is some interference.

Could you try to set NO_GPL=ON in OCL by doing:
cd build
cmake .. -DNO_GPL=ON
make install

Setting NO_GPL has as sideeffect that the signals are disabled.

Peter

Prosilica PvAPI: can't

when I build the makefile with

cmake -DBUILD_TYPE=DEBUG -DNO_GPL=ON
it also doesn't work.

Prosilica PvAPI: can't

On Friday 27 May 2011 15:38:21 eberlid [..] ... wrote:
> when I build the makefile with
>

> cmake -DBUILD_TYPE=DEBUG -DNO_GPL=ON
> 

For the record, it's -DCMAKE_BUILD_TYPE=Debug

> it also doesn't work.

You could try to load your component using rttlua-gnulinux, if you installed
the lua development headers on your system.

The script could look like:

require("rttlib")
tc = rtt.getTC()
depl = tc:getPeer("deployer")
depl:import("camera_prosilica")
depl:loadComponent("Test", "Camera_prosilica")
tc = depl:getPeer("Test")
tc:configure() -- tests the camera

you can type this in when running rttlua-gnulinux as well.

You need to set your path as described in
http://www.orocos.org/wiki/orocos/toolchain/orocostoolchainluacookbook

before you can run this script. If this works, than it is certainly something
with the TaskBrowser... since rttlua does not use that component.

Peter

Prosilica PvAPI: can't get/set attributes

2011/5/27 <eberlid [..] ...>

> When I access a prosilica GigE camera over PvAPI *not* within an orocos
> component, I can successfully open the camera and get/set attributes.
>
> Copying the same code into the constructor, configuration or start hook of
> an orocos component, I successfully can open the camera, but I can not
> get/set attributes.
>
> The system is a x64 Intel, Ubuntu 10.04.
>
> A function call for setting an attribute has the following signature:
>

> tPvErr PVDECL PvAttrUint32Get(tPvHandle Camera,
>                              const char* Name,
>                              tPvUint32* pValue);
> 

>
> where tPvErr is an enum, tPvHandle is of
>
> typedef void*           tPvHandle;
> 

>
> The function returns an error code 6, which means "Camera or attribute not
> found".
>
> Since I can open the camera successfully (I can read out model number) I
> really don't know what the problem might be.
>
> Does the PvAPI not work properly when called from an orocos component?
>
>
We do use the Prosilica SDK from an Orocos component and it works perfectly
fine.

Philippe

Prosilica PvAPI: can't get/set attributes

Do you see any issues in the code?

Header file:

#ifndef OROCOS_CAMERA_PROSILICA_COMPONENT_HPP
#define OROCOS_CAMERA_PROSILICA_COMPONENT_HPP
 
#include <rtt/RTT.hpp>
#include <iostream>
 
#define _LINUX
#define _x64
 
#include "PvApi.h"
 
class Camera_prosilica
    : public RTT::TaskContext
{
 public:
    Camera_prosilica(string const& name);
 
    bool configureHook();
    bool startHook();
    void updateHook();
    void stopHook();
    void cleanupHook();
 
 private:
};
 
#endif

source file:

#include "camera_prosilica-component.hpp"
#include <rtt/Component.hpp>
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#include <unistd.h>
#include <time.h>
#include <signal.h>
 
#include "arpa/inet.h"
 
/*
 * Using this macro, only one component may live
 * in one library *and* you may *not* link this library
 * with another component library. Use 
 * O_CREATE_COMPONENT_TYPE()
 * ORO_LIST_COMPONENT_TYPE(Camera_prosilica)
 * In case you want to link with another library that
 * already contains components.
 *
 * If you have put your component class
 * in a namespace, don't forget to add it here too:
 */
 
 
void Sleep(unsigned int time)
{
    struct timespec t,r;
 
    t.tv_sec    = time / 1000;
    t.tv_nsec   = (time % 1000) * 1000000;
 
    while(nanosleep(&t,&r)==-1)
        t = r;
}
 
 
Camera_prosilica::Camera_prosilica(string const& name)
        : TaskContext(name, PreOperational) {
    std::cout << "Camera_prosilica constructed !" <<std::endl;
}
 
 
bool Camera_prosilica::configureHook() {
    tPvHandle camera;
    tPvAccessFlags flags = ePvAccessMaster;
    tPvErr err;
    unsigned long inetAddr = inet_addr("192.168.0.101");
 
 
    if(PvInitialize() != ePvErrSuccess) {
        fprintf(stderr, "\n-- Failed to initialize API!\n");
        return false;
    }
    else {
        fprintf(stdout, "\n-- Successfully initialized API!\n");
    }
 
    Sleep(2000);
 
    err = PvCameraOpenByAddr(inetAddr,flags,&camera);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error opening camera by address: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully opened camera by address!\n");
 
    Sleep(500);
 
    err = PvCaptureAdjustPacketSize(camera,1500);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error adjusting packet size: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully set packet size!\n");
 
    Sleep(500);
 
    err = PvCaptureStart(camera);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error capture start: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully started capture!\n");
 
    Sleep(500);
 
    unsigned long FrameSize = 0;
    err = PvAttrUint32Get(camera,"TotalBytesPerFrame",&FrameSize);
    if(err != ePvErrSuccess) {
        fprintf(stderr, "-- Error getting TotalBytesPerFrame: %d\n", static_cast<int>(err));
        return false;
    }
    else
        fprintf(stdout, "-- Successfully got TotalBytesPerFrame!\n");
 
    Sleep(500);
 
    PvCaptureEnd(camera);
    PvCameraClose(camera);
    PvUnInitialize();
 
    return true;
}
 
bool Camera_prosilica::startHook() {
 
    return true;
}
 
void Camera_prosilica::updateHook() {
 
}
 
void Camera_prosilica::stopHook() {
 
    std::cout << "Camera_prosilica executes stopping !" <<std::endl;
}
 
void Camera_prosilica::cleanupHook() {
 
    //PvUnInitialize();
 
    std::cout << "Camera_prosilica cleaning up !" <<std::endl;
}
 
 
ORO_CREATE_COMPONENT(Camera_prosilica)

Since it just opens and closes the camera in the config-hook it is clear that camera is closed after configuration. The goal is to get the TotalBytesPerFrame successfully. I tried to get/set other attributes without success...

It returns each time with

-- Successfully initialized API!
-- Successfully opened camera by address!
-- Successfully set packet size!
-- Successfully started capture!
-- Error getting TotalBytesPerFrame: 6

Can you compare my code with your code?