RippleCarryAdder::FullAdder::FullAdder(const QString &name, QGraphicsItem *parent) : Component(name, parent) { addInput(m_a = new Input("a", 1, this)); addInput(m_b = new Input("b", 1, this)); addInput(m_cin = new Input("cin", 1, this)); addOutput(m_cout = new Output("cout", 1, this)); addOutput(m_s = new Output("s", 1, this)); setLayout(Component::MINIMIZED); addSubComponent(m_and0 = new AndGate("and_0")); addSubComponent(m_and1 = new AndGate("and_1")); addSubComponent(m_xor0 = new XOrGate("xor_0")); addSubComponent(m_xor1 = new XOrGate("xor_1")); addSubComponent(m_or = new OrGate("or")); m_a->from()->connect(m_and0->getInput("a")); m_b->from()->connect(m_and0->getInput("b")); m_a->from()->connect(m_xor0->getInput("a")); m_b->from()->connect(m_xor0->getInput("b")); m_cin->from()->connect(m_and1->getInput("a")); m_xor0->getOutput("output")->connect(m_and1->getInput("b")); m_and0->getOutput("output")->connect(m_or->getInput("a")); m_and1->getOutput("output")->connect(m_or->getInput("b")); m_or->getOutput("output")->connect(m_cout->to()); m_xor0->getOutput("output")->connect(m_xor1->getInput("a")); m_cin->from()->connect(m_xor1->getInput("b")); m_xor1->getOutput("output")->connect(m_s->to()); }
// ###################################################################### PointCloudSinkModule::PointCloudSinkModule(std::string const & instanceid) : nrt::Module(instanceid), itsNameParameter(pointcloudsink::NameDef, this), itsPointCloudSink(new nrt::PointCloudSink("sink")) { addSubComponent( itsPointCloudSink ); }
// ###################################################################### AttentionGuidanceMapSC::AttentionGuidanceMapSC(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : AttentionGuidanceMapNeuralSim(mgr, descrName, tagName), itsSC(new nsu::SupColliculusModule(mgr)) { addSubComponent(itsSC); }
// ###################################################################### AttentionGuidanceMapNF::AttentionGuidanceMapNF(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : AttentionGuidanceMapNeuralSim(mgr, descrName, tagName), itsNF(new NeuralFieldModule(mgr)) { addSubComponent(itsNF); }
// ###################################################################### Rovio::Rovio(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsHttpClient(new HTTPClient(mgr)) { addSubComponent(itsHttpClient); }
SimpleLED::SimpleLED(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsSerial(new SerialAdvanced(mgr)) { addSubComponent(itsSerial); }
/** * Constructs a TestComponent. */ TestComponent::TestComponent(const QString &name, QGraphicsItem *parent) : Component(name, parent) { // construct the inputs and add them to the component's list of inputs addInput(m_input_01 = new Input("input_01", 32, this)); addInput(m_input_02 = new Input("input_02", 32, this)); addInput(m_multiplyFlag = new Input("multiplyFlag", 1, this)); // construct the output and add it to the component's list of outputs addOutput(m_output = new Output("output", 32, this)); // add the sub-components that will do our computation work addSubComponent(m_adder = new AdderComponent("adder")); addSubComponent(m_multiplier = new MultiplierComponent("multiplier")); // TODO: add a mux to select between addition and multiplication m_input_01->from()->connect(m_multiplier->getInput("input_01")); m_input_02->from()->connect(m_multiplier->getInput("input_02")); m_multiplier->getOutput("output")->connect(m_output->to()); }
BinaryMultiplier::BinaryMultiplier(const QString &name, int width, QGraphicsItem *parent) : Component(name, parent) { addInput(m_a = new Input("a", width, this)); addInput(m_b = new Input("b", width, this)); addOutput(m_product = new Output("product", width, this)); addSubComponent(m_bToBools = new IntToBoolsComponent("bToBools", width)); m_b->from()->connect(m_bToBools->getInput("input")); for(int i = 0; i < width; i++) { // make an ander m_anders.append(new BinaryAnder("ander" + QVariant(i).toString(), width)); addSubComponent(m_anders.last()); // connect the ander to a and bit i of b, effectively "multiplying" a by b[i] m_a->from()->connect(m_anders.last()->getInput("a")); m_bToBools->getOutput(QVariant(i).toString())->connect(m_anders.last()->getInput("b")); // make a bit shifter that shifts by i m_shifters.append(new BinaryShifter("shifter" + QVariant(i).toString(), width, i)); addSubComponent(m_shifters.last()); // connect the shifter to shift the result of the ander m_anders.last()->getOutput("output")->connect(m_shifters.last()->getInput("input")); if(i > 0) { // make an adder m_adders.append(new RippleCarryAdder("adder" + QVariant(i).toString(), width)); addSubComponent(m_adders.last()); if(i == 1) { m_adders.last()->setLayout(Component::EXPANDED); // connect the adder to add the first two bitshifted results together m_shifters[0]->getOutput("output")->connect(m_adders.last()->getInput("a")); m_shifters[1]->getOutput("output")->connect(m_adders.last()->getInput("b")); } else { m_adders.last()->setLayout(Component::MINIMIZED); // connect the previous adder and the new bitshifted result to the new adder to add the result to the total m_adders[i - 2]->getOutput("sum")->connect(m_adders.last()->getInput("a")); m_shifters.last()->getOutput("output")->connect(m_adders.last()->getInput("b")); } } } // connect the last adder to output the product m_adders.last()->getOutput("sum")->connect(m_product->to()); }
ScorbotSimple(OptionManager& mgr, const std::string& descrName = "", const std::string& tagName = "") : ModelComponent(mgr, descrName, tagName), itsSerial(new Serial(mgr)) { addSubComponent(itsSerial); itsSerial->configure("/dev/ttyUSB0", 115200, "8N1", false, false, 10000); }
LEDcontroller::LEDcontroller(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsSerial(new Serial(mgr)) { addSubComponent(itsSerial); itsSerial->configureSearch("ledboard",115200); }
// ###################################################################### // ###################################################################### // ########## AttentionGuidanceMapConfigurator implementation // ###################################################################### // ###################################################################### AttentionGuidanceMapConfigurator:: AttentionGuidanceMapConfigurator(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsAGMtype(&OPT_AttentionGuidanceMapType, this), itsAGM(new AttentionGuidanceMapStd(mgr)) { addSubComponent(itsAGM); }
// ###################################################################### // ###################################################################### // ###################################################################### SaccadeControllerEyeConfigurator:: SaccadeControllerEyeConfigurator(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsSacCtrlType(&OPT_SaccadeControllerEyeType, this), itsSC(new StubSaccadeController(mgr, SaccadeBodyPartEye)) { addSubComponent(itsSC); }
// ###################################################################### // ###################################################################### // ###################################################################### EyeHeadControllerConfigurator:: EyeHeadControllerConfigurator(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsEHctrlType(&OPT_EyeHeadControllerType, this), itsEHC(new StubEyeHeadController(mgr)) { addSubComponent(itsEHC); }
// ###################################################################### // ###################################################################### // ########## TaskRelevanceMapConfigurator implementation // ###################################################################### // ###################################################################### TaskRelevanceMapConfigurator:: TaskRelevanceMapConfigurator(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsTRMtype(&OPT_TaskRelevanceMapType, this), itsTRM(new TaskRelevanceMapStub(mgr)) { addSubComponent(itsTRM); }
// ###################################################################### FaceDetector::FaceDetector(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : RobotBrainComponent(mgr, descrName, tagName), itsOfs(new OutputFrameSeries(mgr)), itsTimer(1000000), itsCurrImgID(-1), itsPrevProcImgID(-1) { addSubComponent(itsOfs); }
// ###################################################################### // ###################################################################### // ########## PrefrontalCortexConfigurator implementation // ###################################################################### // ###################################################################### PrefrontalCortexConfigurator:: PrefrontalCortexConfigurator(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsType(&OPT_PrefrontalCortexType, this), itsPFC(new PrefrontalCortexStub(mgr)) { addSubComponent(itsPFC); }
// ###################################################################### NavBot::NavBot(OptionManager& mgr, const std::string& descrName, const std::string& tagName, const char *defdev) : ModelComponent(mgr, descrName, tagName), itsSerial(new Serial(mgr)) { itsSerial->configure (defdev, 115200, "8N1", false, false, 0); addSubComponent(itsSerial); }
IMU_SFE_Atomic::IMU_SFE_Atomic(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : ModelComponent(mgr, descrName, tagName), itsSerial(new Serial(mgr, "IMU", "IMU")) { addSubComponent(itsSerial); itsSerial->configure("/dev/ttyUSB0", 115200); }
// ###################################################################### HMR3300::HMR3300(OptionManager& mgr, const std::string& descrName, const std::string& tagName, const char *dev) : ModelComponent(mgr, descrName, tagName), itsSerial(new Serial(mgr, descrName+" Serial Port", tagName+"SerialPort")), itsKeepgoing(true), itsListener(), itsHeading(), itsPitch(), itsRoll() { itsSerial->configure(dev, 19200, "8N1", false, false, 0); addSubComponent(itsSerial); pthread_mutex_init(&itsLock, NULL); }
// ###################################################################### void SaccadeControllerEyeConfigurator:: paramChanged(ModelParamBase* const param, const bool valueChanged, ParamClient::ChangeStatus* status) { ModelComponent::paramChanged(param, valueChanged, status); // was that a change of our baby's name? if (param == &itsSacCtrlType) { // if we had one, let's unregister it (when we later reset() the // nub::ref, the current SaccadeController will unexport its // command-line options): removeSubComponent(*itsSC); // instantiate a controller of the appropriate type: if (itsSacCtrlType.getVal().compare("None") == 0 || itsSacCtrlType.getVal().compare("Stub") == 0) itsSC.reset(new StubSaccadeController(getManager(), SaccadeBodyPartEye)); else if (itsSacCtrlType.getVal().compare("Trivial") == 0) itsSC.reset(new TrivialSaccadeController(getManager(), SaccadeBodyPartEye)); else if (itsSacCtrlType.getVal().compare("Fixed") == 0) itsSC.reset(new FixedSaccadeController(getManager(), SaccadeBodyPartEye)); else if (itsSacCtrlType.getVal().compare("Friction") == 0) itsSC.reset(new FrictionSaccadeController(getManager(), SaccadeBodyPartEye)); else if (itsSacCtrlType.getVal().compare("Threshold") == 0) itsSC.reset(new ThresholdSaccadeController(getManager(), SaccadeBodyPartEye)); else if (itsSacCtrlType.getVal().compare("Threshfric") == 0) itsSC.reset(new ThresholdFrictionSaccadeController(getManager(), SaccadeBodyPartEye)); else LFATAL("Unknown eye SaccadeController type %s", itsSacCtrlType.getVal().c_str()); // add our baby as a subcomponent of us so that it will become // linked to the manager through us (hopefully we are registered // with the manager), which in turn will allow it to export its // command-line options and get configured: addSubComponent(itsSC); // tell the controller to export its options: itsSC->exportOptions(MC_RECURSE); // some info message: LINFO("Selected Eye SC of type %s", itsSacCtrlType.getVal().c_str()); } }
// ###################################################################### RangeFinder::RangeFinder(OptionManager& mgr, const std::string& descrName, const std::string& tagName, const char *defdev) : ModelComponent(mgr, descrName, tagName), itsPort(new Serial(mgr)) { // set a default config for our serial port: itsPort->configure(defdev, 19200, "8N1", false, false, 1); // attach our port as a subcomponent: addSubComponent(itsPort); itsRangeData.resize(74); }
// ##################################################################### BeoGPS::BeoGPS(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : RobotBrainComponent(mgr, descrName, tagName), itsSerial(new Serial(mgr)), itsOfs(new OutputFrameSeries(mgr)), itsDisplayUpdateRate(.05), // itsSerialDev(&OPT_SerialDev, this, 0), itsPosition(0.0,0.0,0.0), itsInitLat(-1.0), itsInitLon(-1.0), itsDispImage(512,512,ZEROS), itsCurrMessageID(0) { addSubComponent(itsSerial); addSubComponent(itsOfs); itsData.latDD = -1; itsData.lonDD = -1; itsBufI = 0; itsData.lat = -1; itsData.lon = -1; itsNewGPSdata = false; }
// ###################################################################### ND_Navigation::ND_Navigation(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : RobotBrainComponent(mgr, descrName, tagName), itsOfs(new OutputFrameSeries(mgr)), itsTimer(1000000), itsNDNavigationAlgorithm(new ND_Navigation_Algorithm()) { addSubComponent(itsOfs); // goal is always in front of the robot FOR NOW // this should be set by the Localizer at some point itsGoalSector = 141; itsNDNavigationAlgorithm->setGoalSector(itsGoalSector); }
// ###################################################################### // implementation of SimulationViewerAdapter // ###################################################################### SimulationViewerAdapter::SimulationViewerAdapter(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : SimulationViewer(mgr, descrName, tagName), SIMCALLBACK_INIT(SimEventRetinaImage), SIMCALLBACK_INIT(SimEventWTAwinner), itsInverseRetinal(&OPT_SVInverseTransform, this), itsInput(), itsCurrFOA(WTAwinner::NONE()), itsPrevFOA(WTAwinner::NONE()), itsTransform(new SpaceVariantModule(mgr)) { addSubComponent(itsTransform); }
// ###################################################################### void TaskRelevanceMapConfigurator:: paramChanged(ModelParamBase* const param, const bool valueChanged, ParamClient::ChangeStatus* status) { ModelComponent::paramChanged(param, valueChanged, status); // was that a change of our baby's name? if (param == &itsTRMtype) { // if we had one, let's unregister it (when we later reset() the // nub::ref, the current TaskRelevanceMap will unexport its // command-line options): removeSubComponent(*itsTRM); // instantiate a SM of the appropriate type: if (itsTRMtype.getVal().compare("None") == 0 || itsTRMtype.getVal().compare("Stub") == 0) // no TRM itsTRM.reset(new TaskRelevanceMapStub(getManager())); else if (itsTRMtype.getVal().compare("Std") == 0) // standard itsTRM.reset(new TaskRelevanceMapStd(getManager())); else if (itsTRMtype.getVal().compare("KillStatic") == 0) // kill-static itsTRM.reset(new TaskRelevanceMapKillStatic(getManager())); else if (itsTRMtype.getVal().compare("KillN") == 0) // kill-n itsTRM.reset(new TaskRelevanceMapKillN(getManager())); else if (itsTRMtype.getVal().compare("GistClassify") == 0) // gist-classify itsTRM.reset(new TaskRelevanceMapGistClassify(getManager())); else if (itsTRMtype.getVal().compare("Tigs") == 0) // Tigs itsTRM.reset(new TaskRelevanceMapTigs(getManager())); else if (itsTRMtype.getVal().compare("Tigs2") == 0) // Tigs(gist and pca image) itsTRM.reset(new TaskRelevanceMapTigs2(getManager())); else if (itsTRMtype.getVal().compare("Social") == 0) // Social(requires XML of data) itsTRM.reset(new TaskRelevanceMapSocial(getManager())); else LFATAL("Unknown TRM type %s", itsTRMtype.getVal().c_str()); // add our baby as a subcomponent of us so that it will become // linked to the manager through us (hopefully we are registered // with the manager), which in turn will allow it to export its // command-line options and get configured: addSubComponent(itsTRM); // tell the controller to export its options: itsTRM->exportOptions(MC_RECURSE); // some info message: LINFO("Selected TRM of type %s", itsTRMtype.getVal().c_str()); } }
// ###################################################################### BeoBorg::BeoBorg(OptionManager& mgr, const std::string& descrName, const std::string& tagName, const char *defdev) : ModelComponent(mgr, descrName, tagName), itsPort(new Serial(mgr,"beoborg-serial","beoborg-serial")) { // set a default config for our serial port: itsPort->configure(defdev, 115200, "8N1", false, false, 1); // attach our port as a subcomponent: addSubComponent(itsPort); itsSpeed = 0; itsRadius =0; itsDist = 0; itsLeftEncoder = 0; itsRightEncoder = 0; itsLeftPWM = 0; itsRightPWM = 0; }
/** * \fun LocaLization Constructor function * Initializes the Localization class * * * */ Localization::Localization(OptionManager& mgr, const std::string& descrName, const std::string& tagName) : RobotBrainComponent(mgr, descrName, tagName), itsOfs(new OutputFrameSeries(mgr)), itsRunning(true), itsNumParticles(1000), itsKeepParticles(1000), generator(42u), generate_drift(generator, dist_type(M_DRIFT,SIGMA_DRIFT)), generate_trans(generator, dist_type(M_TRANS,SIGMA_TRANS)) { //// The images used for plotting the particles iMap = Image<float > (2000,2000,ZEROS); originalMap = Image<float > (2000,2000,ZEROS); addSubComponent(itsOfs); initPoints(itsNumParticles); }
// ###################################################################### void AttentionGuidanceMapConfigurator:: paramChanged(ModelParamBase* const param, const bool valueChanged, ParamClient::ChangeStatus* status) { ModelComponent::paramChanged(param, valueChanged, status); // was that a change of our baby's name? if (param == &itsAGMtype) { // if we had one, let's unregister it (when we later reset() the // nub::ref, the current AttentionGuidanceMap will unexport its // command-line options): removeSubComponent(*itsAGM); // instantiate a SM of the appropriate type: if (itsAGMtype.getVal().compare("Std") == 0) // standard itsAGM.reset(new AttentionGuidanceMapStd(getManager())); else if (itsAGMtype.getVal().compare("Opt") == 0) // optimized itsAGM.reset(new AttentionGuidanceMapOpt(getManager())); #ifdef INVT_USE_CPP11//we need c++ 0X features for this to work else if (itsAGMtype.getVal().compare("SC") == 0) // superior colliculus itsAGM.reset(new AttentionGuidanceMapSC(getManager())); else if (itsAGMtype.getVal().compare("NF") == 0) // neural field itsAGM.reset(new AttentionGuidanceMapNF(getManager())); #endif else LFATAL("Unknown AGM type %s", itsAGMtype.getVal().c_str()); // add our baby as a subcomponent of us so that it will become // linked to the manager through us (hopefully we are registered // with the manager), which in turn will allow it to export its // command-line options and get configured: addSubComponent(itsAGM); // tell the controller to export its options: itsAGM->exportOptions(MC_RECURSE); // some info message: LINFO("Selected AGM of type %s", itsAGMtype.getVal().c_str()); } }
// ###################################################################### void EyeHeadControllerConfigurator:: paramChanged(ModelParamBase* const param, const bool valueChanged, ParamClient::ChangeStatus* status) { ModelComponent::paramChanged(param, valueChanged, status); // was that a change of our baby's name? if (param == &itsEHctrlType) { // if we had one, let's unregister it (when we later reset() the // nub::ref, the current EyeHeadController will unexport its // command-line options): removeSubComponent(*itsEHC); // instantiate a controller of the appropriate type: if (itsEHctrlType.getVal().compare("None") == 0 || itsEHctrlType.getVal().compare("Stub") == 0) itsEHC.reset(new StubEyeHeadController(getManager())); else if (itsEHctrlType.getVal().compare("Simple") == 0) itsEHC.reset(new SimpleEyeHeadController(getManager())); else if (itsEHctrlType.getVal().compare("EyeTrack") == 0) itsEHC.reset(new EyeTrackerEyeHeadController(getManager())); else if (itsEHctrlType.getVal().compare("Monkey") == 0) itsEHC.reset(new MonkeyEyeHeadController(getManager())); else LFATAL("Unknown eye EyeHeadController type %s", itsEHctrlType.getVal().c_str()); // add our baby as a subcomponent of us so that it will become // linked to the manager through us (hopefully we are registered // with the manager), which in turn will allow it to export its // command-line options and get configured: addSubComponent(itsEHC); // tell the controller to export its options: itsEHC->exportOptions(MC_RECURSE); // some info message: LINFO("Selected Eye/Head Controller of type %s", itsEHctrlType.getVal().c_str()); } }
// ###################################################################### void PrefrontalCortexConfigurator::paramChanged(ModelParamBase* const param, const bool valueChanged, ParamClient::ChangeStatus* status) { ModelComponent::paramChanged(param, valueChanged, status); // was that a change of our baby's name? if (param == &itsType) { // let's unregister our existing PrefrontalCortex: removeSubComponent(*itsPFC); // instantiate a PrefrontalCortex of the appropriate type (when the old // PrefrontalCortex is destroyed, it will un-export its command-line // options): if (itsType.getVal().compare("Stub") == 0) // stub itsPFC.reset(new PrefrontalCortexStub(getManager())); else if (itsType.getVal().compare("OG") == 0) // Optimal Gains itsPFC.reset(new PrefrontalCortexOG(getManager())); else if (itsType.getVal().compare("GS") == 0) // Guided Search itsPFC.reset(new PrefrontalCortexGS(getManager())); else if (itsType.getVal().compare("SB") == 0) // SalBayes itsPFC.reset(new PrefrontalCortexSB(getManager())); else LFATAL("Unknown PrefrontalCortex type %s", itsType.getVal().c_str()); // add our baby as a subcomponent of us so that it will become // linked to the manager through us (hopefully we are registered // with the manager), which in turn will allow it to export its // command-line options and get configured: addSubComponent(itsPFC); // tell the controller to export its options: itsPFC->exportOptions(MC_RECURSE); // some info message: LINFO("Selected PFC of type %s", itsType.getVal().c_str()); } }