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:
> &#10;&gt; &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&gt; &lt;!DOCTYPE properties SYSTEM &quot;cpf.dtd&quot;&gt;&#10;&gt; &lt;properties&gt;&#10;&gt;         &lt;simple name=&quot;Import&quot;&#10;&gt; type=&quot;string&quot;&gt;&lt;value&gt;camera_prosilica&lt;/value&gt;&lt;/simple&gt; &lt;struct&#10;&gt; name=&quot;prosilica_component&quot; type=&quot;Camera_prosilica&quot;&gt;&#10;&gt;               &lt;struct name=&quot;Activity&quot; type=&quot;PeriodicActivity&quot;&gt;&#10;&gt;                     &lt;simple name=&quot;Scheduler&quot;&#10;&gt; type=&quot;string&quot;&gt;&lt;value&gt;ORO_SCHED_RT&lt;/value&gt;&lt;/simple&gt; &lt;simple name=&quot;Period&quot;&#10;&gt; type=&quot;double&quot;&gt;&lt;value&gt;1.0&lt;/value&gt;&lt;/simple&gt; &lt;simple name=&quot;Priority&quot;&#10;&gt; type=&quot;short&quot;&gt;&lt;value&gt;1.0&lt;/value&gt;&lt;/simple&gt; &lt;/struct&gt;&#10;&gt; &#10;&gt;          &lt;simple name=&quot;AutoConf&quot; type=&quot;boolean&quot;&gt;&lt;value&gt;1&lt;/value&gt;&lt;/simple&gt;&#10;&gt;           &lt;simple name=&quot;AutoStart&quot; type=&quot;boolean&quot;&gt;&lt;value&gt;1&lt;/value&gt;&lt;/simple&gt;&#10;&gt;          &lt;simple name=&quot;AutoConnect&quot; type=&quot;boolean&quot;&gt;&lt;value&gt;1&lt;/value&gt;&lt;/simple&gt;&#10;&gt; &#10;&gt;      &lt;/struct&gt;&#10;&gt; &lt;/properties&gt;&#10;&gt;
>
> 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:
> &#10;&gt; Camera_prosilica::Camera_prosilica(string const&amp; name)&#10;&gt; &#10;&gt;         : TaskContext(name, PreOperational) {&#10;&gt; &#10;&gt;        std::cout &lt;&lt; &quot;Camera_prosilica constructed !&quot; &lt;&lt;std::endl;&#10;&gt; }&#10;&gt;
>
> the code of the configuration hook:
> &#10;&gt; bool Camera_prosilica::configureHook() {&#10;&gt;     tPvHandle camera;&#10;&gt;      tPvAccessFlags flags = ePvAccessMaster;&#10;&gt;        tPvErr err;&#10;&gt;    unsigned long inetAddr = inet_addr(&quot;192.168.0.101&quot;);&#10;&gt; &#10;&gt; &#10;&gt;     if(!PvInitialize()) {&#10;&gt;          fprintf(stdout, &quot;\n-- Successfully initialized API!\n&quot;);&#10;&gt;     }&#10;&gt;      else {&#10;&gt;                 fprintf(stderr, &quot;\n-- Failed to initialize API!\n&quot;);&#10;&gt;                 return false;&#10;&gt;  }&#10;&gt; &#10;&gt;    Sleep(2000);&#10;&gt; &#10;&gt;         err = PvCameraOpenByAddr(inetAddr,flags,&amp;camera);&#10;&gt;  if(err != ePvErrSuccess) {&#10;&gt;             fprintf(stderr, &quot;-- Error opening camera by address: %d\n&quot;,&#10;&gt; static_cast&lt;int&gt;(err)); return false;&#10;&gt;     }&#10;&gt;      else&#10;&gt;           fprintf(stdout, &quot;-- Successfully opened camera by address!\n&quot;);&#10;&gt; &#10;&gt;    Sleep(500);&#10;&gt; &#10;&gt;  err = PvCaptureAdjustPacketSize(camera,1500);&#10;&gt;  if(err != ePvErrSuccess) {&#10;&gt;             fprintf(stderr, &quot;-- Error adjusting packet size: %d\n&quot;,&#10;&gt; static_cast&lt;int&gt;(err)); return false;&#10;&gt;         }&#10;&gt;      else&#10;&gt;           fprintf(stdout, &quot;-- Successfully set packet size!\n&quot;);&#10;&gt; &#10;&gt;     Sleep(500);&#10;&gt; &#10;&gt;  err = PvCaptureStart(camera);&#10;&gt;  if(err != ePvErrSuccess) {&#10;&gt;             fprintf(stderr, &quot;-- Error capture start: %d\n&quot;, static_cast&lt;int&gt;(err));&#10;&gt;                return false;&#10;&gt;  }&#10;&gt;      else&#10;&gt;           fprintf(stdout, &quot;-- Successfully started capture!\n&quot;);&#10;&gt; &#10;&gt;     Sleep(500);&#10;&gt; &#10;&gt;  unsigned long FrameSize = 0;&#10;&gt;   err = PvAttrUint32Get(camera,static_cast&lt;const&#10;&gt; char*&gt;(&quot;TotalBytesPerFrame&quot;),&amp;FrameSize); if(err != ePvErrSuccess) {&#10;&gt;               fprintf(stderr, &quot;-- Error getting TotalBytesPerFrame: %d\n&quot;,&#10;&gt; static_cast&lt;int&gt;(err)); return false;&#10;&gt;    }&#10;&gt;      else&#10;&gt;           fprintf(stdout, &quot;-- Successfully got TotalBytesPerFrame!\n&quot;);&#10;&gt; &#10;&gt;      return true;&#10;&gt; }&#10;&gt;
>
> which gives me as output:
> &#10;&gt; -- Successfully initialized API!&#10;&gt; -- Successfully opened camera by address!&#10;&gt; -- Successfully set packet size!&#10;&gt; -- Successfully started capture!&#10;&gt; -- Error getting TotalBytesPerFrame: 6&#10;&gt;
>
> 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
> &#10;&gt; cmake -DBUILD_TYPE=DEBUG -DNO_GPL=ON&#10;&gt;

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:

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

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:
> &#10;&gt; tPvErr PVDECL PvAttrUint32Get(tPvHandle Camera,&#10;&gt;                              const char* Name,&#10;&gt;                              tPvUint32* pValue);&#10;&gt;
>
> where tPvErr is an enum, tPvHandle is of
> &#10;&gt; typedef void*           tPvHandle;&#10;&gt;
>
> 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?