20 Bundle(
float _x,
float _y,
float _a,
float _w,
float _l): x(_x), y(_y), angle(_a), width(_w), length(_l){}
34 bool operator<(
const Bundle & bf);
41 return sqrt(pow(x,2)+pow(y,2));
52 float get_angle()
const{
56 float get_width()
const{
60 float get_length()
const{
65 float sum_squares()
const{
66 return pow(x, 2) + pow(y, 2)+pow(angle, 2) +pow(width, 2) +pow(length, 2);
69 std::vector <float> get_vector()
const{
70 return {x, y, angle, width, length};
75 T linear_rectify(T value){
93 static constexpr
float FIXED_ENDPOSE=0.05;
94 static constexpr
float FIXED_ANGLE= M_PI/6;
95 static constexpr
float FIXED_DISTPOS= 0.065;
96 static constexpr
float FIXED_AFFORDANCE =0;
97 static constexpr
float FIXED_DIMENSIONS=0.03;
101 Threshold(
float e,
float a,
float d,
float aff,
float d_dim):
102 endPosition(e), angle(a), dPosition(d), affordance(aff), D_dimensions(d_dim){}
104 float for_robot_position()
const{
108 float for_robot_angle()
const{
112 float for_affordance()
const{
130 void set_Dn(
const Bundle & b){
134 void set_Di(
const Bundle & b){
141 return Bundle(dPosition, dPosition, angle, D_dimensions, D_dimensions);
147 float endPosition=FIXED_ENDPOSE;
148 float angle= FIXED_ANGLE;
149 float dPosition= FIXED_DISTPOS;
150 float affordance =FIXED_AFFORDANCE;
151 float D_dimensions=FIXED_DIMENSIONS;
152 Bundle Di=
Bundle(dPosition, dPosition, angle, D_dimensions, D_dimensions), Dn=Di;
157 Bundle Di_weights, Dn_weights;
162 void set_learning_rate(
float f){
175 FILE *f= fopen(
"/tmp/threshold_weights.txt",
"a+");
176 fprintf(f,
"%f\t%f\t%f\t%f\t%f\t\t%f\t%f\t%f\t%f\t%f\n", Di_weights.get_x(),
178 Di_weights.get_angle(),
179 Di_weights.get_length(),
180 Di_weights.get_width(),
183 Dn_weights.get_angle(),
184 Dn_weights.get_length(),
185 Dn_weights.get_width()
191 FILE *f= fopen(
"/tmp/threshold_weights",
"w+");
213 result.set_Di(t.
for_Di()*Di_weights);
214 result.set_Dn(t.
for_Dn()*Dn_weights);
Definition: threshold.h:10
Bundle operator*(const Bundle &b) const
Dot product between two bundles.
Definition: threshold.cpp:3
Definition: threshold.h:155
virtual void Di_tune(const Bundle &error, const Bundle &x)=0
Tune weights for Di.
virtual Bundle update_bundle(const Bundle &error, const Bundle &x)=0
Updates a threshold according to a custom learning rule.
Definition: threshold.h:91
Bundle for_Dn() const
Returns a bundle of thresholds for the initial disturbance.
Definition: threshold.h:126
Bundle for_Di() const
Returns a bundle of thresholds for the initial disturbance.
Definition: threshold.h:119
Bundle bundle_threshold()
Returns a bundle of parameters for disturbance matching.
Definition: threshold.h:140
Definition: disturbance.h:47