The VEX Visual Studio Code Extension has replaced VEXcode Pro V5, which is now end-of-life.
VEXcode Blocks and VEXcode Text remain actively developed and supported for all VEX platforms.
उदाहरण: एक रोबोट द्वारा सीधी दूरी तय करने के लिए एक नमूना प्रोग्राम
निम्नलिखित फ़ंक्शन रोबोट कोटोटलएनकएनकोडर के लिए आगे की ओर चलने की अनुमति देगा। यह V5 क्लॉबोट कॉन्फ़िगरेशन का उपयोग करता है।
यहspinToPositionफ़ंक्शन तब तक वापस नहीं आएगा जब तक गति पूरी नहीं हो जाती। इसे “सिंक्रनाइज़्ड” क्रिया कहा जाता है – जो अंतिम पैरामीटरसत्य द्वारा निर्धारित होती है।
उपयोगकर्ता-परिभाषित फ़ंक्शन का उपयोग किए बिना:
int main() {
vexcodeInit();
LeftMotor.resetPosition();
LeftMotor.setVelocity(100.0, प्रतिशत);
LeftMotor.spinToPosition(500.0, डिग्री, सही);
Brain.Screen.printAt(5,30, "सेकंड रेव डिग्री");
Brain.Screen.printAt(5,60, "%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
wait(1000, मिलीसेकंड);
LeftMotor.resetPosition();
LeftMotor.setVelocity(-100.0, प्रतिशत);
LeftMotor.spinToPosition(-1000.0, c, सही); }
Brain.Screen.printAt(5,100, "secs rev deg" );
Brain.Screen.printAt(5,130, "%%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
wait(1000, msec);
}
इस नमूने से निम्नलिखित परिणाम प्राप्त हो सकते हैं:
सेकंड रॉ रेव डिग्री
2.06 5445 3.12 1089
कृपया ध्यान रखें कि आपका परीक्षण दशमलव स्थानों में बहुत छोटे अंतर से भिन्न होगा।
उपयोगकर्ता-परिभाषित फ़ंक्शन के साथ:
निम्नलिखित नमूना दिखाता है कि संचालन के एक सेट को एकल पुन: प्रयोज्य "फ़ंक्शन" कॉल में कैसे कैप्चर किया जाए।
void reportMotionValues() {
Brain.Screen.printAt(5, 60, "%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
}
int main() {
vexcodeInit();
LeftMotor.resetPosition();
LeftMotor.setVelocity(50.0, percent);
LeftMotor.spinToPosition(500.0, deg, true);
reportMotionValues();
LeftMotor.resetPosition ();
LeftMotor.setVelocity(-50.0, percent);
LeftMotor.spinToPosition(-500.0, deg, true);
reportMotionValues();
}
नीचे दिया गया वीडियो दिखाता है कि कॉलर फ़ंक्शन main() से लॉजिक का क्रम कैसे आगे बढ़ता है: