Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
RobotAPI
Commits
5c77d08b
Commit
5c77d08b
authored
5 years ago
by
ArmarX User
Browse files
Options
Downloads
Patches
Plain Diff
fix torque estimation for gripper joint (type 16)
parent
bb8f18cf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/KITGripperEtherCAT/KITGripperBasisBoard/Misc/TorqueEstimation.cpp
+29
-31
29 additions, 31 deletions
...erEtherCAT/KITGripperBasisBoard/Misc/TorqueEstimation.cpp
with
29 additions
and
31 deletions
source/RobotAPI/libraries/KITGripperEtherCAT/KITGripperBasisBoard/Misc/TorqueEstimation.cpp
+
29
−
31
View file @
5c77d08b
#include
"TorqueEstimation.h"
#include
<math.h>
#include
<ArmarXCore/core/logging/Logging.h>
/* --------- !!! Do not change the following function for motor model "motor16" !!! ----------- */
float
MotorTorqueEstimator
::
linearModel_dcx16
(
int32_t
nI
,
int32_t
pwm
)
{
// 4096: ticks per turn
...
...
@@ -37,6 +39,7 @@ float MotorTorqueEstimator::linearModel_dcx16(int32_t nI, int32_t pwm)
return
T
;
}
/* --------- !!! the following function are not used anymore, instead use the neural network for "motor22" !!! ----------- */
float
MotorTorqueEstimator
::
linearModel_dcx22
(
float
nI
,
int32_t
pwm
)
{
float
n
=
nI
*
60.
f
/
M_PI
/
2.
f
*
231.
f
;
//rad/s -> turns/min
...
...
@@ -57,45 +60,31 @@ float MotorTorqueEstimator::linearModel_dcx22(float nI, int32_t pwm)
void
MotorTorqueEstimator
::
estimateTorque
(
float
vel
,
int32_t
pwm
)
//, int motorModel, bool linearModelOnly = false)
{
// calculate the torque based on the linear model
// std::cout << "model type: " << motorModel << std::endl;
if
(
motorModel
==
"Motor16"
)
{
torque
=
linearModel_dcx16
(
vel
,
pwm
);
}
else
if
(
motorModel
==
"Motor22"
)
{
torque
=
linearModel_dcx22
(
vel
,
pwm
);
}
else
{
//std::cout << "motor model should be set to 'Motor16' or 'Motor22'" << std::endl;
torque
=
0.0
;
}
torque
=
0.0
f
;
// calculate the torque induced by non-linear model
if
(
!
linearModelOnly
)
{
float
vel_input
=
(
float
)
vel
/
vel_factor
;
float
pwm_input
=
(
float
)
pwm
/
pwm_factor
;
static
float
pwmXvel_old
=
0
;
//
static float pwmXvel_old = 0;
float
pwmXvel
=
vel_input
*
pwm_input
;
if
(
pwmXvel
<
0
)
{
pwmXvel
=
-
1
;
pwmXvel_old
=
pwmXvel
;
}
else
if
(
pwmXvel
>
0
)
{
pwmXvel
=
1
;
pwmXvel_old
=
pwmXvel
;
}
else
{
pwmXvel
=
pwmXvel_old
;
}
//
if (pwmXvel < 0)
//
{
//
pwmXvel = -1;
//
pwmXvel_old = pwmXvel;
//
}
//
else if (pwmXvel > 0)
//
{
//
pwmXvel = 1;
//
pwmXvel_old = pwmXvel;
//
}
//
else
//
{
//
pwmXvel = pwmXvel_old;
//
}
torque
+=
network
->
feedforward
(
vel_input
,
pwm_input
,
pwmXvel
);
// torque += network->feedforward(vel_input, pwm_input, 0.0f);
}
/*// calculating the torque induced by motor inertia
...
...
@@ -109,5 +98,14 @@ void MotorTorqueEstimator::estimateTorque(float vel, int32_t pwm)//, int motorMo
float acc = (float) 0.001 * (angVel - vel_old) / deltaT;
vel_old = angVel;
float inertiaTorque = acc * inertia;*/
/* --------- !!! Do not change the following if-code for motor model "motor16" !!! ----------- */
if
(
motorModel
==
"Motor16"
)
{
// ARMARX_INFO << deactivateSpam(0.01) << "motor 16, torque: " << torque;
torque
=
linearModel_dcx16
(
vel
,
pwm
);
}
torqueWithInertia
=
torque
;
// + inertiaTorque;
// ARMARX_INFO << deactivateSpam(0.01) << "motor 16, torqueWithInertia: " << torqueWithInertia;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment