SoBoolOperation SoGate SoElapsedTime

/*-------------------------------------------------------------- * Boolean engine. Derived from example 13.5. * The smaller duck stays still while the bigger duck moves, * and starts moving as soon as the bigger duck stops. *------------------------------------------------------------*/ #include <Inventor/SoDB.h> #include <Inventor/Win/SoWin.h> #include <Inventor/Win/SoWinRenderArea.h> #include <Inventor/engines/SoBoolOperation.h> #include <Inventor/engines/SoCompose.h> #include <Inventor/engines/SoElapsedTime.h> #include <Inventor/engines/SoGate.h> #include <Inventor/events/SoMouseButtonEvent.h> #include <Inventor/nodes/SoCylinder.h> #include <Inventor/nodes/SoDirectionalLight.h> #include <Inventor/nodes/SoEventCallback.h> #include <Inventor/nodes/SoMaterial.h> #include <Inventor/nodes/SoPerspectiveCamera.h> #include <Inventor/nodes/SoRotationXYZ.h> #include <Inventor/nodes/SoSeparator.h> #include <Inventor/nodes/SoSphere.h> #include <Inventor/nodes/SoTransform.h> #include <Inventor/nodes/SoTranslation.h> #ifdef WIN32 # include "print.h" #endif void myMousePressCB(void *, SoEventCallback *); int main(int, char **argv) { // Print out usage message printf("Only one duck can move at a time./n"); printf("Click the left mouse button to toggle between the two ducks./n"); // Initialize Inventor and Win HWND myWindow = SoWin::init(argv[0]); if (myWindow == NULL) exit(1); SoSeparator *root = new SoSeparator; root->ref(); // Add a camera and light SoPerspectiveCamera *myCamera = new SoPerspectiveCamera; myCamera->position.setValue(0.0f, -4.0f, 8.0f); myCamera->heightAngle = (float)(M_PI/2.5f); myCamera->nearDistance = 1.0f; myCamera->farDistance = 15.0f; root->addChild(myCamera); root->addChild(new SoDirectionalLight); // Rotate scene slightly to get better view SoRotationXYZ *globalRotXYZ = new SoRotationXYZ; globalRotXYZ->axis = SoRotationXYZ::X; globalRotXYZ->angle = (float)(M_PI/9.0f); root->addChild(globalRotXYZ); // Pond group SoSeparator *pond = new SoSeparator; root->addChild(pond); SoTranslation *pondTranslation = new SoTranslation; pondTranslation->translation.setValue(0.0f, -6.725f, 0.0f); pond->addChild(pondTranslation); // water SoMaterial *waterMaterial = new SoMaterial; waterMaterial->diffuseColor.setValue(0.0f, 0.3f, 0.8f); pond->addChild(waterMaterial); SoCylinder *waterCylinder = new SoCylinder; waterCylinder->radius.setValue(4.0f); waterCylinder->height.setValue(0.5f); pond->addChild(waterCylinder); // rock SoMaterial *rockMaterial = new SoMaterial; rockMaterial->diffuseColor.setValue(0.8f, 0.23f, 0.03f); pond->addChild(rockMaterial); SoSphere *rockSphere = new SoSphere; rockSphere->radius.setValue(0.9f); pond->addChild(rockSphere); // Read the duck object from a file and add to the group SoInput myInput; if (!myInput.openFile("../data/duck.iv")) exit (1); SoSeparator *duckObject = SoDB::readAll(&myInput); if (duckObject == NULL) exit (1); ///////////////////////////////////////////////////////////// // CODE FOR The Inventor Mentor STARTS HERE // Bigger duck group SoSeparator *bigDuck = new SoSeparator; root->addChild(bigDuck); SoRotationXYZ *bigDuckRotXYZ = new SoRotationXYZ; bigDuck->addChild(bigDuckRotXYZ); SoTransform *bigInitialTransform = new SoTransform; bigInitialTransform->translation.setValue(0.0f, 0.0f, 3.5f); bigInitialTransform->scaleFactor.setValue(6.0f, 6.0f, 6.0f); bigDuck->addChild(bigInitialTransform); bigDuck->addChild(duckObject); // Smaller duck group SoSeparator *smallDuck = new SoSeparator; root->addChild(smallDuck); SoRotationXYZ *smallDuckRotXYZ = new SoRotationXYZ; smallDuck->addChild(smallDuckRotXYZ); SoTransform *smallInitialTransform = new SoTransform; smallInitialTransform->translation.setValue(0.0f, -2.24f, 1.5f); smallInitialTransform->scaleFactor.setValue(4.0f, 4.0f, 4.0f); smallDuck->addChild(smallInitialTransform); smallDuck->addChild(duckObject); // Use a gate engine to start/stop the rotation of // the bigger duck. SoGate *bigDuckGate = new SoGate(SoMFFloat::getClassTypeId()); SoElapsedTime *bigDuckTime = new SoElapsedTime; bigDuckGate->input->connectFrom(&bigDuckTime->timeOut); bigDuckRotXYZ->axis = SoRotationXYZ::Y; // Y axis bigDuckRotXYZ->angle.connectFrom(bigDuckGate->output); // Each mouse button press will enable/disable the gate // controlling the bigger duck. SoEventCallback *myEventCB = new SoEventCallback; myEventCB->addEventCallback( SoMouseButtonEvent::getClassTypeId(), myMousePressCB, bigDuckGate); root->addChild(myEventCB); // Use a Boolean engine to make the rotation of the smaller // duck depend on the bigger duck. The smaller duck moves // only when the bigger duck is still. SoBoolOperation *myBoolean = new SoBoolOperation; myBoolean->a.connectFrom(&bigDuckGate->enable); myBoolean->operation = SoBoolOperation::NOT_A; SoGate *smallDuckGate = new SoGate(SoMFFloat::getClassTypeId()); SoElapsedTime *smallDuckTime = new SoElapsedTime; smallDuckGate->input->connectFrom(&smallDuckTime->timeOut); smallDuckGate->enable.connectFrom(&myBoolean->output); smallDuckRotXYZ->axis = SoRotationXYZ::Y; // Y axis smallDuckRotXYZ->angle.connectFrom(smallDuckGate->output); // CODE FOR The Inventor Mentor ENDS HERE ///////////////////////////////////////////////////////////// SoWinRenderArea *myRenderArea = new SoWinRenderArea(myWindow); myRenderArea->setSceneGraph(root); myRenderArea->setTitle("Duck and Duckling"); myRenderArea->show(); SoWin::show(myWindow); SoWin::mainLoop(); return 0; } // This routine is called for every mouse button event. void myMousePressCB(void *userData, SoEventCallback *eventCB) { SoGate *gate = (SoGate *) userData; const SoEvent *event = eventCB->getEvent(); // Check for mouse button being pressed if (SO_MOUSE_PRESS_EVENT(event, ANY)) { // Toggle the gate that controls the duck motion if (gate->enable.getValue()) gate->enable.setValue(FALSE); else gate->enable.setValue(TRUE); eventCB->setHandled(); } }

内容概要:本文围绕“基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究”展开,提出了一种结合Koopman算子理论与递归神经网络(RNN)的数据驱动建模方法,旨在对非线性纳米定位系统进行有效线性化建模,并实现高精度的模型预测控制(MPC)。该方法利用Koopman算子将非线性系统映射到高维线性空间,通过递归神经网络学习系统的动态演化规律,构建可解释性强、计算效率高的线性化模型,进而提升预测控制在复杂不确定性环境下的鲁棒性与跟踪精度。文中给出了完整的Matlab代码实现,涵盖数据预处理、网络训练、模型验证与MPC控制器设计等环节,具有较强的基于数据驱动的 Koopman 算子的递归神经网络模型线性化,用于纳米定位系统的预测控制研究(Matlab代码实现)可复现性和工程应用价值。; 适合人群:具备一定控制理论基础和Matlab编程能力的研究生、科研人员及自动化、精密仪器、机器人等方向的工程技术人员。; 使用场景及目标:①解决高精度纳米定位系统中非线性动态响应带来的控制难题;②实现复杂机电系统的数据驱动建模与预测控制一体化设计;③为非线性系统控制提供一种可替代传统机理建模的有效工具。; 阅读建议:建议结合提供的Matlab代码逐模块分析实现流程,重点关注Koopman观测矩阵构造、RNN网络结构设计与MPC控制器耦合机制,同时可通过替换实际系统数据进行迁移验证,深化对数据驱动控制方法的理解与应用能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值