ROS机器人操作系统

【ROS-I wiki翻译(五)】ROS-I教程之简单 Ethe

2018-09-19  本文已影响10人  十月石榴2013

原网页:Create a simple EtherCAT IO network (Implementation Notes)

PS:文章最后给了一个知网连接,是在ROS下使用Ethercat的相关论文。

1. 硬件设置(例子)

  1. T61 联想笔记本 (带 Ethernet 卡)
  2. IO rack: EtherCAT Couper, 8 DI, & 8DO (all Beckhoff)

2. Beckhoff(倍福) EtherCAT 驱动

  1. 安装ROS的OROCOS toolchain
  2. 安装Simple Open EtherCAT Master (soem)
git clone https://github.com/orocos/rtt_soem.git
  1. 运行catkin_make,编译连接soem
  2. 将Ethercat设备连接到以太网口。EtherCAT可通过标准以太网工作。直接建立连接,连接应该不能通过交换机,因为典型的以太网耦合器没有IP地址。
    (原文:Connect EtherCAT device to ethernet port. EtherCAT works over standard ethernet cable. Make a direct connection, I do not think connections through switches work since EtherCAT couplers do not have IP addresses (typcially))
  3. soem_core 包中给 slaveinfo 访问socket命令的root访问权限:
sudo setcap cap_net_raw+ep bin/slaveinfo
(可能需要安装这个:)
sudo apt-get install libcap2-bin
  1. 执行 slaveinfo 模块:
rosrun soem_core slaveinfo <device, typcially eth0>

模块成功执行时,将会打印一张连接到的从机列表。
7.(最新版的soem中可能不需要这一步)soem堆栈有一个BUG,无法识别未知模块的IO大小。 以下补丁修复了该BUG(已提交BUG)。

 diff --git a/soem_master/soem_master_component.cpp b/soem_master/soem_master_component.cpp
 index e166ad0..dc6b460 100644
 --- a/soem_master/soem_master_component.cpp
 +++ b/soem_master/soem_master_component.cpp
 @@ -79,6 +79,8 @@ bool SoemMasterComponent::configureHook()
              // wait for all slaves to reach PRE_OP state
              ec_statecheck(0, EC_STATE_PRE_OP, EC_TIMEOUTSTATE);

 +          ec_config(FALSE, &m_IOmap);
 +
              for (int i = 1; i <= ec_slavecount; i++)
              {
                  SoemDriver
 @@ -89,6 +91,8 @@ bool SoemMasterComponent::configureHook()
                      m_drivers.push_back(driver);
                      log(Info) << "Created driver for " << ec_slave[i].name
                              << ", with address " << ec_slave[i].configadr
 +                            << ", output bits " << ec_slave[i].Obits
 +                            << ", input bits " << ec_slave[i].Ibits
                              << endlog();
                      //Adding driver's services to master component
                      this->provides()->addService(driver->provides());
  1. 在soem_master目录下运行rosmake编译补丁。
  2. 编辑 test.ops 脚本,启动master并将OROCOS消息映射到ROS主题。
 import("soem_beckhoff_drivers")
 loadComponent("Master","soem_master::SoemMasterComponent")
 Master.displayAvailableDrivers()

 # Default nic is eth0, set if different. e.g.
 #Master.ifname = "eth1"

 # Crawls the network and identifies attached devices.  Devices are loaded
 # (if a driver exists) and given names "Slave_1***".  The *** appear to be
 # the module order (at least this is the case for a single rack)
 Master.configure()

 # Setting the update period (in seconds).  This determines the rate at which
 # the data is published on the ROS side (setting this value to zero turns
 # off updating
 Master.setPeriod(0.05)

 # This stars the Master "task" running.  It will update at the period set
 # above
 Master.start()

 # This command remaps OROCOS topics to ROS topics
 stream("Master.Slave_1002.bits", ros.topic("DI"))
 stream("Master.Slave_1003.bits", ros.topic("DO"))
  1. ocl 包中给 deployer-gnulinux 访问socket命令的root访问权限:
 sudo setcap cap_net_raw+ep bin/deployer-gnulinux
  1. 在命令行中 launch the master:
 roslaunch soem_master soem_master_test.launch

launch文件会launch orocos,load test.ops脚本。

3. 其他

  1. 打开OROCOS消息日志:export ORO_LOGLEVEL=5</tt> (见 [The Orocos Component Builder's Manual - Logging]。(http://www.orocos.org/stable/documentation/rtt/v2.x/doc-xml/orocos-components-manual.html#corelib-logging))
  2. OROCOS消息和ROS消息的转换(见 rtt_ros_integration_example)例程脚本:stream("Master.Slave_1002.bits", ros.topic("DI_bits"))

译者注:

这有一篇关于ROS下使用Ethercat的文章:ROS下基于Ethercat的串联机器人控制系统

上一篇下一篇

猜你喜欢

热点阅读