{"mode":"Blocks","workspace":"<xml xmlns=\"http://www.w3.org/1999/xhtml\"><variables><variable type=\"\" id=\"_2.^beQjx|FGt38A,8(E\" islocal=\"false\" iscloud=\"false\" arraylength=\"0\" arraywidth=\"0\">myVariable</variable></variables><block type=\"iq_events_when_started\" id=\".NsXwU_L.OuU1l7Sho$F\" x=\"70\" y=\"-10\"><next><block type=\"iq_sensing_optical_set_light\" id=\"IVt^7xzM{[qNow*lY_;a\"><field name=\"OPTICAL\">Optical4</field><field name=\"OPTION\">on</field><next><block type=\"iq_sensing_optical_set_light_power\" id=\"wh(7lM=eK=Q@z;gs:#n:\"><field name=\"OPTICAL\">Optical4</field><value name=\"POWER\"><shadow type=\"math_number\" id=\"TE^xx!VMFw@G5Y_;9suJ\"><field name=\"NUM\">75</field></shadow></value><next><block type=\"iq_drivetrain_set_turn_velocity\" id=\"ptebyINji$n34o+y!+|G\"><field name=\"UNITS\">pct</field><value name=\"VELOCITY\"><shadow type=\"math_number\" id=\"$SsL2tI6(l{RS?#%%Ljd\"><field name=\"NUM\">10</field></shadow></value><next><block type=\"iq_control_forever\" id=\"CsuK[zn}J*!WUShTeEXc\"><statement name=\"SUBSTACK\"><block type=\"iq_other_comment\" id=\"25{o;51hXwN7#@{N0$[C\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"zd)|aWXyQfHLSE`}[QM+\"><field name=\"comment\">Turn right until a cube is detected</field></shadow></value><next><block type=\"iq_drivetrain_turn\" id=\"OE!b3Vv]x]2#-RXB1FGv\"><field name=\"TURNDIRECTION\">right</field><next><block type=\"iq_control_wait_until\" id=\"`FxZUloVrWW9At%5)?~*\"><value name=\"CONDITION\"><block type=\"iq_operator_less_than\" id=\"^8Uar:!Ji*XgN=EXkp|d\"><value name=\"OPERAND1\"><shadow type=\"math_number\" id=\".p_`I^kw02V7}+p!`7ro\"><field name=\"NUM\"></field></shadow><block type=\"iq_sensing_distance_object_distance\" id=\"NlqZPZhSW^b]ql)_FGQo\"><field name=\"DISTANCE\">Distance3</field><field name=\"UNITS\">mm</field></block></value><value name=\"OPERAND2\"><shadow type=\"math_number\" id=\"8%1tvJ:PRsnyMjHzegN,\"><field name=\"NUM\">600</field></shadow></value></block></value><next><block type=\"iq_other_comment\" id=\"sJSx]xx!)f!oRaD*nPkb\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"UfO..rtZ[Z-_6u0.8P$L\"><field name=\"comment\">Turn a little more to center the cube</field></shadow></value><next><block type=\"iq_drivetrain_turn_for\" id=\"97+2_tuOA`fHhg[?8X%:\"><field name=\"TURNDIRECTION\">right</field><field name=\"anddontwait_mutator\">FALSE</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"p84Jy4;2OMRWRXwSJr9@\"><field name=\"NUM\">10</field></shadow></value><next><block type=\"iq_other_comment\" id=\"I3{k~!~dB{|Z5CL@hE$6\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"+u{Q_Nu.az^oki7QB%:%\"><field name=\"comment\">Move closer to the cube</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"j^ki1zEH;q)yALFzE2OH\"><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">FALSE</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"Cx3G4sk3v#aniD7+o6rZ\"><field name=\"NUM\">200</field></shadow><block type=\"iq_sensing_distance_object_distance\" id=\"DWjJeR8kn*{5ma()fum^\"><field name=\"DISTANCE\">Distance3</field><field name=\"UNITS\">mm</field></block></value><next><block type=\"iq_other_comment\" id=\"w|fk{Y#{?:M_-el;T3Y0\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"DovFm2eOrgp)CxinRZnz\"><field name=\"comment\">Move forward until the Distance Sensor does not detect a cube</field></shadow></value><next><block type=\"iq_other_comment\" id=\"muOJX29AK[^i%RJHm}75\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"_vDGzCd~^+Mx)?R!sqhC\"><field name=\"comment\">and the Optical Sensor does not detect the field</field></shadow></value><next><block type=\"iq_drivetrain_drive\" id=\"v4T0!Z.fBB@,w3=nCo*;\"><field name=\"DIRECTION\">fwd</field><next><block type=\"iq_control_wait_until\" id=\"FMOYQ2~@YM8OM+G0u4rU\"><value name=\"CONDITION\"><block type=\"iq_operator_and\" id=\"}4tm_Y9ay5Ig^i.0b:Tu\"><value name=\"OPERAND1\"><block type=\"iq_operator_greater_than\" id=\"%(I%i+l^|^iu0+CO*ck(\"><value name=\"OPERAND1\"><shadow type=\"math_number\" id=\"=a4xZP46I9{V|-.5N@4D\"><field name=\"NUM\"></field></shadow><block type=\"iq_sensing_distance_object_distance\" id=\"u^uxo+Ec0mk/?@{N(+V7\"><field name=\"DISTANCE\">Distance3</field><field name=\"UNITS\">mm</field></block></value><value name=\"OPERAND2\"><shadow type=\"math_number\" id=\"ZSp!BjkR(u6RbL8P7ifL\"><field name=\"NUM\">200</field></shadow></value></block></value><value name=\"OPERAND2\"><block type=\"iq_operator_not\" id=\"#A3h}x2t74s$)O*$betI\"><value name=\"OPERAND\"><block type=\"iq_sensing_optical_found_object\" id=\"*C]_N8X^RE`gJ:qM-GD;\"><field name=\"OPTICAL\">Optical4</field></block></value></block></value></block></value><next><block type=\"iq_other_comment\" id=\"?`I(I*X@M8Y`drBXQ%n`\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"]6b_QLU-lDg_hQXi4j}g\"><field name=\"comment\">Move away from the edge of the Field</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"Z$f`YG0/hW53fcgn*bKa\"><field name=\"DIRECTION\">rev</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">FALSE</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"!A5(,r4L3Do[JmDKir8-\"><field name=\"NUM\">400</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></next></block></next></block></next></block></next></block></xml>","rconfig":[{"port":[1,6,0],"name":"Drivetrain","customName":false,"deviceType":"Drivetrain","deviceClass":"smartdrive","setting":{"type":"2-motor","wheelSize":"200mm","gearRatio":"1:1","direction":"fwd","gyroType":"integrated","width":"173","unit":"mm","wheelbase":"76","wheelbaseUnit":"mm","xOffset":"0","yOffset":"0","thetaOffset":"0"},"triportSourcePort":22},{"port":[3],"name":"Distance3","customName":false,"deviceType":"Distance","deviceClass":"distance","setting":{},"triportSourcePort":22},{"port":[4],"name":"Optical4","customName":false,"deviceType":"Optical","deviceClass":"optical","setting":{},"triportSourcePort":22}],"slot":0,"platform":"IQ","sdkVersion":"20220726.10.00.00","appVersion":"2.4.5","minVersion":"2.4.0","fileFormat":"1.2.0","icon":"","targetBrainGen":"Second","cppStatus":"true","cpp":"// Make sure all required headers are included.\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdbool.h>\n#include <math.h>\n#include <string.h>\n\n\n#include \"vex.h\"\n\nusing namespace vex;\n\n// Brain should be defined by default\nbrain Brain;\n\n\n// START IQ MACROS\n#define waitUntil(condition)                                                   \\\n  do {                                                                         \\\n    wait(5, msec);                                                             \\\n  } while (!(condition))\n\n#define repeat(iterations)                                                     \\\n  for (int iterator = 0; iterator < iterations; iterator++)\n// END IQ MACROS\n\n\n// Robot configuration code.\ninertial BrainInertial = inertial();\nmotor LeftDriveSmart = motor(PORT1, 1, false);\nmotor RightDriveSmart = motor(PORT6, 1, true);\n\nsmartdrive Drivetrain = smartdrive(LeftDriveSmart, RightDriveSmart, BrainInertial, 200);\n\ndistance Distance3 = distance(PORT3);\noptical Optical4 = optical(PORT4);\n\nvoid calibrateDrivetrain() {\n  wait(200, msec);\n  Brain.Screen.print(\"Calibrating\");\n  Brain.Screen.newLine();\n  Brain.Screen.print(\"Inertial\");\n  BrainInertial.calibrate();\n  while (BrainInertial.isCalibrating()) {\n    wait(25, msec);\n  }\n\n  // Clears the screen and returns the cursor to row 1, column 1.\n  Brain.Screen.clearScreen();\n  Brain.Screen.setCursor(1, 1);\n}\n\n// Generated code.\n\n// Include the IQ Library\n#include \"vex.h\"\n  \n// Allows for easier use of the VEX Library\nusing namespace vex;\n\nfloat myVariable;\n\n// \"when started\" hat block\nint whenStarted1() {\n  Optical4.setLight(ledState::on);\n  Optical4.setLightPower(75.0, percent);\n  Drivetrain.setTurnVelocity(10.0, percent);\n  while (true) {\n    // Turn right until a cube is detected\n    Drivetrain.turn(right);\n    waitUntil((Distance3.objectDistance(mm) < 600.0));\n    // Turn a little more to center the cube\n    Drivetrain.turnFor(right, 10.0, degrees);\n    // Move closer to the cube\n    Drivetrain.driveFor(forward, Distance3.objectDistance(mm), mm);\n    // Move forward until the Distance Sensor does not detect a cube\n    // and the Optical Sensor does not detect the field\n    Drivetrain.drive(forward);\n    waitUntil((Distance3.objectDistance(mm) > 200.0 && !Optical4.isNearObject()));\n    // Move away from the edge of the Field\n    Drivetrain.driveFor(reverse, 400.0, mm);\n  wait(20, msec);\n  }\n  return 0;\n}\n\n\nint main() {\n  // Calibrate the Drivetrain Gyro\n  calibrateDrivetrain();\n\n  whenStarted1();\n}","target":"Physical"}