@@ -777,26 +777,53 @@ namespace dynamicgraph {
777
777
778
778
779
779
780
+ namespace dynamicgraph {
781
+ namespace sot {
782
+
783
+ template < typename T>
784
+ struct WeightedAdder
785
+ : public BinaryOpHeader<T,T,T>
786
+ {
787
+ public:
788
+ double gain1,gain2;
789
+ void operator ()( const T& v1,const T& v2, T& res ) const
790
+ {
791
+ res=v1; res*=gain1;
792
+ res += gain2*v2;
793
+ }
794
+
795
+ void addSpecificCommands (Entity& ent,
796
+ Entity::CommandMap_t& commandMap)
797
+ {
798
+ using namespace dynamicgraph ::command;
799
+ std::string doc;
800
+
801
+ ADD_COMMAND ( " setGain1" ,
802
+ makeDirectSetter (ent,&gain1,docDirectSetter (" gain1" ," double" )));
803
+ ADD_COMMAND ( " setGain2" ,
804
+ makeDirectSetter (ent,&gain2,docDirectSetter (" gain2" ," double" )));
805
+ ADD_COMMAND ( " getGain1" ,
806
+ makeDirectGetter (ent,&gain1,docDirectGetter (" gain1" ," double" )));
807
+ ADD_COMMAND ( " getGain2" ,
808
+ makeDirectGetter (ent,&gain2,docDirectGetter (" gain2" ," double" )));
809
+ }
810
+
811
+ virtual std::string getDocString () const
812
+ {
813
+ return std::string (" Weighted Combination of inputs : \n - gain{1|2} gain." );
814
+ }
815
+ };
816
+
817
+ REGISTER_BINARY_OP (WeightedAdder<ml::Matrix>,WeightAdd_of_matrix);
818
+ REGISTER_BINARY_OP (WeightedAdder<ml::Vector>,WeightAdd_of_vector);
819
+ REGISTER_BINARY_OP (WeightedAdder<double >,WeightAdd_of_double);
820
+ }
821
+ }
822
+
780
823
/* --- TODO ------------------------------------------------------------------*/
781
824
// The following commented lines are sot-v1 entities that are still waiting
782
825
// for conversion. Help yourself!
783
826
784
- // struct WeightedAdder
785
- // {
786
- // public:
787
- // double gain1,gain2;
788
- // void operator()( const ml::Vector& v1,const ml::Vector& v2,ml::Vector& res ) const
789
- // {
790
- // res=v1; res*=gain1;
791
- // res += gain2*v2;
792
- // }
793
- // };
794
- // typedef BinaryOp< Vector,Vector,Vector,WeightedAdder > weightadd;
795
- // SOT_FACTORY_TEMPLATE_ENTITY_PLUGIN_ExE_E_CMD(weightadd,vector,weight_add,"WeightAdd_of_vector",else if( cmdLine=="gain1" ){ cmdArgs>>op.gain1; }
796
- // else if( cmdLine=="gain2" ){ cmdArgs>>op.gain2;}
797
- // else if( cmdLine=="print" ){os<<"WeightAdd: "<<op.gain1<<" "<<op.gain2<<std::endl; },
798
- // "WeightAdd<vector>: \n - gain{1|2} gain.")
799
-
800
827
// /* -------------------------------------------------------------------------- */
801
828
802
829
// struct WeightedDirection
0 commit comments