@@ -25,10 +25,10 @@ void OdriveMotor::prepareActuation()
2525}
2626
2727// to be implemented
28- void OdriveMotor::reset ()
29- {
30- return ;
31- }
28+ void OdriveMotor::reset ()
29+ {
30+ return ;
31+ }
3232
3333void OdriveMotor::actuateRad (double target_rad)
3434{
@@ -38,32 +38,31 @@ void OdriveMotor::actuateRad(double target_rad)
3838
3939void OdriveMotor::actuateTorque (double target_torque_ampere)
4040{
41- float target_torque_ampere_float = (float ) target_torque_ampere;
42- std::string command_name_ = this ->create_command (O_PM_DESIRED_MOTOR_CURRENT);
43- if (this ->write (command_name_, target_torque_ampere_float) == 1 )
44- {
45- ROS_ERROR (" Could net set target torque; %f to the axis" , target_torque_ampere);
46- }
41+ float target_torque_ampere_float = (float )target_torque_ampere;
42+ std::string command_name_ = this ->create_command (O_PM_DESIRED_MOTOR_CURRENT);
43+ if (this ->write (command_name_, target_torque_ampere_float) == 1 )
44+ {
45+ ROS_ERROR (" Could net set target torque; %f to the axis" , target_torque_ampere);
46+ }
4747}
4848
4949MotorControllerStates& OdriveMotor::getStates ()
5050{
51- static OdriveStates states;
52-
53- // Common states
54- states.motorCurrent = this ->getMotorCurrent ();
55- states.controllerVoltage = this ->getMotorControllerVoltage ();
56- states.motorVoltage = this ->getMotorVoltage ();
51+ static OdriveStates states;
5752
58- states. absoluteEncoderValue = this -> getAngleCountsAbsolute ();
59- states.incrementalEncoderValue = this ->getAngleCountsIncremental ();
60- states.absoluteVelocity = this ->getVelocityRadAbsolute ();
61- states.incrementalVelocity = this ->getVelocityRadIncremental ();
53+ // Common states
54+ states.motorCurrent = this ->getMotorCurrent ();
55+ states.controllerVoltage = this ->getMotorControllerVoltage ();
56+ states.motorVoltage = this ->getMotorVoltage ();
6257
63- states.state = States (this ->getState ());
58+ states.absoluteEncoderValue = this ->getAngleCountsAbsolute ();
59+ states.incrementalEncoderValue = this ->getAngleCountsIncremental ();
60+ states.absoluteVelocity = this ->getVelocityRadAbsolute ();
61+ states.incrementalVelocity = this ->getVelocityRadIncremental ();
6462
65- return states ;
63+ states. state = States ( this -> getState ()) ;
6664
65+ return states;
6766}
6867
6968float OdriveMotor::getMotorControllerVoltage ()
@@ -114,13 +113,13 @@ double OdriveMotor::getTorque()
114113
115114int OdriveMotor::getAngleCountsAbsolute ()
116115{
117- return 0 ;
116+ return 0 ;
118117}
119118
120119double OdriveMotor::getAngleRadAbsolute ()
121120{
122- double angle_rad = this ->getAngleCountsAbsolute () * PI_2 / std::pow (2 , 17 );
123- return angle_rad;
121+ double angle_rad = this ->getAngleCountsAbsolute () * PI_2 / std::pow (2 , 17 );
122+ return angle_rad;
124123}
125124
126125double OdriveMotor::getVelocityRadAbsolute ()
@@ -135,14 +134,14 @@ bool OdriveMotor::getIncrementalMorePrecise() const
135134
136135int OdriveMotor::getAngleCountsIncremental ()
137136{
138- float iu_position;
139- std::string command_name_ = this ->create_command (O_PM_ENCODER_POSITION_UI);
140- if (this ->read (command_name_, iu_position) == 1 )
141- {
142- ROS_ERROR (" Could not retrieve incremental position of the encoder" );
143- return ODRIVE_ERROR;
144- }
145- return iu_position;
137+ float iu_position;
138+ std::string command_name_ = this ->create_command (O_PM_ENCODER_POSITION_UI);
139+ if (this ->read (command_name_, iu_position) == 1 )
140+ {
141+ ROS_ERROR (" Could not retrieve incremental position of the encoder" );
142+ return ODRIVE_ERROR;
143+ }
144+ return iu_position;
146145}
147146
148147double OdriveMotor::getAngleRadIncremental ()
0 commit comments