@@ -391,6 +391,141 @@ int Odrive::setConfigurations(const std::string& configuration_json_path)
391391 return ODRIVE_OK
392392}
393393
394+ uint16_t Odrive::readAxisError ()
395+ {
396+ uint16_t axis_error;
397+ std::string command_name_ = this ->create_command (O_PM_AXIS_ERROR);
398+ if (this ->read (command_name_, axis_error) == 1 )
399+ {
400+ ROS_ERROR (" Could not retrieve axis error" );
401+ return ODRIVE_ERROR;
402+ }
403+
404+ return axis_error;
405+ }
406+
407+ uint16_t Odrive::readAxisMotorError ()
408+ {
409+ uint16_t axis_motor_error;
410+ std::string command_name_ = this ->create_command (O_PM_AXIS_MOTOR_ERROR);
411+ if (this ->read (command_name_, axis_motor_error) == 1 )
412+ {
413+ ROS_ERROR (" Could not retrieve axis motor error" );
414+ return ODRIVE_ERROR;
415+ }
416+
417+ return axis_motor_error;
418+ }
419+
420+ uint8_t Odrive::readAxisEncoderError ()
421+ {
422+ uint8_t axis_encoder_error;
423+ std::string command_name_ = this ->create_command (O_PM_AXIS_ENCODER_ERROR);
424+ if (this ->read (command_name_, axis_encoder_error) == 1 )
425+ {
426+ ROS_ERROR (" Could not retrieve axis encoder error" );
427+ return ODRIVE_ERROR;
428+ }
429+
430+ return axis_encoder_error;
431+ }
432+
433+ uint8_t Odrive::readAxisControllerError ()
434+ {
435+ uint8_t axis_controller_error;
436+ std::string command_name_ = this ->create_command (O_PM_AXIS_CONTROLLER_ERROR);
437+ if (this ->read (command_name_, axis_controller_error) == 1 )
438+ {
439+ ROS_ERROR (" Could not retrieve axis controller error" );
440+ return ODRIVE_ERROR;
441+ }
442+
443+ return axis_controller_error;
444+ }
445+
446+ float Odrive::readMotorControllerVoltage ()
447+ {
448+ float motor_controller_voltage;
449+ std::string command_name_ = this ->create_command (O_PM_ODRIVE_INPUT_VOLTAGE);
450+ if (this ->read (command_name_, motor_controller_voltage) == 1 )
451+ {
452+ ROS_ERROR (" Could not retrieve motor controller voltage" );
453+ return ODRIVE_ERROR;
454+ }
455+ return motor_controller_voltage;
456+ }
457+
458+ float Odrive::readMotorCurrent ()
459+ {
460+ float motor_current;
461+ std::string command_name_ = this ->create_command (O_PM_ACTUAL_MOTOR_CURRENT);
462+ if (this ->read (command_name_, motor_current) == 1 )
463+ {
464+ ROS_ERROR (" Could not retrieve motor current" );
465+ return ODRIVE_ERROR;
466+ }
467+
468+ return motor_current;
469+ }
470+
471+ float Odrive::readMotorVoltage ()
472+ {
473+ float motor_voltage;
474+ std::string command_name_ = this ->create_command (O_PM_ACTUAL_MOTOR_VOLTAGE_D);
475+ if (this ->read (command_name_, motor_voltage) == 1 )
476+ {
477+ ROS_ERROR (" Could not retrieve motor voltage" );
478+ return ODRIVE_ERROR;
479+ }
480+
481+ return motor_voltage;
482+ }
483+
484+ int Odrive::readAngleCountsAbsolute ()
485+ {
486+ return 0 ;
487+ }
488+
489+ double Odrive::readVelocityRadAbsolute ()
490+ {
491+ return 0 ;
492+ }
493+
494+ int Odrive::readAngleCountsIncremental ()
495+ {
496+ float iu_position;
497+ std::string command_name_ = this ->create_command (O_PM_ENCODER_POSITION_UI);
498+ if (this ->read (command_name_, iu_position) == 1 )
499+ {
500+ ROS_ERROR (" Could not retrieve incremental position of the encoder" );
501+ return ODRIVE_ERROR
502+ }
503+ return iu_position;
504+ }
505+
506+ double Odrive::readVelocityRadIncremental ()
507+ {
508+ float iu_velocity;
509+ std::string command_name_ = this ->create_command (O_PM_ENCODER_VELOCITY_UI);
510+ if (this ->read (command_name_, iu_velocity) == 1 )
511+ {
512+ ROS_ERROR (" Could not retrieve incremental velocity of the encoder" );
513+ return ODRIVE_ERROR
514+ }
515+
516+ double angle_rad = iu_velocity * PI_2 / (std::pow (2 , 12 ) * 101 );
517+ return angle_rad;
518+ }
519+
520+ std::string Odrive::create_command (std::string command_name)
521+ {
522+ if (command_name.at (0 ) == ' .' )
523+ {
524+ return this ->axis_number + command_name;
525+ }
526+ return command_name;
527+ }
528+
394529template int Odrive::validateType (const odrive_json_object& json_object, int8_t &);
395530template int Odrive::validateType (const odrive_json_object& json_object, int16_t &);
396531template int Odrive::validateType (const odrive_json_object& json_object, int32_t &);
0 commit comments