-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add noise dynamic simulator - compute dxdt - create logger dynamic simulator
- Loading branch information
1 parent
e0dc918
commit c18efc5
Showing
10 changed files
with
156 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ | |
properties | ||
mBodyTwist_0 | ||
motorsAngVel | ||
motorsAngVel_des | ||
motorsCurrent | ||
motorsCurrentNoise | ||
motorsCurrent_task | ||
motorsCurrent_gravity | ||
jointsAngVel_PJ | ||
%mBodyAngVelStar_0 | ||
mBodyWrenchExt_0 | ||
|
@@ -34,7 +38,11 @@ | |
[email protected]('model',input.model,'numberIterations',input.numberIterations) | ||
obj.mBodyTwist_0 = zeros(input.model.constants.mBodyTwist ,obj.numberIterations); | ||
obj.motorsAngVel = zeros(input.model.constants.motorsAngVel,obj.numberIterations); | ||
obj.motorsAngVel_des = zeros(input.model.constants.motorsAngVel,obj.numberIterations); | ||
obj.motorsCurrent = zeros(input.model.constants.motorsAngVel,obj.numberIterations); | ||
obj.motorsCurrent_gravity = zeros(input.model.constants.motorsAngVel,obj.numberIterations); | ||
obj.motorsCurrent_task = zeros(input.model.constants.motorsAngVel,obj.numberIterations); | ||
obj.motorsCurrentNoise = zeros(input.model.constants.motorsAngVel,obj.numberIterations); | ||
obj.jointsAngVel_PJ = zeros(input.model.constants.jointsAngVel,obj.numberIterations); | ||
%obj.mBodyAngVelStar_0 = zeros(input.model.constants.mBodyAngVel ,obj.numberIterations); | ||
obj.mBodyWrenchExt_0 = zeros(input.model.constants.mBodyTwist,obj.numberIterations); | ||
|
@@ -60,6 +68,10 @@ function store(obj,input) | |
input.controller | ||
input.stgsDesiredShape | ||
input.motorsCurrent | ||
input.motorsCurrentNoise | ||
input.motorsCurrent_task | ||
input.motorsCurrent_gravity | ||
input.motorsAngVel_des | ||
end | ||
|
||
obj.storeStateKinMBody('model',input.model,'controller',input.controller,'indexIteration',input.indexIteration,... | ||
|
@@ -77,7 +89,12 @@ function store(obj,input) | |
|
||
obj.mBodyTwist_0( :,obj.indexIteration) = mBodyTwist; | ||
obj.motorsAngVel( :,obj.indexIteration) = jointsAngVel(input.model.selector.indexes_motorsAngVel_from_jointsAngVel); | ||
obj.motorsAngVel_des(:,obj.indexIteration) = input.motorsAngVel_des; | ||
obj.motorsCurrent( :,obj.indexIteration) = input.motorsCurrent; | ||
obj.motorsCurrentNoise( :,obj.indexIteration) = input.motorsCurrentNoise; | ||
obj.motorsCurrent_task( :,obj.indexIteration) = input.motorsCurrent_task; | ||
obj.motorsCurrent_gravity( :,obj.indexIteration) = input.motorsCurrent_gravity; | ||
|
||
obj.jointsAngVel_PJ(:,obj.indexIteration) = jointsAngVel; | ||
|
||
% massMatrix mBodyTwAcc_0 = mBodyWrenchExt + mBodyWrenchJcF_0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
classdef NoiseDynRel < handle | ||
%NOISEKINREL Summary of this class goes here | ||
% Detailed explanation goes here | ||
|
||
properties (SetAccess=protected,GetAccess=public) | ||
stgsNoise | ||
timeIncrement | ||
kBaum | ||
regTermDampPInv | ||
end | ||
|
||
methods | ||
function [obj] = NoiseDynRel(input) | ||
arguments | ||
input.stgsNoise | ||
input.controller_dt | ||
input.kBaum | ||
input.regTermDampPInv | ||
end | ||
obj.stgsNoise = input.stgsNoise; | ||
obj.timeIncrement = input.controller_dt; | ||
obj.kBaum = input.kBaum; | ||
obj.regTermDampPInv = input.regTermDampPInv; | ||
end | ||
|
||
function motorsCurrent = applyInputCompression(obj,input) | ||
arguments | ||
obj | ||
input.motorsCurrent | ||
end | ||
|
||
if obj.stgsNoise.inputCompression.bool | ||
mu = 0; | ||
saturationValue = obj.stgsNoise.inputCompression.maxValue; | ||
probSaturationValue = obj.stgsNoise.inputCompression.probMaxValue/2; | ||
noise = abs(mystica.utils.createBoundedGaussianNoise(size(input.motorsCurrent),mu,saturationValue,probSaturationValue)); | ||
motorsCurrent = input.motorsCurrent .* (1 - noise); | ||
else | ||
motorsCurrent = input.motorsCurrent; | ||
end | ||
|
||
end | ||
|
||
function stateDynMBody = createStateDynMBodyNoise(obj,input) | ||
arguments | ||
obj | ||
input.stateDynMBody | ||
end | ||
stateDynMBody = copy(input.stateDynMBody); | ||
end | ||
|
||
function stateDynMBody = applyEstimationError(obj,input) | ||
arguments | ||
obj | ||
input.stateDynMBody | ||
input.model | ||
end | ||
|
||
stateDynMBody = copy(input.stateDynMBody); | ||
|
||
if obj.stgsNoise.errorStateEstimation.bool | ||
mu = 0; | ||
saturationValue = obj.stgsNoise.errorStateEstimation.maxValue; | ||
probSaturationValue = obj.stgsNoise.errorStateEstimation.probMaxValue; | ||
motorsAngVelNoise = mystica.utils.createBoundedGaussianNoise([input.model.constants.motorsAngVel 1],mu,saturationValue,probSaturationValue); | ||
mBodyVelQuat_0 = stateDynMBody.get_mBodyVelQuat0_from_motorsAngVel('motorsAngVel',motorsAngVelNoise,... | ||
'model',input.model,'kBaum',obj.kBaum,'regTermDampPInv',obj.regTermDampPInv); | ||
mBodyPosQuat_0 = stateDynMBody.mBodyPosQuat_0 + mBodyVelQuat_0 * obj.timeIncrement; | ||
mBodyPosVel_0 = stateDynMBody.mBodyPosVel_0; | ||
mBodyPosVel_0(input.model.selector.indexes_mBodyPosQuat_from_mBodyPosVel) = mBodyPosQuat_0; | ||
stateDynMBody.setMBodyPosVel( 'model',input.model,'mBodyPosVel_0' ,mBodyPosVel_0) | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters