Changeset 952 for cpp/frams/neuro


Ignore:
Timestamp:
06/20/20 01:09:57 (4 years ago)
Author:
Maciej Komosinski
Message:

Added new receptors (Gp:"gyroscope" on a Part, Tp:Touch-proximity and Tc:Touch-contact) and improved existing ones (T, G)

Location:
cpp/frams/neuro
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/neuro/impl/neuroimpl-body-sdk.h

    r922 r952  
    1616};
    1717
     18extern ParamEntry NI_GyroP_tab[];
     19
     20class NI_GyroP : public NeuroImpl
     21{
     22public:
     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
    1830extern ParamEntry NI_Touch_tab[];
    1931class NI_Touch : public NeuroImpl
     
    2133public:
    2234        double range;
     35        double ry,rz;
    2336        NeuroImpl* makeNew() { return new NI_Touch(); } // for NeuroFactory
    2437        int lateinit() { if (!neuro->part) return 0; simorder = 0; return 1; }
    2538        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; }
    2740};
     41
     42extern ParamEntry NI_TouchP_tab[];
     43class NI_TouchP : public NI_Touch
     44{
     45public:
     46        NeuroImpl* makeNew() { return new NI_TouchP(); } // for NeuroFactory
     47        NI_TouchP() { paramentries = NI_TouchP_tab; }
     48};
     49
     50extern ParamEntry NI_TouchC_tab[];
     51class NI_TouchC : public NI_Touch
     52{
     53public:
     54        NeuroImpl* makeNew() { return new NI_TouchC(); } // for NeuroFactory
     55        NI_TouchC() { paramentries = NI_TouchC_tab; }
     56};
     57
    2858
    2959class NI_Smell : public NeuroImpl
  • cpp/frams/neuro/neurocls-f0-SDK-factory.h

    r946 r952  
    3939#undef FIELDSTRUCT
    4040
     41#define FIELDSTRUCT NI_GyroP
     42ParamEntry 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
    4149#define FIELDSTRUCT NI_Touch
    4250ParamEntry NI_Touch_tab []={
    43 {"Touch",1, 1 ,"T",},
     51{"Touch",1, 3 ,"T",},
    4452{"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
     59ParamEntry NI_TouchC_tab []={
     60{"Touch contact",1, 0 ,"Tc",},
     61 {0,0,0,},};
     62#undef FIELDSTRUCT
     63
     64#define FIELDSTRUCT NI_TouchP
     65ParamEntry 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),},
    4570 {0,0,0,},};
    4671#undef FIELDSTRUCT
     
    159184setImplementation("Nu",new NI_StdUNeuron); \
    160185setImplementation("G",new NI_Gyro); \
     186setImplementation("Gp",new NI_GyroP); \
    161187setImplementation("T",new NI_Touch); \
     188setImplementation("Tc",new NI_TouchC); \
     189setImplementation("Tp",new NI_TouchP); \
    162190setImplementation("S",new NI_Smell); \
    163191setImplementation("*",new NI_Const); \
  • cpp/frams/neuro/neurocls-f0-SDK-library.h

    r946 r952  
    4141
    4242
    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,},};
     46addClass(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};   
     49static 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,},};
     57addClass(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));
    4658
    4759      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};   
    4860static ParamEntry NI_Touch_tab[]={
    49 {"Touch",1, 1 ,"T",},
     61{"Touch",1, 3 ,"T",},
    5062
    5163
    5264{"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,},};
     69addClass(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};   
     72static ParamEntry NI_TouchC_tab[]={
     73{"Touch contact",1, 0 ,"Tc",},
     74
     75
     76 
     77{0,0,0,},};
     78addClass(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};   
     81static 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,},};
     90addClass(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));
    5691
    5792      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  
    1313#include <frams/simul/simul.h>
    1414#endif
     15#include <frams/vm/classes/3dobject.h>
    1516
    1617const int NeuroImpl::ENDDRAWING = -9999;
     
    153154}
    154155
     156void 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
    155165///////////////////////////////////////////////
    156166
     
    301311ParamEntry neuroimpl_tab[] =
    302312{
    303         { "Neuro", 1, 27 + NEUROIMPL_SIGNAL_PROPS, "Neuro", "Live Neuron object." },
     313        { "Neuro", 1, 29 + NEUROIMPL_SIGNAL_PROPS, "Neuro", "Live Neuron object." },
    304314
    305315        { "getInputState", 0, 0, "Get input signal", "p f(d input)", PROCEDURE(p_get), },
     
    324334        { "position_y", 0, PARAM_READONLY, "Position y", "f", GETONLY(position_y), },
    325335        { "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), },
    326338        { "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" },
    329341        { "neuroproperties", 0, PARAM_READONLY, "Custom neuron fields", "oNeuroProperties", GETONLY(fields),
    330342        "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"
     
    549561}
    550562
     563void NeuroImpl::get_relative_pos(ExtValue *ret)
     564{
     565        ret->setObject(Pt3D_Ext::makeDynamicObject(getRelativePosition()));
     566}
     567
     568void NeuroImpl::get_relative_orient(ExtValue *ret)
     569{
     570        ret->setObject(Orient_Ext::makeDynamicObject(new Orient_Ext(getRelativeOrientation())));
     571}
    551572
    552573void NeuroImpl::createFieldsObject()
  • cpp/frams/neuro/neuroimpl.h

    r932 r952  
    8888
    8989        static NeuroImpl *getImpl(Neuro* n) { return (NeuroImpl*)n->userdata[mytags_id]; }
     90        static void getLiveNeuroObject(Neuro *n, ExtValue *ret);
    9091};
    9192
     
    271272        Creature* getCreature();
    272273
     274        virtual Pt3D getRelativePosition() { return Pt3D_0; }
     275        virtual Orient getRelativeOrientation() { return Orient_1; }
     276       
    273277#define STATRICKCLASS NeuroImpl
    274278        PARAMGETDEF(count) { arg1->setInt(getInputCount()); }
     
    300304        PARAMGETDEF(position_y);
    301305        PARAMGETDEF(position_z);
     306        PARAMGETDEF(relative_pos);
     307        PARAMGETDEF(relative_orient);
    302308        PARAMGETDEF(fields);
    303309        PARAMGETDEF(neurodef);
Note: See TracChangeset for help on using the changeset viewer.