21 , pdoTypeEnum_(pdoTypeEnum)
43 std::lock_guard<std::recursive_mutex> lock(
mutex_);
90 std::lock_guard<std::recursive_mutex> lock(
mutex_);
94 serialNumber =
static_cast<unsigned int>(serial_number);
95 ROS_DEBUG(
"[%s] Reading serial number: %u",
name_.c_str(), serialNumber);
101 std::lock_guard<std::recursive_mutex> lock(
mutex_);
105 samplingRate =
static_cast<int>(sampling_rate);
106 ROS_DEBUG(
"[%s] Force/Torque sampling rate: %d Hz",
name_.c_str(), samplingRate);
112 std::lock_guard<std::recursive_mutex> lock(
mutex_);
134 std::lock_guard<std::recursive_mutex> lock(
mutex_);
135 ROS_DEBUG(
"[%s] Setting acceleration filter: %u",
name_.c_str(), filter);
143 std::lock_guard<std::recursive_mutex> lock(
mutex_);
144 ROS_DEBUG(
"[%s] Setting angular rate filter: %u",
name_.c_str(), filter);
152 std::lock_guard<std::recursive_mutex> lock(
mutex_);
153 ROS_DEBUG(
"[%s] Setting acceleration range: %u",
name_.c_str(), range);
161 std::lock_guard<std::recursive_mutex> lock(
mutex_);
162 ROS_DEBUG(
"[%s] Setting angular rate range: %u",
name_.c_str(), range);
170 std::lock_guard<std::recursive_mutex> lock(
mutex_);
171 ROS_DEBUG_STREAM(
"[" <<
name_.c_str() <<
"] Setting Force/Torque offset: " << forceTorqueOffset << std::endl);
174 static_cast<float>(forceTorqueOffset(0, 0)));
176 static_cast<float>(forceTorqueOffset(1, 0)));
178 static_cast<float>(forceTorqueOffset(2, 0)));
180 static_cast<float>(forceTorqueOffset(3, 0)));
182 static_cast<float>(forceTorqueOffset(4, 0)));
184 static_cast<float>(forceTorqueOffset(5, 0)));
190 std::lock_guard<std::recursive_mutex> lock(
mutex_);
217 std::lock_guard<std::recursive_mutex> lock(
mutex_);
264 std::this_thread::sleep_for(std::chrono::milliseconds(500));
267 ROS_ERROR(
"[%s] Slave failed to switch to PREOP state",
name_.c_str());
282 std::lock_guard<std::recursive_mutex> lock(
mutex_);
285 uint8_t retain_configuration = 0x01;
291 ROS_ERROR(
"[%s] Could not save configuration parameters on device. Status value is: %u",
name_.c_str(), status);
299 std::lock_guard<std::recursive_mutex> lock(
mutex_);
305 std::lock_guard<std::recursive_mutex> lock(
mutex_);
318 std::lock_guard<std::recursive_mutex> lock(
mutex_);
324 std::lock_guard<std::recursive_mutex> lock(
mutex_);
331 std::lock_guard<std::recursive_mutex> lock(
mutex_);
337 std::lock_guard<std::recursive_mutex> lock(
mutex_);
364 std::ifstream file(filePath, std::ios::binary);
365 std::string file_buffer;
369 while ((ch = file.get()) != std::istream::traits_type::eof())
371 file_buffer.push_back(static_cast<char>(ch));
373 fileBuffer_ =
const_cast<char*
>(file_buffer.c_str());
374 fileSize_ =
static_cast<int>(file_buffer.size());
385 <<
"Failed to open file " << filePath);
389 <<
"The firmware was read successfully. Size of file buffer: " <<
fileSize_);
397 std::lock_guard<std::recursive_mutex> lock(
mutex_);
401 <<
"Could not read file in path " << filePath <<
".");
uint8_t getChopEnable() const
bool setAccelerationRange(const unsigned int range)
Sets an acceleration range to the device.
bool setAngularRateRange(const unsigned int range)
Sets an angular rate range to the device.
bool firmwareUpdate(const std::string &filePath, const std::string &fileName, const uint32_t &password)
Updates the firmware of the device.
#define OD_SENSOR_CONFIGURATION_SID_CALIBRATION_MATRIX_ACTIVE
void updateRead() override
This method is called by the EthercatBusManager. Each device attached to this bus reads its data from...
bool getForceTorqueSamplingRate(int &samplingRate)
Gets the force torque sampling rate of the device.
bool getSerialNumber(unsigned int &serialNumber)
Accessor for device serial number.
const WrenchType & getWrench() const
#define OD_IDENTITY_SID_SERIAL_NUMBER
void readTxPdo(const uint16_t slave, TxPdo &txPdo) const
#define OD_TX_PDO_ID_VAL_A
RokubiminiEthercatSlave()=delete
Default constructor is deleted.
void getReading(rokubimini::Reading &reading) const
Gets the internal reading variable.
std::atomic< PdoTypeEnum > currentPdoTypeEnum_
Current PDO type.
Base class for generic ethercat slaves using soem.
uint8_t getTemperatureCompensationActive() const
#define OD_ANGULAR_RATE_RANGE_ID
float estimatedOrientationY_
bool isRunning()
Returns if the instance is running.
float estimatedOrientationZ_
bool writeFirmware(const uint16_t slave, const std::string &fileName, const uint32_t &password, const int fileSize, char *fileBuffer)
int fileSize_
The size of the file.
#define OD_SENSOR_CONFIGURATION_ID
uint32_t warningsErrorsFatals_
bool sendSdoRead(const uint16_t index, const uint8_t subindex, const bool completeAccess, Value &value)
void updateWrite() override
This method is called by the EthercatBusManager. Each device attached to the bus writes its data to t...
#define OD_FORCE_TORQUE_FILTER_SID_SINC_SIZE
#define OD_SAMPLING_RATE_ID
void shutdown() override
Shuts down the device.
bool setSensorConfiguration(const configuration::SensorConfiguration &sensorConfiguration)
Sets a sensor configuration to the device.
#define OD_SENSOR_CONFIGURATION_SID_ORIENTATION_ESTIMATION
uint8_t getInertiaCompensationActive() const
bool configurePdo(const PdoTypeEnum pdoTypeEnum)
Configures a PDO in the Ethercat device.
bool setAccelerationFilter(const unsigned int filter)
Sets an acceleration filter to the device.
#define OD_SENSOR_CONFIGURATION_SID_IMU_ACTIVE
#define MAX_FILE_SIZE_FIRMWARE
bool readFileToBuffer(const std::string &filePath)
Reads the contents of a file to an internal buffer.
std::recursive_mutex mutex_
#define OD_CONTROL_SID_STATUS
bool setAngularRateFilter(const unsigned int filter)
Sets an angular rate filter to the device.
PdoInfos pdoInfos_
Map between PDO types and their infos.
bool setRunMode()
Sets the device in run mode.
#define OD_CONTROL_SID_COMMAND
uint8_t getFastEnable() const
#define OD_FORCE_TORQUE_FILTER_SID_FIR_DISABLE
void setState(const uint16_t state, const uint16_t slave=0)
uint8_t getSkipEnable() const
#define OD_FORCE_TORQUE_FILTER_ID
uint8_t getCoordinateSystemConfigurationActive() const
PdoTypeEnum getCurrentPdoTypeEnum() const
Accessor for the current PDO type.
bool saveConfigParameter()
Saves the current configuration to the device.
#define OD_ACCELERATION_RANGE_ID
#define OD_SENSOR_FORCE_TORQUE_OFFSET_SID_1
char * fileBuffer_
The buffer to save the contents of the file.
void setStatusword(const Statusword &statusword)
void setState(const uint16_t state)
Sets the desired EtherCAT state machine state of the device in the bus.
const uint32_t getPassPhrase() const
#define OD_FORCE_TORQUE_FILTER_SID_CHOP_ENABLE
const ros::Time & getUpdateReadStamp() const
void setForceTorqueSaturated(const bool isForceTorqueSaturated)
#define OD_RX_PDO_ID_VAL_A
#define OD_SENSOR_FORCE_TORQUE_OFFSET_SID_3
bool waitForState(const uint16_t state)
Wait for an EtherCAT state machine state to be reached.
std::atomic< PdoTypeEnum > pdoTypeEnum_
#define ROS_DEBUG_STREAM(args)
bool setForceTorqueOffset(const Eigen::Matrix< double, 6, 1 > &forceTorqueOffset)
Sets a force torque offset to the device.
bool sendCalibrationMatrixEntry(const uint8_t subId, const double entry)
Sends a calibration matrix entry to device.
#define OD_SENSOR_FORCE_TORQUE_OFFSET_SID_6
bool waitForState(const uint16_t state, const uint16_t slave=0, const unsigned int maxRetries=40, const double retrySleep=0.001)
uint8_t getOrientationEstimationActive() const
PdoInfo getCurrentPdoInfo() const override
Accessor for the current PDO info.
static constexpr double G_TO_METERS_PER_SECOND_SQUARED
#define OD_SENSOR_FORCE_TORQUE_OFFSET_SID_2
float estimatedOrientationX_
uint16_t getSincFilterSize() const
#define OD_SENSOR_CONFIGURATION_SID_TEMPERATURE_COMPENSATION
#define OD_SENSOR_FORCE_TORQUE_OFFSET_SID_4
#define OD_SENSOR_CALIBRATION_ID
#define OD_SENSOR_FORCE_TORQUE_OFFSET_SID_5
bool setConfigMode()
Sets the device in config mode.
Struct defining the Pdo characteristic.
uint8_t getCalibrationMatrixActive() const
Class for managing an ethercat bus containing one or multiple slaves.
std::string getName() const override
Accessor for device name.
const TempType & getTemperature() const
#define OD_SENSOR_CONFIGURATION_SID_COORD_SYSTEM_CONFIGURATION
#define OD_FORCE_TORQUE_FILTER_SID_FAST_ENABLE
bool sendSdoWrite(const uint16_t index, const uint8_t subindex, const bool completeAccess, const Value value)
#define OD_ACCELERATION_FILTER_ID
#define ROS_ERROR_STREAM(args)
#define OD_ANGULAR_RATE_FILTER_ID
#define OD_SENSOR_FORCE_TORQUE_OFFSET_ID
#define OD_SENSOR_CONFIGURATION_SID_INERTIA_COMPENSATION
float estimatedOrientationW_
bool setForceTorqueFilter(const configuration::ForceTorqueFilter &filter)
Sets a force torque filter to the device.
void writeRxPdo(const uint16_t slave, const RxPdo &rxPdo)
const Eigen::Matrix< double, 6, 6 > & getCalibrationMatrix() const
const std::string name_
Name of the sensor.
uint8_t getImuActive() const
const ImuType & getImu() const
bool startup() override
This method starts up and initializes the device.
bool setSensorCalibration(const calibration::SensorCalibration &sensorCalibration)
Sets a sensor calibration to the device.
Reading reading_
The internal reading variable. It's used for providing to client code the sensor readings, through the getReading () function.
std::atomic< bool > isRunning_
Internal flag to indicate if the instance is running.
static constexpr double DEG_TO_RAD
uint16_t forceTorqueSaturated_