Skip to content

Commit 1a89e06

Browse files
committed
Round commanded force.
1 parent 65b7388 commit 1a89e06

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

ign_ros2_control/src/ign_system.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,9 @@ hardware_interface::return_type IgnitionSystem::write(
889889
position_error, std::chrono::duration<double>(
890890
period.to_chrono<std::chrono::nanoseconds>()));
891891

892-
// remember for potential effort state interface
892+
target_force = round(target_force * 10000.0)/10000.0;
893+
894+
// remember for potential effort state interface
893895
this->dataPtr->joints_[i].joint_effort_cmd = target_force;
894896

895897
auto forceCmd =
@@ -944,6 +946,8 @@ hardware_interface::return_type IgnitionSystem::write(
944946
mimic_joint.multiplier, jointAxis->Data().Lower(),
945947
jointAxis->Data().Upper());
946948

949+
position_error = round(position_error * 10000.0)/10000.0;
950+
947951
position_error =
948952
copysign(
949953
1.0,
@@ -952,7 +956,9 @@ hardware_interface::return_type IgnitionSystem::write(
952956
std::abs(position_error), 0.0,
953957
std::abs(jointAxis->Data().Upper() - jointAxis->Data().Lower()));
954958

955-
// calculate target velocity - output of outer pid - input to inner pid
959+
960+
961+
// calculate target velocity - output of outer pid - input to inner pid
956962
double target_vel = this->dataPtr->joints_[mimic_joint.joint_index].pid_pos.Update(
957963
position_error, std::chrono::duration<double>(
958964
period.to_chrono<std::chrono::nanoseconds>()));
@@ -974,6 +980,8 @@ hardware_interface::return_type IgnitionSystem::write(
974980
position_error, std::chrono::duration<double>(
975981
period.to_chrono<std::chrono::nanoseconds>()));
976982

983+
target_force = round(target_force * 10000.0)/10000.0;
984+
977985
this->dataPtr->joints_[mimic_joint.joint_index].joint_effort_cmd = target_force;
978986

979987
auto forceCmd =

0 commit comments

Comments
 (0)