SOEM master : Creating slave drivers

Hello all

I just started studying EtherCAT and I wan't to use the SOEM driver made in ros/orocos (http://www.ros.org/wiki/soem). I've been studing the code of the soem_master_component, the soem_driver_factory and the beckhoff drivers, but I've had some trouble finding out how are the drivers registered, created and configured.

I see that, after executing the ocl deployer and entering

import("soem_beckhoff_drivers")
loadComponent("Master","soem_master::SoemMasterComponent")
, it automatically registers all the beckhoff's drivers in the factory. When and how is that done? Is that made in the cMakeList or..?

What I understand is that at some time, somehow, the methods

soem_master::SoemDriverFactory::Instance().registerDriver("ELxxxx",createSoemELxxxx);
are called, which saves the callbacks to the methods createSoemELxxxx in the 'mapped value' place of the factory map. Then the master calls the factory method createDriver, which calls the createSoemELxxxx through the callback saved in the map and returns a constructed and 'configured' (with the slave configuration info) SoemDriver instance. Is this right?

Also, I saw some 'commented' (#if 0) code using CoE. Why is it commented? Does it work as well?

Hope you can help me. Thanks in advance

Santiago

Ruben Smits's picture

SOEM master : Creating slave drivers

On Tuesday 29 November 2011 02:29:19 focke [dot] 85 [..] ... wrote:
> Hello all
>
> I just started studying EtherCAT and I wan't to use the SOEM driver made in
> ros/orocos (http://www.ros.org/wiki/soem). I've been studing the code of the
> soem_master_component, the soem_driver_factory and the beckhoff drivers,
> but I've had some trouble finding out how are the drivers registered,
> created and configured.
>
> I see that, after executing the ocl deployer and entering
>
> import("soem_beckhoff_drivers")
> loadComponent("Master","soem_master::SoemMasterComponent")
>
> , it automatically registers all the beckhoff's drivers in the factory. When
> and how is that done? Is that made in the cMakeList or..?
>
> What I understand is that at some time, somehow, the methods
>
> soem_master::SoemDriverFactory::Instance().registerDriver("ELxxxx",createSoe
> mELxxxx);
>
> are called, which saves the callbacks to the methods createSoemELxxxx in the
> 'mapped value' place of the factory map. Then the master calls the factory
> method createDriver, which calls the createSoemELxxxx through the callback
> saved in the map and returns a constructed and 'configured' (with the slave
> configuration info) SoemDriver instance. Is this right?
>

Yes! The registerDriver functions are called when the library that contains it
is loaded. This means during the import statement.

>
> Also, I saw some 'commented' (#if 0) code using CoE. Why is it commented?
> Does it work as well?
>

It is not well tested, I don't even know whether it works at all. But feel
free to investigate ;)

>
>
> Hope you can help me. Thanks in advance
>
> Santiago

Re:

Ruben Smits wrote:
On Tuesday 29 November 2011 02:29:19 focke [dot] 85 [..] ... wrote: >> Hello all

>> I just started studying EtherCAT and I wan't to use the SOEM driver made in

 ros/orocos (http://www.ros.org/wiki/soem). I've been studing the code of the
 soem_master_component, the soem_driver_factory and the beckhoff drivers,
 but I've had some trouble finding out how are the drivers registered,
 created and configured.
 
>> I see that, after executing the ocl deployer and entering
 
>> import("soem_beckhoff_drivers") >> loadComponent("Master","soem_master::SoemMasterComponent")
 
>> , it automatically registers all the beckhoff's drivers in the factory. When
 and how is that done? Is that made in the cMakeList or..?
 
>> What I understand is that at some time, somehow, the methods
 
>> soem_master::SoemDriverFactory::Instance().registerDriver("ELxxxx",createSoe
 mELxxxx);
 
>> are called, which saves the callbacks to the methods createSoemELxxxx in the
 'mapped value' place of the factory map. Then the master calls the factory
 method createDriver, which calls the createSoemELxxxx through the callback
 saved in the map and returns a constructed and 'configured' (with the slave
 configuration info) SoemDriver instance. Is this right?
 
> Yes! The registerDriver functions are called when the library that contains it
 is loaded. This means during the import statement.
Well, at least I'm not too lost :D In which part of the code are the registration methods of the slave drivers called? I mean, why (how) do the 'import' and 'loadComponent' trigger the registration methods of the drivers?

Also, I'd like to know how can I configure my network (with Ethercat Network Information (ENI) files or something like that) with the SOEM master. Do you know if SOEM has methods to load/write the ENI from/to an xml file?

 
>> Also, I saw some 'commented' (#if 0) code using CoE. Why is it commented?
 Does it work as well?
 
> It is not well tested, I don't even know whether it works at all. But feel
 free to investigate ;)

 
 
>> Hope you can help me. Thanks in advance
 
>> Santiago

Re:

focke_85 wrote:
Ruben Smits wrote:
On Tuesday 29 November 2011 02:29:19 focke [dot] 85 [..] ... wrote: >>> Hello all

>>> I just started studying EtherCAT and I wan't to use the SOEM driver made in ros/orocos http://www.ros.org/wiki/soem). I've been studing the code of the soem_master_component, the soem_driver_factory and the beckhoff drivers, but I've had some trouble finding out how are the drivers registered, created and configured.

>>> I see that, after executing the ocl deployer and entering

>>> import("soem_beckhoff_drivers") >>> loadComponent("Master","soem_master::SoemMasterComponent")

>>> , it automatically registers all the beckhoff's drivers in the factory. When and how is that done? Is that made in the cMakeList or..?

>>> What I understand is that at some time, somehow, the methods

>>> soem_master::SoemDriverFactory::Instance().registerDriver("ELxxxx",createSoe mELxxxx);

>>> are called, which saves the callbacks to the methods createSoemELxxxx in the 'mapped value' place of the factory map. Then the master calls the factory method createDriver, which calls the createSoemELxxxx through the callback saved in the map and returns a constructed and 'configured' (with the slave configuration info) SoemDriver instance. Is this right?

>> Yes! The registerDriver functions are called when the library that contains it is loaded. This means during the import statement.

> Well, at least I'm not too lost :D In which part of the code are the registration methods of the slave drivers called? I mean, why (how) do the 'import' and 'loadComponent' trigger the registration methods of the drivers?

I just realiced that the import methods are called outside the driver class. Now it makes sense to me :). Nevertheless, I still have a doubt. I have an ORO_main executable which loads my taskContexts in a taskBrowser and makes the peers connections etc. How can I import soem_beckhoff_drivers from my c++ ORO_main file?

Also, I'd like to know which would be the best way to access the slave drivers saved in m_slaves from another taskContext, so that the taskContext can use the slave drivers services.

> Also, I'd like to know how can I configure my network (with Ethercat Network Information (ENI) files or something like that) with the SOEM master. Do you know if SOEM has methods to load/write the ENI from/to an xml file?

>>> Also, I saw some 'commented' (#if 0) code using CoE. Why is it commented? Does it work as well?

>> It is not well tested, I don't even know whether it works at all. But feel free to investigate ;)

>>> Hope you can help me. Thanks in advance

>>> Santiago