SOEM/Orocos EtherCAT master + Xenomai

Hi all

I've been working with the SOEM/Orocos master stack (http://www.ros.org/wiki/soem) in a gnulinux Orocos target (kernel 2.6.32.32) with no problems. Now, I started working with Xenomai (linux kernel 2.2.6.38.8, Xenomai 2.6.0, ROS orocos_toolchain_ros stack + Xenomai 2.6 patch), but I've had some problems with the SOEM/Orocos master component.

When I configure the master component it manages to set the EtherCat slave and put it in the Operational state. Nevertheless, when I start it, the process data is not reaching the slave. Sometimes I see that the slave receives a first frame, but after that it stops. I have tried with periods from 0.001 to 0.01 seconds in the master without results, and when I print the 'outputs' of the slave image, I see that the data is there.

Is there any complication when working with the SOEM/Orocos master stack in a Xenomai environment? If not, did I miss some kernel configuration or something like that?

Best Regards,

Santiago

SOEM/Orocos EtherCAT master + Xenomai

Hi Santiago,

On Fri, Feb 3, 2012 at 5:50 PM, <focke [dot] 85 [..] ...> wrote:

> Actually I've measured the period time the master component is spending,
> and
> I realized that the period increases from ~0.001 to ~0.1 seconds every
> time I
> call a driver's method from my controller Orocos component that adds data
> to
> a local vector.
>
>
> bool SoemCanEthercat::addOutputCANmessage(can_message
> outputCanMessage) {
> tx_message tx_msg_temp;
> tx_msg_temp.transaction_nr = m_tx_transaction_nr;
> tx_msg_temp.can_msg = outputCanMessage;
> m_tx_transaction_nr++;
> m_input_can_messages.insert( m_input_can_messages.begin() ,
> tx_msg_temp );
> return true;
> }//SoemCanEthercat::addOutputCANmessage
>
>
> The data in that vector is later written to the 'outputs' of the slave
> during
> the updateHook of the master component, where the update method of the
> slave
> driver is called.
>

Are you sure updateHook is never called during addOutputCANmessage ?

>
> Obviously, this period time is much more than the expected one. I checked
> the
> time the driver spends in the 'addOutputCANmessage' and 'update' methods
> and
> is just about a few microsecond, so the delay is not there. This wasn't
> happening before changing to Xenomai. What can be causing this excessive
> delay in my master?
>

What we did to get soem working on Xenomai is to use rtnet instead of plain
Linux sockets, just in case the delay is caused by this.... It's no use
switching to Xenomai for SOEM if you don't use rtnet.

Ruben, is this method/option already in the SOEM repos ?

> The driver was coded following the Beckhoff drivers in the SOEM/Orocos
> master
> stack, except that I'm using an operation to receive the process data that
> will be sent to the slaves, and an Orocos port to publish the process data
> the the driver receives from the slave.
>

This should be ok, but be sure that your operation is OwnThread in case you
don't use any mutexes.

Peter

Re:

Hi Peter. Thanks for the reply

> Hi Santiago,

> On Fri, Feb 3, 2012 at 5:50 PM, <focke [dot] 85 [..] ...> wrote:

>> Actually I've measured the period time the master component is spending, and I realized that the period increases from ~0.001 to ~0.1 seconds every time I call a driver's method from my controller Orocos component that adds data to a local vector.

>> bool SoemCanEthercat::addOutputCANmessage(can_message outputCanMessage) {

                tx_message tx_msg_temp;
                tx_msg_temp.transaction_nr = m_tx_transaction_nr;
                tx_msg_temp.can_msg = outputCanMessage;
                m_tx_transaction_nr++;
               m_input_can_messages.insert( m_input_can_messages.begin() , tx_msg_temp );
                return true;
        }//SoemCanEthercat::addOutputCANmessage
>> The data in that vector is later written to the 'outputs' of the slave during the updateHook of the master component, where the update method of the slave driver is called.

> Are you sure updateHook is never called during addOutputCANmessage ?

The addOutputCANmessage methods is exactly as posted above. The master's updateHook is not called from it.

I made a small test, where I stopped calling the driver's method addOutputCANmessage. So, in this moment I just have the periodical soem master and a non-periodical controller component (Orocos task context). In the controller I'm printing, during the configureHook, a message in the console every 0.02 sec for some time and then return true. In the master updateHook i'm printing a message as well, with a master period of 0.01 sec. When I run master it prints the master messages periodically. But when I configure the controller, the master stops printing its messages until the controller finishes the configureHook. Apparently both components (taskContexts) are being executed in the same thread, or something is happening that makes that the master component thread is not processed while the controller component is being configured. The same code worked without Xenomai. What can be happening with the Orocos components and how could I solve this problem?

>> Obviously, this period time is much more than the expected one. I checked the time the driver spends in the 'addOutputCANmessage' and 'update' methods and is just about a few microsecond, so the delay is not there. This wasn't happening before changing to Xenomai. What can be causing this excessive delay in my master?

> What we did to get soem working on Xenomai is to use rtnet instead of plain Linux sockets, just in case the delay is caused by this.... It's no use switching to Xenomai for SOEM if you don't use rtnet.

But is it possible to use SOEM with Xenomai and plain Linux sockets? or is RTNet required?

> Ruben, is this method/option already in the SOEM repos ?

>> The driver was coded following the Beckhoff drivers in the SOEM/Orocos master stack, except that I'm using an operation to receive the process data that will be sent to the slaves, and an Orocos port to publish the process data the the driver receives from the slave.

> This should be ok, but be sure that your operation is OwnThread in case you don't use any mutexes.

The operation is OwnThread

>Peter

Santiago

SOEM/Orocos EtherCAT master + Xenomai

On Sat, Feb 4, 2012 at 1:04 PM, Peter Soetens <peter [..] ...>wrote:

> Hi Santiago,
>
> On Fri, Feb 3, 2012 at 5:50 PM, <focke [dot] 85 [..] ...> wrote:
>
>> Actually I've measured the period time the master component is spending,
>> and
>> I realized that the period increases from ~0.001 to ~0.1 seconds every
>> time I
>> call a driver's method from my controller Orocos component that adds data
>> to
>> a local vector.
>>
>>
>> bool SoemCanEthercat::addOutputCANmessage(can_message
>> outputCanMessage) {
>> tx_message tx_msg_temp;
>> tx_msg_temp.transaction_nr = m_tx_transaction_nr;
>> tx_msg_temp.can_msg = outputCanMessage;
>> m_tx_transaction_nr++;
>> m_input_can_messages.insert( m_input_can_messages.begin()
>> , tx_msg_temp );
>> return true;
>> }//SoemCanEthercat::addOutputCANmessage
>>
>>
>> The data in that vector is later written to the 'outputs' of the slave
>> during
>> the updateHook of the master component, where the update method of the
>> slave
>> driver is called.
>>
>
> Are you sure updateHook is never called during addOutputCANmessage ?
>
>
>>
>> Obviously, this period time is much more than the expected one. I checked
>> the
>> time the driver spends in the 'addOutputCANmessage' and 'update' methods
>> and
>> is just about a few microsecond, so the delay is not there. This wasn't
>> happening before changing to Xenomai. What can be causing this excessive
>> delay in my master?
>>
>
> What we did to get soem working on Xenomai is to use rtnet instead of
> plain Linux sockets, just in case the delay is caused by this.... It's no
> use switching to Xenomai for SOEM if you don't use rtnet.
>
> Ruben, is this method/option already in the SOEM repos ?
>

Yes, it is, AFAIK it is automatically switch on if the rtnet headers are
found in one of the standard places and xenomai is available:
http://git.mech.kuleuven.be/?p=robotics/soem.git;a=blob_plain;f=soem_cor...

Ruben

>
>
>> The driver was coded following the Beckhoff drivers in the SOEM/Orocos
>> master
>> stack, except that I'm using an operation to receive the process data that
>> will be sent to the slaves, and an Orocos port to publish the process data
>> the the driver receives from the slave.
>>
>
> This should be ok, but be sure that your operation is OwnThread in case
> you don't use any mutexes.
>
> Peter
>
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>

SOEM/Orocos EtherCAT master + Xenomai

On Feb 4, 2012, at 07:04 , Peter Soetens wrote:

> Hi Santiago,
>
> On Fri, Feb 3, 2012 at 5:50 PM, <focke [dot] 85 [..] ...> wrote:
> Actually I've measured the period time the master component is spending, and
> I realized that the period increases from ~0.001 to ~0.1 seconds every time I
> call a driver's method from my controller Orocos component that adds data to
> a local vector.
>
>
> bool SoemCanEthercat::addOutputCANmessage(can_message outputCanMessage) {
> tx_message tx_msg_temp;
> tx_msg_temp.transaction_nr = m_tx_transaction_nr;
> tx_msg_temp.can_msg = outputCanMessage;
> m_tx_transaction_nr++;
> m_input_can_messages.insert( m_input_can_messages.begin() , tx_msg_temp );
> return true;
> }//SoemCanEthercat::addOutputCANmessage
>
>
> The data in that vector is later written to the 'outputs' of the slave during
> the updateHook of the master component, where the update method of the slave
> driver is called.
>
> Are you sure updateHook is never called during addOutputCANmessage ?

We've noticed recently (in RTT v1 at least) that updateHook can be called when you don't expect it. It certainly is _not_ just on the "timer", if using a periodic activity. I wonder if anything like this exists in v2 also ...
S

Re: SOEM/Orocos EtherCAT master + Xenomai

Actually I've measured the period time the master component is spending, and I realized that the period increases from ~0.001 to ~0.1 seconds every time I call a driver's method from my controller Orocos component that adds data to a local vector.

    bool SoemCanEthercat::addOutputCANmessage(can_message outputCanMessage) {
        tx_message tx_msg_temp;
        tx_msg_temp.transaction_nr = m_tx_transaction_nr;
        tx_msg_temp.can_msg = outputCanMessage;
        m_tx_transaction_nr++;
        m_input_can_messages.insert( m_input_can_messages.begin() , tx_msg_temp );
        return true;
    }//SoemCanEthercat::addOutputCANmessage

The data in that vector is later written to the 'outputs' of the slave during the updateHook of the master component, where the update method of the slave driver is called.

Obviously, this period time is much more than the expected one. I checked the time the driver spends in the 'addOutputCANmessage' and 'update' methods and is just about a few microsecond, so the delay is not there. This wasn't happening before changing to Xenomai. What can be causing this excessive delay in my master?

The driver was coded following the Beckhoff drivers in the SOEM/Orocos master stack, except that I'm using an operation to receive the process data that will be sent to the slaves, and an Orocos port to publish the process data the the driver receives from the slave.

BR,

Santiago

focke_85 wrote:
Hi all

I've been working with the SOEM/Orocos master stack (http://www.ros.org/wiki/soem) in a gnulinux Orocos target (kernel 2.6.32.32) with no problems. Now, I started working with Xenomai (linux kernel 2.2.6.38.8, Xenomai 2.6.0, ROS orocos_toolchain_ros stack + Xenomai 2.6 patch), but I've had some problems with the SOEM/Orocos master component.

When I configure the master component it manages to set the EtherCat slave and put it in the Operational state. Nevertheless, when I start it, the process data is not reaching the slave. Sometimes I see that the slave receives a first frame, but after that it stops. I have tried with periods from 0.001 to 0.01 seconds in the master without results, and when I print the 'outputs' of the slave image, I see that the data is there.

Is there any complication when working with the SOEM/Orocos master stack in a Xenomai environment? If not, did I miss some kernel configuration or something like that?

Best Regards,

Santiago