Changeset 952 for cpp/frams/neuro
- Timestamp:
- 06/20/20 01:09:57 (4 years ago)
- Location:
- cpp/frams/neuro
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/neuro/impl/neuroimpl-body-sdk.h
r922 r952 16 16 }; 17 17 18 extern ParamEntry NI_GyroP_tab[]; 19 20 class NI_GyroP : public NeuroImpl 21 { 22 public: 23 double ry,rz; 24 NeuroImpl* makeNew() { return new NI_GyroP(); } // for NeuroFactory 25 int lateinit() { if (!neuro->part) return 0; simorder = 0; return 1; } 26 void go() { setState(0); } 27 NI_GyroP(): ry(0),rz(0) { paramentries = NI_GyroP_tab; } 28 }; 29 18 30 extern ParamEntry NI_Touch_tab[]; 19 31 class NI_Touch : public NeuroImpl … … 21 33 public: 22 34 double range; 35 double ry,rz; 23 36 NeuroImpl* makeNew() { return new NI_Touch(); } // for NeuroFactory 24 37 int lateinit() { if (!neuro->part) return 0; simorder = 0; return 1; } 25 38 void go() { setState(0); } 26 NI_Touch() :range(1) { paramentries = NI_Touch_tab; }39 NI_Touch() :range(1),ry(0),rz(0) { paramentries = NI_Touch_tab; } 27 40 }; 41 42 extern ParamEntry NI_TouchP_tab[]; 43 class NI_TouchP : public NI_Touch 44 { 45 public: 46 NeuroImpl* makeNew() { return new NI_TouchP(); } // for NeuroFactory 47 NI_TouchP() { paramentries = NI_TouchP_tab; } 48 }; 49 50 extern ParamEntry NI_TouchC_tab[]; 51 class NI_TouchC : public NI_Touch 52 { 53 public: 54 NeuroImpl* makeNew() { return new NI_TouchC(); } // for NeuroFactory 55 NI_TouchC() { paramentries = NI_TouchC_tab; } 56 }; 57 28 58 29 59 class NI_Smell : public NeuroImpl -
cpp/frams/neuro/neurocls-f0-SDK-factory.h
r946 r952 39 39 #undef FIELDSTRUCT 40 40 41 #define FIELDSTRUCT NI_GyroP 42 ParamEntry NI_GyroP_tab []={ 43 {"Part Gyroscope",1, 2 ,"Gp",}, 44 {"ry",1,0,"rotation.y","f -6.282 6.282 0",FIELD(ry),}, 45 {"rz",1,0,"rotation.z","f -6.282 6.282 0",FIELD(rz),}, 46 {0,0,0,},}; 47 #undef FIELDSTRUCT 48 41 49 #define FIELDSTRUCT NI_Touch 42 50 ParamEntry NI_Touch_tab []={ 43 {"Touch",1, 1,"T",},51 {"Touch",1, 3 ,"T",}, 44 52 {"r",1,0,"Range","f 0.0 1.0 1.0",FIELD(range),}, 53 {"ry",1,0,"rotation.y","f -6.282 6.282 0",FIELD(ry),}, 54 {"rz",1,0,"rotation.z","f -6.282 6.282 0",FIELD(rz),}, 55 {0,0,0,},}; 56 #undef FIELDSTRUCT 57 58 #define FIELDSTRUCT NI_TouchC 59 ParamEntry NI_TouchC_tab []={ 60 {"Touch contact",1, 0 ,"Tc",}, 61 {0,0,0,},}; 62 #undef FIELDSTRUCT 63 64 #define FIELDSTRUCT NI_TouchP 65 ParamEntry NI_TouchP_tab []={ 66 {"Touch proximity",1, 3 ,"Tp",}, 67 {"r",1,0,"Range","f 0.0 1.0 1.0",FIELD(range),}, 68 {"ry",1,0,"rotation.y","f -6.282 6.282 0",FIELD(ry),}, 69 {"rz",1,0,"rotation.z","f -6.282 6.282 0",FIELD(rz),}, 45 70 {0,0,0,},}; 46 71 #undef FIELDSTRUCT … … 159 184 setImplementation("Nu",new NI_StdUNeuron); \ 160 185 setImplementation("G",new NI_Gyro); \ 186 setImplementation("Gp",new NI_GyroP); \ 161 187 setImplementation("T",new NI_Touch); \ 188 setImplementation("Tc",new NI_TouchC); \ 189 setImplementation("Tp",new NI_TouchP); \ 162 190 setImplementation("S",new NI_Smell); \ 163 191 setImplementation("*",new NI_Const); \ -
cpp/frams/neuro/neurocls-f0-SDK-library.h
r946 r952 41 41 42 42 43 44 {0,0,0,},}; 45 addClass(new NeuroClass(NI_Gyro_tab,"Equilibrium sensor.\n0=the stick is horizontal\n+1/-1=the stick is vertical",0,1,2, Gyro_xy,false, 32, 3)); 43 44 45 {0,0,0,},}; 46 addClass(new NeuroClass(NI_Gyro_tab,"Tilt sensor.\nSignal is proportional to sin(angle) = most sensitive in horizontal orientation.\n0=the stick is horizontal\n+1/-1=the stick is vertical",0,1,2, Gyro_xy,false, 32, 1)); 47 48 static int GyroP_xy[]={83,8,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,12,43,24,48,24,48,19,38,19,38,24,43,24,43,54,48,54,48,64,43,69,38,64,38,54,43,54,5,63,69,58,74,48,79,38,79,28,74,23,69,1,43,79,43,74,1,23,69,26,66,1,63,69,60,66,1,55,76,53,73,1,31,75,33,72}; 49 static ParamEntry NI_GyroP_tab[]={ 50 {"Part Gyroscope",1, 2 ,"Gp",}, 51 52 53 {"ry",1,0,"rotation.y","f -6.282 6.282 0",}, 54 {"rz",1,0,"rotation.z","f -6.282 6.282 0",}, 55 56 {0,0,0,},}; 57 addClass(new NeuroClass(NI_GyroP_tab,"Tilt sensor. Signal is directly proportional to the tilt angle.\n0=the part X axis is horizontal\n+1/-1=the axis is vertical",0,1,1, GyroP_xy,false, 32, 3)); 46 58 47 59 static int Touch_xy[]={43,2,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,11,75,50,65,50,60,55,55,45,50,55,45,45,40,50,35,50,30,45,25,50,30,55,35,50}; 48 60 static ParamEntry NI_Touch_tab[]={ 49 {"Touch",1, 1,"T",},61 {"Touch",1, 3 ,"T",}, 50 62 51 63 52 64 {"r",1,0,"Range","f 0.0 1.0 1.0",}, 53 54 {0,0,0,},}; 55 addClass(new NeuroClass(NI_Touch_tab,"Touch sensor.\n-1=no contact\n0=just touching\n>0=pressing, value depends on the force applied",0,1,1, Touch_xy,false, 32, 3)); 65 {"ry",1,0,"rotation.y","f -6.282 6.282 0",}, 66 {"rz",1,0,"rotation.z","f -6.282 6.282 0",}, 67 68 {0,0,0,},}; 69 addClass(new NeuroClass(NI_Touch_tab,"Touch and proximity sensor (Tc+Tp combined)\n-1=no contact\n0=just touching\n>0=pressing, value depends on the force applied (not implemented in ODE mode)",0,1,1, Touch_xy,false, 32, 3)); 70 71 static int TouchC_xy[]={43,2,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,11,75,50,65,50,60,55,55,45,50,55,45,45,40,50,35,50,30,45,25,50,30,55,35,50}; 72 static ParamEntry NI_TouchC_tab[]={ 73 {"Touch contact",1, 0 ,"Tc",}, 74 75 76 77 {0,0,0,},}; 78 addClass(new NeuroClass(NI_TouchC_tab,"Touch sensor.\n-1=no contact\n0=the Part is touching the obstacle\n>0=pressing, value depends on the force applied (not implemented in ODE mode)",0,1,1, TouchC_xy,false, 32, 3)); 79 80 static int TouchP_xy[]={43,2,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,11,75,50,65,50,60,55,55,45,50,55,45,45,40,50,35,50,30,45,25,50,30,55,35,50}; 81 static ParamEntry NI_TouchP_tab[]={ 82 {"Touch proximity",1, 3 ,"Tp",}, 83 84 85 {"r",1,0,"Range","f 0.0 1.0 1.0",}, 86 {"ry",1,0,"rotation.y","f -6.282 6.282 0",}, 87 {"rz",1,0,"rotation.z","f -6.282 6.282 0",}, 88 89 {0,0,0,},}; 90 addClass(new NeuroClass(NI_TouchP_tab,"Proximity sensor detecting obstacles along the X axis.\n-1=distance is \r\' or more\n0=zero distance'",0,1,1, TouchP_xy,false, 32, 3)); 56 91 57 92 static int Smell_xy[]={64,5,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,3,10,40,15,45,15,55,10,60,5,20,30,25,35,30,45,30,55,25,65,20,70,4,15,35,20,40,22,50,20,60,15,65,5,75,50,50,50,45,45,40,50,45,55,50,50}; -
cpp/frams/neuro/neuroimpl.cpp
r932 r952 13 13 #include <frams/simul/simul.h> 14 14 #endif 15 #include <frams/vm/classes/3dobject.h> 15 16 16 17 const int NeuroImpl::ENDDRAWING = -9999; … … 153 154 } 154 155 156 void NeuroNetImpl::getLiveNeuroObject(Neuro *n, ExtValue *ret) 157 { 158 NeuroImpl *ni = getImpl(n); 159 if (ni) 160 ret->setObject(ExtObject(&NeuroImpl::getStaticParam(), ni)); 161 else 162 ret->setEmpty(); 163 } 164 155 165 /////////////////////////////////////////////// 156 166 … … 301 311 ParamEntry neuroimpl_tab[] = 302 312 { 303 { "Neuro", 1, 2 7+ NEUROIMPL_SIGNAL_PROPS, "Neuro", "Live Neuron object." },313 { "Neuro", 1, 29 + NEUROIMPL_SIGNAL_PROPS, "Neuro", "Live Neuron object." }, 304 314 305 315 { "getInputState", 0, 0, "Get input signal", "p f(d input)", PROCEDURE(p_get), }, … … 324 334 { "position_y", 0, PARAM_READONLY, "Position y", "f", GETONLY(position_y), }, 325 335 { "position_z", 0, PARAM_READONLY, "Position z", "f", GETONLY(position_z), }, 336 { "relative_pos", 0, PARAM_READONLY, "Relative position", "oXYZ", GETONLY(relative_pos), }, 337 { "relative_orient", 0, PARAM_READONLY, "Relative orientation", "oOrient", GETONLY(relative_orient), }, 326 338 { "creature", 0, PARAM_READONLY, "Gets owner creature", "oCreature", GETONLY(creature), }, 327 { " part", 0, PARAM_READONLY, "The Part object where this neuron is located", "oMechPart", GETONLY(part),},328 { " joint", 0, PARAM_READONLY, "The Joint object where this neuron is located", "oMechJoint", GETONLY(joint),},339 { "mechpart", 0, PARAM_READONLY, "MechPart object", "oMechPart", GETONLY(part), "The MechPart object where this neuron is located" }, 340 { "mechjoint", 0, PARAM_READONLY, "MechJoint object" , "oMechJoint", GETONLY(joint), "The MechJoint object where this neuron is located" }, 329 341 { "neuroproperties", 0, PARAM_READONLY, "Custom neuron fields", "oNeuroProperties", GETONLY(fields), 330 342 "Neurons can have different fields depending on their class. Script neurons have their fields defined using the \"property:\" syntax. If you develop a custom neuron script you should use the NeuroProperties object for accessing your own neuron fields. The Neuro.neuroproperties property is meant for accessing the neuron fields from the outside script.\n" … … 549 561 } 550 562 563 void NeuroImpl::get_relative_pos(ExtValue *ret) 564 { 565 ret->setObject(Pt3D_Ext::makeDynamicObject(getRelativePosition())); 566 } 567 568 void NeuroImpl::get_relative_orient(ExtValue *ret) 569 { 570 ret->setObject(Orient_Ext::makeDynamicObject(new Orient_Ext(getRelativeOrientation()))); 571 } 551 572 552 573 void NeuroImpl::createFieldsObject() -
cpp/frams/neuro/neuroimpl.h
r932 r952 88 88 89 89 static NeuroImpl *getImpl(Neuro* n) { return (NeuroImpl*)n->userdata[mytags_id]; } 90 static void getLiveNeuroObject(Neuro *n, ExtValue *ret); 90 91 }; 91 92 … … 271 272 Creature* getCreature(); 272 273 274 virtual Pt3D getRelativePosition() { return Pt3D_0; } 275 virtual Orient getRelativeOrientation() { return Orient_1; } 276 273 277 #define STATRICKCLASS NeuroImpl 274 278 PARAMGETDEF(count) { arg1->setInt(getInputCount()); } … … 300 304 PARAMGETDEF(position_y); 301 305 PARAMGETDEF(position_z); 306 PARAMGETDEF(relative_pos); 307 PARAMGETDEF(relative_orient); 302 308 PARAMGETDEF(fields); 303 309 PARAMGETDEF(neurodef);
Note: See TracChangeset
for help on using the changeset viewer.