Skip to content
This repository was archived by the owner on Dec 1, 2020. It is now read-only.

Commit 7709c41

Browse files
committed
Fix some bugs
1 parent ef4aaf9 commit 7709c41

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

march_hardware/config/march_odrive.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
{
88
"name":"axis0.encoder.config.cpr",
9-
"type":"uint32",
9+
"type":"int32",
1010
"value":4096
1111
},
1212
{
@@ -21,7 +21,7 @@
2121
},
2222
{
2323
"name":"axis0.motor.config.pole_pairs",
24-
"type":"uint32",
24+
"type":"int32",
2525
"value":21
2626
},
2727
{
@@ -57,7 +57,7 @@
5757
{
5858
"name":"axis0.motor.config.direction",
5959
"type":"int32",
60-
"value":1
60+
"value":0
6161
},
6262
{
6363
"name":"axis0.sensorless_estimator.config.pm_flux_linkage",

march_hardware/include/march_hardware/joint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Joint
5050
void prepareActuation();
5151

5252
void actuateRad(double target_position);
53-
void actuateTorque(int16_t target_torque);
53+
void actuateTorque(double target_torque);
5454
void readEncoders(const ros::Duration& elapsed_time);
5555

5656
double getPosition() const;

march_hardware/src/joint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ double Joint::getAbsolutePosition() const
141141
return this->absolute_position_;
142142
}
143143

144-
void Joint::actuateTorque(int16_t target_torque)
144+
void Joint::actuateTorque(double target_torque)
145145
{
146146
if (!this->canActuate())
147147
{

march_hardware/src/odrive/odrive_motor.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ void OdriveMotor::actuateTorque(double target_torque_ampere)
111111
float target_torque_ampere_float = (float)target_torque_ampere;
112112
ROS_INFO("target torque: %f", target_torque_ampere_float);
113113

114-
if (target_torque_ampere_float < 3.0)
115-
{
116-
target_torque_ampere_float = 3.0;
117-
}
118114
std::string command_name_ = this->create_command(O_PM_DESIRED_MOTOR_CURRENT);
119115
if (this->write(command_name_, target_torque_ampere_float) == 1)
120116
{
@@ -219,6 +215,8 @@ float OdriveMotor::getMotorCurrent()
219215
return ODRIVE_ERROR;
220216
}
221217

218+
ROS_INFO("actual torque: %f", motor_current);
219+
222220
return motor_current;
223221
}
224222

@@ -272,13 +270,12 @@ int OdriveMotor::getAngleCountsIncremental()
272270
ROS_ERROR("Could not retrieve incremental position of the encoder");
273271
return ODRIVE_ERROR;
274272
}
275-
ROS_WARN("encoder position: %f", iu_position);
276273
return iu_position;
277274
}
278275

279276
double OdriveMotor::getAngleRadIncremental()
280277
{
281-
double angle_rad = this->getAngleCountsIncremental() * PI_2 / std::pow(2, 12);
278+
double angle_rad = this->getAngleCountsIncremental() * PI_2 / (std::pow(2, 12) * 101);
282279
return angle_rad;
283280
}
284281

@@ -292,7 +289,7 @@ double OdriveMotor::getVelocityRadIncremental()
292289
return ODRIVE_ERROR;
293290
}
294291

295-
double angle_rad = iu_velocity * PI_2 / std::pow(2, 12);
292+
double angle_rad = iu_velocity * PI_2 / (std::pow(2, 12) * 101);
296293
return angle_rad;
297294
}
298295

march_hardware_builder/include/march_hardware_builder/allowed_robot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class AllowedRobot
6767
}
6868
else if (this->value == AllowedRobot::test_joint_rotational)
6969
{
70-
return base_path.append("/robots/test_joint_rotational.yaml");
70+
return base_path.append("/robots/odrive_test_joint_rotational.yaml");
7171
}
7272
else if (this->value == AllowedRobot::odrive_test_joint_rotational)
7373
{

march_hardware_builder/robots/odrive_test_joint_rotational.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
testsetup:
2-
ifName: enp2s0
32
cycleTime: 4
43
slaveTimeout: 50
54
joints:

march_hardware_interface/src/march_hardware_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void MarchHardwareInterface::write(const ros::Time& /* time */, const ros::Durat
277277
}
278278
else if (joint.getActuationMode() == march::ActuationMode::torque)
279279
{
280-
joint.actuateTorque(std::round(joint_effort_command_[i]));
280+
joint.actuateTorque(joint_effort_command_[i]));
281281
}
282282
}
283283
}

0 commit comments

Comments
 (0)