{"mode":"Blocks","hardwareTarget":"brain","workspace":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable id=\"_2.^beQjx|FGt38A,8(E\">myVariable</variable><variable id=\"i!+fr@4x_goQ2$X5^;G.\">block</variable></variables><block type=\"iq_events_when_started\" id=\".NsXwU_L.OuU1l7Sho$F\" x=\"70\" y=\"-10\"><next><block type=\"iq_other_comment\" id=\"Bw|5s|=J!!lYrF,Ek9Tz\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"=`.$^RRM!EPE)a8o$Ol,\"><field name=\"comment\">Turn on the Optical light to allow it to see the block color better</field></shadow></value><next><block type=\"iq_sensing_optical_set_light\" id=\"W}u#IT7FS(c%IPTDug,r\"><field name=\"OPTICAL\">Optical2</field><field name=\"OPTION\">on</field><next><block type=\"iq_control_repeat\" id=\"2rSC#L6sijldm8=rhXD;\"><value name=\"TIMES\"><shadow type=\"math_whole_number\" id=\"+#=FwQ!,DJ-.Cm0gF)A7\"><field name=\"NUM\">5</field></shadow></value><statement name=\"SUBSTACK\"><block type=\"iq_other_comment\" id=\"F6f1Z$^2-G+lfMCahQ#z\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"z=/=6gUe_MHU#6U0fYyf\"><field name=\"comment\">Move to the block</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"u3=3Gu1yFHOK42c:qn+]\"><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"e45S50(l4=|q;UXGiYpd\"><field name=\"NUM\">305</field></shadow></value><next><block type=\"iq_drivetrain_turn_for\" id=\"))U^{%ZkZpTh;uO@Xxf+\"><field name=\"TURNDIRECTION\">left</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"dBQk1Aa(nBW0MWqz)ma1\"><field name=\"NUM\">90</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\")gUXsx)MyOJ~UQTXAz7}\"><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"v~@gN0v~bknUC:kU%Q=Z\"><field name=\"NUM\">150</field></shadow></value><next><block type=\"iq_control_wait\" id=\"`dnU0H#0[o+rZ){{kt3{\"><value name=\"DURATION\"><shadow type=\"math_positive_number\" id=\"iN8HD%$*L^eTxvkE@!71\"><field name=\"NUM\">1</field></shadow></value><next><block type=\"iq_other_comment\" id=\"N?,2E3zvtFP!HshGyZYf\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"tP+hPRvlJka{FpdkcDmH\"><field name=\"comment\">Detects if the block color is red</field></shadow></value><next><block type=\"iq_control_if_then_else\" id=\"!TWiDq}*#0#i[(n%3*ai\"><value name=\"CONDITION\"><block type=\"iq_sensing_optical_detect\" id=\"H,8]a%9!50^0nuBDQ,@1\"><field name=\"OPTICAL\">Optical2</field><field name=\"COLORS\">red</field></block></value><statement name=\"SUBSTACK\"><block type=\"iq_other_comment\" id=\"X;COyI{?RCE{7Zw9glf[\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"kV!jDI^buASO=+DJVtDX\"><field name=\"comment\">If the block is red the claw will close</field></shadow></value><next><block type=\"iq_motion_spin_for\" id=\"jv]oU.NTAU~xNThh(M7*\"><field name=\"MOTOR\">ClawMotor</field><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">deg</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"GPOGq})MzEX4CGoay$iU\"><field name=\"NUM\">30</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"/c`.SK;$Gwi1tKGpA!mI\"><field name=\"DIRECTION\">rev</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"FV9xl2OEZE5(2nXY2g?H\"><field name=\"NUM\">150</field></shadow></value><next><block type=\"iq_drivetrain_turn_for\" id=\"X!)Veq},_ItX=*mm[=b!\"><field name=\"TURNDIRECTION\">right</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"d[;}9daoVs(Z(4MV~S+#\"><field name=\"NUM\">180</field></shadow></value><next><block type=\"iq_other_comment\" id=\"XfLyXQTA6{3XxRF#jq.[\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"hq/D38O|ii%^7KNpx3F!\"><field name=\"comment\">Drive to the other side of the Field</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"BIzL5viX_(|RuPs(!cnt\"><field name=\"DIRECTION\">fwd</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"2=yF6?P4n`2Ak}k)uN+3\"><field name=\"NUM\">150</field></shadow></value><next><block type=\"iq_other_comment\" id=\"[}u1a/Kocfv]cwQoVUm4\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"Ev,f2D*/hJj.}#:Uz9ud\"><field name=\"comment\">Open the claw and go back to the center of the Field</field></shadow></value><next><block type=\"iq_motion_spin_to_position\" id=\"eM0.4v_tRm69-V0AUyfU\"><field name=\"MOTOR\">ClawMotor</field><field name=\"UNITS\">deg</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"B,;$r2zG7}zibNO_VN*I\"><field name=\"NUM\">0</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"3)xs|rXxi`]y=Oi[-^K(\"><field name=\"DIRECTION\">rev</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"}6[4:uh{@HS,V7.0!?w}\"><field name=\"NUM\">150</field></shadow></value><next><block type=\"iq_drivetrain_turn_for\" id=\"FKnr_@~2a?j$16B8aST/\"><field name=\"TURNDIRECTION\">left</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"ZJj*X|:ikCkPy|PMp0/7\"><field name=\"NUM\">90</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement><statement name=\"SUBSTACK2\"><block type=\"iq_other_comment\" id=\"_V)WH3VI*M3SbfCz{Mz)\"><value name=\"COMMENT\"><shadow type=\"comment_text\" id=\"Dy+[W~qF:HBVxY1z8((g\"><field name=\"comment\">If the block is not red then the robot will drive back to the center</field></shadow></value><next><block type=\"iq_drivetrain_drive_for\" id=\"(AFh?:kOe,a#dWL$le:6\"><field name=\"DIRECTION\">rev</field><field name=\"UNITS\">mm</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"vXc^q,)xBLN8B%|jNiB.\"><field name=\"NUM\">150</field></shadow></value><next><block type=\"iq_drivetrain_turn_for\" id=\"p{k~:fpBNei;L^%W+y+@\"><field name=\"TURNDIRECTION\">right</field><field name=\"anddontwait_mutator\">false</field><value name=\"AMOUNT\"><shadow type=\"math_number\" id=\"0AX4zO0.nZ#gw%tjp)!j\"><field name=\"NUM\">90</field></shadow></value></block></next></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></next></block></next></block></next></block></xml>","robotConfig":[{"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":[4],"name":"ClawMotor","customName":true,"deviceType":"Motor","deviceClass":"motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse"},"triportSourcePort":22},{"port":[2],"name":"Optical2","customName":false,"deviceType":"Optical","deviceClass":"optical","setting":{},"triportSourcePort":22}],"slot":0,"platform":"IQ","sdkVersion":"20230818.11.00.00","appVersion":"4.0.7","minVersion":"3.0.0","fileFormat":"1.3.0","targetBrainGen":"Second","v5SoundsEnabled":false,"downloadLanguage":"python","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\nmotor ClawMotor = motor(PORT4, false);\noptical Optical2 = optical(PORT2);\n\n\n// generating and setting random seed\nvoid initializeRandomSeed(){\n  wait(100,msec);\n  double xAxis = BrainInertial.acceleration(xaxis) * 1000;\n  double yAxis = BrainInertial.acceleration(yaxis) * 1000;\n  double zAxis = BrainInertial.acceleration(zaxis) * 1000;\n  // Combine these values into a single integer\n  int seed = int(\n    xAxis + yAxis + zAxis\n  );\n  // Set the seed\n  srand(seed); \n}\n\nbool vexcode_initial_drivetrain_calibration_completed = false;\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  vexcode_initial_drivetrain_calibration_completed = true;\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\nvoid vexcodeInit() {\n\n  // Calibrate the Drivetrain\n  calibrateDrivetrain();\n\n  // Initializing random seed.\n  initializeRandomSeed(); \n}\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, block;\n\n// \"when started\" hat block\nint whenStarted1() {\n  // Turn on the Optical light to allow it to see the block color better\n  Optical2.setLight(ledState::on);\n  repeat(5) {\n    // Move to the block\n    Drivetrain.driveFor(forward, 305.0, mm, true);\n    Drivetrain.turnFor(left, 90.0, degrees, true);\n    Drivetrain.driveFor(forward, 150.0, mm, true);\n    wait(1.0, seconds);\n    // Detects if the block color is red\n    if (Optical2.color() == red) {\n      // If the block is red the claw will close\n      ClawMotor.spinFor(forward, 30.0, degrees, true);\n      Drivetrain.driveFor(reverse, 150.0, mm, true);\n      Drivetrain.turnFor(right, 180.0, degrees, true);\n      // Drive to the other side of the Field\n      Drivetrain.driveFor(forward, 150.0, mm, true);\n      // Open the claw and go back to the center of the Field\n      ClawMotor.spinToPosition(0.0, degrees, true);\n      Drivetrain.driveFor(reverse, 150.0, mm, true);\n      Drivetrain.turnFor(left, 90.0, degrees, true);\n    }\n    else {\n      // If the block is not red then the robot will drive back to the center\n      Drivetrain.driveFor(reverse, 150.0, mm, true);\n      Drivetrain.turnFor(right, 90.0, degrees, true);\n    }\n    wait(20, msec);\n  }\n  return 0;\n}\n\n\nint main() {\n  // Initializing Robot Configuration. DO NOT REMOVE!\n  vexcodeInit();\n\n  whenStarted1();\n}","target":"Physical"}