void CRemoteInterface::update() { if (motorControl.update) { updateMotorControl(); motorControl.update = false; } const uint32_t curtime = millis(); if (curtime > statusSendDelay) { statusSendDelay = curtime + 500; sendStatus(); } if (REM_SERIAL.available()) checkForCommands(); }
fmMsgs::can AES25::processCanTxEvent() { static int canToggle = 0; updateMotorControl(); // Alternate between sending 200h and 300h command // to get status return. if (canToggle == 0) { aes_tx_msg_.id = 0x200; aes_tx_msg_.header.stamp = ros::Time::now(); aes_tx_msg_.length = 8; canToggle++; } else { aes_tx_msg_.id = 0x300; aes_tx_msg_.header.stamp = ros::Time::now(); aes_tx_msg_.length = 8; canToggle = 0; } aes_tx_msg_.data[0] = motorSetSpeed.byte[0]; aes_tx_msg_.data[1] = motorSetSpeed.byte[1]; aes_tx_msg_.data[2] = motorSetAngle.byte[0]; aes_tx_msg_.data[3] = motorSetAngle.byte[1]; aes_tx_msg_.data[4] = motorControlBits_; aes_tx_msg_.data[5] = motorSetTorque.byte[0]; aes_tx_msg_.data[6] = 0; aes_tx_msg_.data[7] = motorSetParameter_; if (controllerInfo_[INDEX_CAN_TIMEOUT_TICKS] > 0) { controllerInfo_[INDEX_CAN_TIMEOUT_TICKS]--; // Reset Controller if we lose CAN if (controllerInfo_[INDEX_CAN_TIMEOUT_TICKS] == 0) { ROS_ERROR("AES25 watchdog timeout!"); resetControllerVariables(); } } return aes_tx_msg_; }