Hello all,
I have been trying to jog the motors via the sdk. i have the x axis in the status standstill. So if i read the docummentation correctly its now ready to recieve move commands. The problem is that i dont know how i need to declare and implement the axisjogcmd. This is done true the axis commands not the kinematic group. I added the code below. It gives a error about MotionResult not being declared.Â
Â
 Thanks in advance
#include <functional>
#include <thread>
#include <limits>
Â
#include "ctrlx_datalayer_helper.h"
#include "datalayerclient.h"
Â
#include <stdio.h>
#include <iostream>
using namespace std;
Â
Â
static void printStringList(comm::datalayer::Variant& data)
{
  if (data.getType() == comm::datalayer::VariantType::ARRAY_OF_STRING)
  {
    std::cout << "Node List: ";
    const char** strArray = data;
    for (uint32_t i = 0; i < data.getCount(); i++)
    {
      std::cout << strArray[i] << " ";
    }
    std::cout << std::endl;
  }
}
static void printMetadata(comm::datalayer::Variant& data)
{
  if (STATUS_FAILED(data.verifyFlatbuffers(comm::datalayer::VerifyMetadataBuffer)))
  {
    std::cout << "Invalid Flatbuffer: Not a MetadataBuffer";
    return;
  }
Â
  auto metadata = comm::datalayer::GetMetadata(data.getData());
  std::cout << metadata->displayName()->c_str() << std::endl;
  std::cout << metadata->displayFormat() << std::endl;
  std::cout << metadata->description()->c_str() << std::endl;
  std::cout << metadata->descriptionUrl()->c_str() << std::endl;
Â
  auto operations = metadata->operations();
  std::cout << "AllowedOperations: read=" << operations->read() << " write:" << operations->write() << " create:" << operations->create() << " delete:" << operations->delete_() << std::endl;
Â
  auto references = metadata->references();
  for (flatbuffers::uoffset_t i = 0; i < references->size(); i++)
  {
    std::cout << references->Get(i)->type()->c_str() << std::endl;
    std::cout << references->Get(i)->targetAddress()->c_str() << std::endl;
  }
}
DataLayerClient::DataLayerClient(const std::string& ip, const std::string& user, const std::string& password, int sslPort)
  : m_ip(ip)
  , m_user(user)
  , m_password(password)
  , m_sslPort(sslPort)
  , m_client(nullptr)
{}
Â
Â
bool DataLayerClient::start()
{
  std::cout << "m_datalayer.start(..)" << std::endl;
  m_datalayerSystem.start(false);
Â
  m_client = getClient(m_datalayerSystem, m_ip, m_user, m_password, m_sslPort);
Â
  return m_client != nullptr && m_client->isConnected();
}
Â
Â
comm::datalayer::IClient::ResponseCallback DataLayerClient::responseCallback()
{
  // [&]   All needed symbols are provided per reference
   // (...) Parameter provided by the calling site
  return [&](comm::datalayer::DlResult result, const comm::datalayer::Variant* data)
    {
      m_resultAsync = result;
      if (data != nullptr)
      {
        // data must not be nullptr otherwise the '=' operator crashes
        m_dataAsync = *data;
Â
        if (m_dataAsync.getType() == comm::datalayer::VariantType::ARRAY_OF_STRING)
        {
          printStringList(m_dataAsync);
        }
      }
Â
      std::cout << "ResponseCallback: " << std::string(result.toString()) << std::endl;
    };
}
Â
bool DataLayerClient::waitForResponseCallback(int counter)
{
  for (;;)
  {
    if (counter > 0)
    {
      counter--;
      if (counter <= 0)
      {
        return false;
      }
    }
Â
    //sleep(1);
Â
    if (m_resultAsync != -1)
    {
      std::cout << "ResponseCallback finished: " << m_resultAsync.toString() << std::endl;
      return true;
    }
  }
}
Â
Â
void DataLayerClient::ping()
{
  std::cout << "ping" << std::endl;
  m_result = m_client->pingSync();
  std::cout << "m_client->pingSync() " << m_result.toString() << std::endl;
Â
  m_resultAsync = -1;
  m_result = m_client->pingAsync(responseCallback());
  waitForResponseCallback(10);
}
Â
//"fieldbuses/ethercat/master/instances/ethercatmaster/realtime_data/input/data/ctrlX_DRIVE_XCS_SoE_X/AT.Position_feedback_value_1"
void DataLayerClient::readSync(const std::string& node)
{
  std::string address = node;
  m_result = m_client->readSync(address, &m_data);
  // std::cout << ("readSync() " + address) << endl;
   cout << int32_t(m_data) << endl;
}
Â
void DataLayerClient::writeSync(const std::string& node)
{
  auto address = "motion/kin/Kinematics/cmd/group-ena";
  m_result = m_client->writeSync(address, &m_data);
  cout << m_result.toString() << endl;
}
Â
Â
void DataLayerClient::write()
{
  m_data.setValue(true);
  writeSync("bool8");
Â
  m_data.setValue(-0.123456789f);
  writeSync("float32");
Â
  m_data.setValue(-0.987654321);
  writeSync("float64");
Â
  m_data.setValue((int8_t)-127);
  writeSync("int8");
Â
  m_data.setValue((int16_t)-32767);
  writeSync("int16");
Â
  m_data.setValue((int32_t)0x80000001);
  writeSync("int32");
Â
  m_data.setValue((int64_t)0x8000000000000001);
  writeSync("int64");
Â
  m_data.setValue("Changed by cpp ctrlX Data Layer Client");
  writeSync("string");
}
Â
void DataLayerClient::createSync(const std::string& node)
{
  std::string address = node;
  m_client->removeSync(address); // First remove - may be node exists
  m_result = m_client->createSync(address, &m_data);
  cout << m_result.toString() << endl;
}
Â
Â
Â
void DataLayerClient::stop()
{
  delete m_client;
  m_client = nullptr;
}
Â
Â
int main() {