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.
नमूना: एक रोबोट के लिए सीधी दूरी तक जाने का एक नमूना कार्यक्रम
निम्नलिखित फ़ंक्शन रोबोट कोtotalEncएनकोडर के लिए आगे चलने की अनुमति देगा। यह V5 क्लॉबोट कॉन्फ़िगरेशन का उपयोग करता है।
यहspinToPositionफ़ंक्शन तब तक वापस नहीं आएगा जब तक कि गति पूरी नहीं हो जाती। इसे "सिंक्रोनाइज़्ड" क्रिया कहा जाता है - जो अंतिम पैरामीटरtrueद्वारा निर्धारित होती है।
उपयोगकर्ता-परिभाषित फ़ंक्शन का उपयोग किए बिना:
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(डिग्री));
wait(1000, मिसे);
LeftMotor.resetPosition();
LeftMotor.setVelocity(-100.0, प्रतिशत);
LeftMotor.spinToPosition(-1000.0, c, सत्य);
Brain.Screen.printAt(5,100, "सेकंड रेव डिग्री" );
Brain.Screen.printAt(5,130, "%%.2f: %8.2f %8.2f",
Brain.Timer.value(),
LeftMotor.position(rev),
LeftMotor.position(deg));
wait(1000, मिसे);
}
नमूना निम्नलिखित परिणाम दे सकता है:
सेकंड रॉ रेव डिग्री 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, प्रतिशत);
LeftMotor.spinToPosition(500.0, डिग्री, सत्य);
reportMotionValues();
LeftMotor.resetPosition();
LeftMotor.setVelocity(-50.0, प्रतिशत);
LeftMotor.spinToPosition(-500.0, डिग्री, सत्य);
reportMotionValues();
}
यहां कॉलर फ़ंक्शन main() से तर्क प्रवाह का अनुक्रम दिखाया गया है: