Issue with Bosch Rexroth ctrlX C++ SDK and Festo VTEM EtherCAT Communication

Hello,

I am currently facing an issue while trying to control a Festo VTEM device via EtherCAT using the C++ SDK provided by Bosch Rexroth. Below is the code snippet I am using

 

#include <stdio.h>
#include <map>
#include <iostream>
#include <chrono>
#include <thread>
#include <csignal>

#include "comm/datalayer/datalayer.h"
#include "comm/datalayer/datalayer_system.h"
#include "comm/datalayer/memory_map_generated.h"

static bool g_endProcess = false;
static void signalHandler(int signal)
{
  std::cout << "signal: " << signal << std::endl;
  g_endProcess = true;
}

int main(void)
{
  comm::datalayer::DlResult result;
  comm::datalayer::Variant data;
  comm::datalayer::Variant dataIn;
  comm::datalayer::DatalayerSystem datalayer;
  datalayer.start(false);

  std::signal(SIGINT, signalHandler);

  // First we have to open the realtimememory, reading the whole outputs.
  uint8_t* outData;
  std::cout << "Opening some realtime memory" << std::endl;
  std::shared_ptr<comm::datalayer::IMemoryUser> output;
  result = datalayer.factory()->openMemory(output, "fieldbuses/ethercat/master/instances/VTEM/realtime_data/output");
  if (comm::datalayer::STATUS_FAILED(result))
  {
    std::cout << "Open the memory failed with: " << result.toString() << std::endl;
  }

  // We can read the Inputs to get a Start trigger for example
  uint8_t* inData;
  std::cout << "Opening some realtime memory" << std::endl;
  std::shared_ptr<comm::datalayer::IMemoryUser> input;
  result = datalayer.factory()->openMemory(input, "fieldbuses/ethercat/master/instances/VTEM/realtime_data/input");
  if (comm::datalayer::STATUS_FAILED(result))
  {
    std::cout << "Open the memory failed with: " << result.toString() << std::endl;
  }

  do
  {
    std::cout << "Try to get MemoryMap" << std::endl;
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    result = output->getMemoryMap(data);
    std::cout << "Getting MemoryMap with: " << result.toString() << std::endl;
  } while (comm::datalayer::STATUS_FAILED(result) && !g_endProcess);

  return 0;
}

 

 

 

I can successfully open the memory input and output; however, when I attempt to read, get a map, or begin access, I encounter errors such as DL_RT_NOTOPEN or DL_RT_NOVALIDDATA (I will provide more details on this soon).

I have not initialized the Data Layer client as shown in the sample code provided in the SDK(https://github.com/boschrexroth/ctrlx-automation-sdk/tree/main/samples-cpp/datalayer.ecat.io). My reasons for not doing so are as follows:

  1. Since I am executing the program on the CtrlX Core, I believe it might not be necessary.
  2. Additionally, when I tried to add the client section, as shown in the sample code, I encountered the following error related to AppArmor when integrating with ROS2:
    AVC apparmor="DENIED" operation="mknod" profile="snap.ros2-vtem-datalayer-monitor.datalayerMonitor" name="/dev/shm/fastrtps_c50f8f0c6a04a86c" pid=65979 comm="datalayerMonito" requested_mask="c" denied_mask="c" fsuid=0 ouid=0

I would appreciate any guidance or suggestions on resolving these issues and whether initializing the client is necessary for my specific setup.

Thank you for your assistance, and please let me know if you require any further information to help diagnose the problem.

 

 

Best reply by nickH

Hi Vishnuprasad Prachandabhanu,

The problem might be, that your fieldbus is not running when you are trying to access the RT-data. After you installed your snap you have to switch back into operating mode, so your fieldbus (EtherCAT) gets switched into "Running". 

Please have a look into this Post. This blog-poster had a similar problem. (Note: but you don't have to deactivate the watchdog since you don't run in sync with the scheduler)

Best regards, 

Nick

View original
3 replies