78 for (
unsigned int i = 0; i < 4096; i++) {
117 LOG(
trace) <<
"automatic send is not possible if the EtherCAT master has no thread";
125 LOG(
trace) <<
"automatic receive is not possible if the EtherCAT master has no thread";
135 for (
unsigned int i = 0; i < ethercatSlaveInfos.size(); i++) {
136 ethercatSlaveInfos[i].inputs = NULL;
137 ethercatSlaveInfos[i].outputs = NULL;
153 if (ec_send_processdata() == 0) {
214 LOG(
trace) << ec_slavecount <<
" EtherCAT slaves found and configured.";
249 LOG(
warning) <<
"Not all EtherCAT slaves reached safe operational state.";
252 for (
int i = 1; i <= ec_slavecount; i++) {
254 LOG(
info) <<
"Slave " << i <<
" State=" << ec_slave[i].state <<
" StatusCode=" << ec_slave[i].ALstatuscode <<
" : " <<
ec_ALstatuscode2string(ec_slave[i].ALstatuscode);
264 LOG(
trace) <<
"Request operational state for all EtherCAT slaves";
269 ec_send_processdata();
277 LOG(
trace) <<
"Operational state reached for all EtherCAT slaves.";
279 throw std::runtime_error(
"Not all EtherCAT slaves reached operational state.");
284 throw std::runtime_error(
"No EtherCAT slaves found!");
288 throw std::runtime_error(
"No socket connection on " +
ethernetDevice +
"\nExcecute as root");
293 std::string baseJointControllerName =
"TMCM-174";
294 std::string baseJointControllerNameAlternative =
"TMCM-1632";
295 std::string manipulatorJointControllerName =
"TMCM-174";
296 std::string ManipulatorJointControllerNameAlternative =
"TMCM-1610";
297 std::string actualSlaveName;
303 configfile->
readInto(baseJointControllerNameAlternative,
"BaseJointControllerNameAlternative");
304 configfile->
readInto(manipulatorJointControllerName,
"ManipulatorJointControllerName");
305 configfile->
readInto(ManipulatorJointControllerNameAlternative,
"ManipulatorJointControllerNameAlternative");
308 for (
int cnt = 1; cnt <= ec_slavecount; cnt++) {
309 LOG(
trace) <<
"Slave: " << cnt <<
" Name: " << ec_slave[cnt].name <<
" Output size: " << ec_slave[cnt].Obits
310 <<
"bits Input size: " << ec_slave[cnt].Ibits <<
"bits State: " << ec_slave[cnt].state
311 <<
" delay: " << ec_slave[cnt].pdelay;
315 actualSlaveName = ec_slave[cnt].name;
316 if ((actualSlaveName == baseJointControllerName || actualSlaveName == baseJointControllerNameAlternative ||
317 actualSlaveName == manipulatorJointControllerName || actualSlaveName == ManipulatorJointControllerNameAlternative
318 ) && ec_slave[cnt].Obits > 0 && ec_slave[cnt].Ibits > 0) {
334 throw std::runtime_error(
"No EtherCAT slave could be found");
444 std::stringstream errorMessageStream;
445 errorMessageStream <<
" ";
446 std::string errorMessage;
447 errorMessage = errorMessageStream.str();
451 LOG(
error) << errorMessage <<
"got over current";
456 LOG(
error) << errorMessage <<
"got under voltage";
461 LOG(
error) << errorMessage <<
"got over voltage";
466 LOG(
error) << errorMessage <<
"got over temperature";
476 LOG(
error) << errorMessage <<
"got hall sensor problem";
531 LOG(
error) << errorMessage <<
"has a timeout";
536 LOG(
error) << errorMessage <<
"exceeded I2t";
Headerfile for ethercatdc.c.
void registerJointLimitMonitor(JointLimitMonitor *object, const unsigned int JointNumber)
ec_mbxbuft mailboxBufferReceive
~EthercatMasterWithoutThread()
bool receiveProcessData()
unsigned int getNumberOfSlaves() const
return the quantity of ethercat slave which have an input/output buffer
Output part from the EtherCat message of the youBot EtherCat slaves.
std::vector< YouBotSlaveMailboxMsg > firstMailboxBufferVector
bool closeEthercat()
closes the ethercat connection
Reads and writes a configuration file.
void setMsgBuffer(const YouBotSlaveMsg &msgBuffer, const unsigned int jointNumber)
std::string ethernetDevice
void AutomaticSendOn(const bool enableAutomaticSend)
bool ethercatConnectionEstablished
mailboxInputBuffer stctInput
static std::string configFileName
unsigned int ethercatTimeout
General typedefs and defines for EtherCAT.
Headerfile for ethercatcoe.c.
std::vector< ec_slavet > ethercatSlaveInfo
std::vector< YouBotSlaveMsg > processDataBuffer
mailboxOutputBuffer stctOutput
EthercatMasterWithoutThread(const std::string &configFile, const std::string &configFilePath)
bool receiveMailboxMessage(YouBotSlaveMailboxMsg &mailboxMsg)
ec_mbxbuft mailboxBufferSend
bool isErrorInSoemDriver()
std::vector< SlaveMessageInput * > ethercatInputBufferVector
bool sendMailboxMessage(const YouBotSlaveMailboxMsg &mailboxMsg)
bool readInto(T &var, const string &key) const
It monitors the joint position and will decelerate and stop the joint if it is close the limits...
EtherCAT mailbox message of the youBot slaves.
void setMailboxMsgBuffer(const YouBotSlaveMailboxMsg &msgBuffer, const unsigned int jointNumber)
void initializeEthercat()
establishes the ethercat connection
SlaveMessageInput stctInput
std::vector< SlaveMessageOutput * > ethercatOutputBufferVector
void parseYouBotErrorFlags(const YouBotSlaveMsg &messageBuffer)
Headerfile for ethercatbase.c.
bool isEtherCATConnectionEstablished()
SlaveMessageOutput stctOutput
Headerfile for ethercatmain.c.
void getEthercatDiagnosticInformation(std::vector< ec_slavet > ðercatSlaveInfos)
unsigned int mailboxTimeout
bool getMailboxMsgBuffer(YouBotSlaveMailboxMsg &mailboxMsg, const unsigned int jointNumber)
void AutomaticReceiveOn(const bool enableAutomaticReceive)
static std::string configFilepath
EtherCat message of the youBot EtherCat slaves.
Headerfile for ethercatconfig.c.
Headerfile for ethercatprint.c.
char * ec_ALstatuscode2string(uint16 ALstatuscode)
void getMsgBuffer(const unsigned int jointNumber, YouBotSlaveMsg &returnMsg)