{"mode":"Blocks","workspace":"myVariableinertialLeftinertialRightinertialMultiplierdeadzoneThresholdProject:\n\nUsing MyBlocks (procedures & encapsulation)\nand Driving options and seeing what the robot sees via printoutsMotorArmholdMotorArmpct50MotorClawholdMotorClawpct25MotorSidewaysholdMotorSidewayspct25trueController1ButtonL1trueController1ButtonL2trueController1ButtonR1trueController1ButtonR21Controller1Axis31Controller1Axis41Controller1Axis1raise_boollower_boolControl Armnode_modules/@rm-vca/blockly/media/../../../../static/img/ui_imgs/elseif_blank.pngnode_modules/@rm-vca/blockly/media/../../../../static/img/ui_imgs/elseif_blank.pngnode_modules/@rm-vca/blockly/media/../../../../static/img/ui_imgs/elseif_add.pngraise_boolMotorArmfwdlower_boolMotorArmrevMotorArmfwdVelocityturnVelocityMotorLeftpct50fwdVelocityturnVelocityMotorLeftfwdMotorRightpct50fwdVelocityturnVelocityMotorRightfwdleftVelocityrightVelocityMotorLeftpct50leftVelocityMotorLeftfwdMotorRightpct50rightVelocityMotorRightfwdsideways_velocityMotorSidewayspct50sideways_velocityMotorSidewaysfwdopen_boolclose_boolcontrol Clawnode_modules/@rm-vca/blockly/media/../../../../static/img/ui_imgs/elseif_blank.pngnode_modules/@rm-vca/blockly/media/../../../../static/img/ui_imgs/elseif_blank.pngnode_modules/@rm-vca/blockly/media/../../../../static/img/ui_imgs/elseif_add.pngopen_boolMotorClawfwdclose_boolMotorClawrevMotorClawJ1_valueJ2_valueJ3_valueJ4_valueConsoleFALSEJ1: ConsoleFALSEJ1: J1_valueConsoleFALSE - J2: ConsoleFALSEJ1: J2_valueConsoleFALSE - J3: ConsoleFALSEJ1: J3_valueConsoleFALSE - J4: ConsoleTRUEJ1: J4_valueConsoleFALSE - Distance: ConsoleTRUEVEXcoderfForwardinConsoleFALSEClawHeight: ConsoleFALSEVEXcoderfClawHeightin","rconfig":[{"port":[13],"name":"MotorSideways","customName":true,"deviceType":"Motor","deviceClass":"motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio18_1"},"triportSourcePort":22},{"port":[2],"name":"MotorArm","customName":true,"deviceType":"Motor","deviceClass":"motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio36_1"},"triportSourcePort":22},{"port":[3],"name":"MotorClaw","customName":true,"deviceType":"Motor","deviceClass":"motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio18_1"},"triportSourcePort":22},{"port":[],"name":"Controller1","customName":false,"deviceType":"Controller","deviceClass":"controller","setting":{"left":"","leftDir":"false","right":"","rightDir":"false","upDown":"","upDownDir":"false","xB":"","xBDir":"false","drive":"none","id":"primary"},"triportSourcePort":22},{"port":[1,2],"name":"rfForward","customName":true,"deviceType":"RangeFinder","deviceClass":"sonar","setting":{"id":"partner"},"triportSourcePort":22},{"port":[3,4],"name":"rfClawHeight","customName":true,"deviceType":"RangeFinder","deviceClass":"sonar","setting":{"id":"partner"},"triportSourcePort":22},{"port":[11],"name":"MotorLeft","customName":true,"deviceType":"Motor","deviceClass":"motor","setting":{"reversed":"false","fwd":"forward","rev":"reverse","gear":"ratio18_1","id":"partner"}},{"port":[12],"name":"MotorRight","customName":true,"deviceType":"Motor","deviceClass":"motor","setting":{"reversed":"true","fwd":"forward","rev":"reverse","gear":"ratio18_1"}}],"slot":3,"platform":"V5","sdkVersion":"20220215.18.00.00","appVersion":"2.3.1","fileFormat":"1.0.1","icon":"","targetBrainGen":"First","cppStatus":"true","cpp":"// Make sure all required headers are included.\n#include \n#include \n#include \n#include \n#include \n\n\n#include \"vex.h\"\n\nusing namespace vex;\n\n// Brain should be defined by default\nbrain Brain;\n\n\n// START V5 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 V5 MACROS\n\n\n// Robot configuration code.\nmotor MotorSideways = motor(PORT13, ratio18_1, true);\n\nmotor MotorArm = motor(PORT2, ratio36_1, false);\n\nmotor MotorClaw = motor(PORT3, ratio18_1, false);\n\ncontroller Controller1 = controller(primary);\nsonar rfForward = sonar(Brain.ThreeWirePort.A);\nsonar rfClawHeight = sonar(Brain.ThreeWirePort.C);\nmotor MotorLeft = motor(PORT11, ratio18_1, false);\n\nmotor MotorRight = motor(PORT12, ratio18_1, true);\n\n\n\n\n// Generated code.\n\n\n\n\n// define variable for remote controller enable/disable\nbool RemoteControlCodeEnabled = true;\n\n\n// Include the V5 Library\n#include \"vex.h\"\n \n// Allows for easier use of the VEX Library\nusing namespace vex;\n\ncompetition Competition;\n\n// User defined function\nvoid myblockfunction_moveArm__raise_bool_lower_bool(bool myblockfunction_moveArm__raise_bool_lower_bool__raise_bool, bool myblockfunction_moveArm__raise_bool_lower_bool__lower_bool);\n// User defined function\nvoid myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity(double myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__fwdVelocity, double myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__turnVelocity);\n// User defined function\nvoid myblockfunction_DriveBaseTank__leftVelocity_rightVelocity(double myblockfunction_DriveBaseTank__leftVelocity_rightVelocity__leftVelocity, double myblockfunction_DriveBaseTank__leftVelocity_rightVelocity__rightVelocity);\n// User defined function\nvoid myblockfunction_moveSideways__velocity_sideways_velocity(double myblockfunction_moveSideways__velocity_sideways_velocity__sideways_velocity);\n// User defined function\nvoid myblockfunction_moveClaw__open_bool_close_bool(bool myblockfunction_moveClaw__open_bool_close_bool__open_bool, bool myblockfunction_moveClaw__open_bool_close_bool__close_bool);\n// User defined function\nvoid myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value(double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J1_value, double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J2_value, double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J3_value, double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J4_value);\n// User defined function\nvoid myblockfunction_ForwardDistancePrintout();\n// User defined function\nvoid myblockfunction_ClawHeightPrint();\n\nint Brain_precision = 0, Console_precision = 0, Controller1_precision = 0;\n\nfloat myVariable, inertialLeft, inertialRight, inertialMultiplier, deadzoneThreshold;\n\n// User defined function\nvoid myblockfunction_moveArm__raise_bool_lower_bool(bool myblockfunction_moveArm__raise_bool_lower_bool__raise_bool, bool myblockfunction_moveArm__raise_bool_lower_bool__lower_bool) {\n // Control Arm\n if (myblockfunction_moveArm__raise_bool_lower_bool__raise_bool) {\n MotorArm.spin(forward);\n } else if (myblockfunction_moveArm__raise_bool_lower_bool__lower_bool) {\n MotorArm.spin(reverse);\n } else {\n MotorArm.stop();\n }\n}\n\n// User defined function\nvoid myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity(double myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__fwdVelocity, double myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__turnVelocity) {\n MotorLeft.setVelocity((myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__fwdVelocity + myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__turnVelocity), percent);\n MotorLeft.spin(forward);\n MotorRight.setVelocity((myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__fwdVelocity - myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity__turnVelocity), percent);\n MotorRight.spin(forward);\n}\n\n// User defined function\nvoid myblockfunction_DriveBaseTank__leftVelocity_rightVelocity(double myblockfunction_DriveBaseTank__leftVelocity_rightVelocity__leftVelocity, double myblockfunction_DriveBaseTank__leftVelocity_rightVelocity__rightVelocity) {\n MotorLeft.setVelocity(myblockfunction_DriveBaseTank__leftVelocity_rightVelocity__leftVelocity, percent);\n MotorLeft.spin(forward);\n MotorRight.setVelocity(myblockfunction_DriveBaseTank__leftVelocity_rightVelocity__rightVelocity, percent);\n MotorRight.spin(forward);\n}\n\n// User defined function\nvoid myblockfunction_moveSideways__velocity_sideways_velocity(double myblockfunction_moveSideways__velocity_sideways_velocity__sideways_velocity) {\n MotorSideways.setVelocity(myblockfunction_moveSideways__velocity_sideways_velocity__sideways_velocity, percent);\n MotorSideways.spin(forward);\n}\n\n// User defined function\nvoid myblockfunction_moveClaw__open_bool_close_bool(bool myblockfunction_moveClaw__open_bool_close_bool__open_bool, bool myblockfunction_moveClaw__open_bool_close_bool__close_bool) {\n // control Claw\n if (myblockfunction_moveClaw__open_bool_close_bool__open_bool) {\n MotorClaw.spin(forward);\n } else if (myblockfunction_moveClaw__open_bool_close_bool__close_bool) {\n MotorClaw.spin(reverse);\n } else {\n MotorClaw.stop();\n }\n}\n\n// Used to find the format string for printing numbers with the\n// desired number of decimal places\nconst char* printToConsole_numberFormat() {\n // look at the current precision setting to find the format string\n switch(Console_precision){\n case 0: return \"%.0f\"; // 0 decimal places (1)\n case 1: return \"%.1f\"; // 1 decimal place (0.1)\n case 2: return \"%.2f\"; // 2 decimal places (0.01)\n case 3: return \"%.3f\"; // 3 decimal places (0.001)\n default: return \"%f\"; // use the print system default for everthing else\n }\n}\n\n// User defined function\nvoid myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value(double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J1_value, double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J2_value, double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J3_value, double myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J4_value) {\n printf(\"J1: \");\n printf(printToConsole_numberFormat(), static_cast(myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J1_value));\n printf(\" - J2: \");\n printf(printToConsole_numberFormat(), static_cast(myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J2_value));\n printf(\" - J3: \");\n printf(printToConsole_numberFormat(), static_cast(myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J3_value));\n printf(\" - J4: \");\n printf(printToConsole_numberFormat(), static_cast(myblockfunction_printJoystickValues__J1_value_J2_value_J3_value_J4_value__J4_value));\n printf(\"\\n\");\n}\n\n// User defined function\nvoid myblockfunction_ForwardDistancePrintout() {\n printf(\" - Distance: \");\n printf(printToConsole_numberFormat(), static_cast(rfForward.distance(inches)));\n printf(\"\\n\");\n}\n\n// User defined function\nvoid myblockfunction_ClawHeightPrint() {\n printf(\"ClawHeight: \");\n printf(printToConsole_numberFormat(), static_cast(rfClawHeight.distance(inches)));\n}\n\n// \"when started\" hat block\nint whenStarted1() {\n MotorArm.setStopping(hold);\n MotorArm.setVelocity(50.0, percent);\n MotorClaw.setStopping(hold);\n MotorClaw.setVelocity(25.0, percent);\n MotorSideways.setStopping(hold);\n MotorSideways.setVelocity(25.0, percent);\n return 0;\n}\n\n// \"when autonomous\" hat block\nint onauton_autonomous_0() {\n return 0;\n}\n\n// \"when driver control\" hat block\nint ondriver_drivercontrol_0() {\n while (true) {\n myblockfunction_moveArm__raise_bool_lower_bool(Controller1.ButtonL1.pressing(), Controller1.ButtonL2.pressing());\n myblockfunction_moveClaw__open_bool_close_bool(Controller1.ButtonR1.pressing(), Controller1.ButtonR2.pressing());\n myblockfunction_driveBaseArcade__fwdVelocity_turnVelocity(Controller1.Axis3.position(), Controller1.Axis4.position());\n myblockfunction_moveSideways__velocity_sideways_velocity(Controller1.Axis1.position());\n wait(5, msec);\n }\n return 0;\n}\n\nvoid VEXcode_driver_task() {\n // Start the driver control tasks....\n vex::task drive0(ondriver_drivercontrol_0);\n\n\n while(Competition.isDriverControl() && Competition.isEnabled()) {this_thread::sleep_for(10);}\n drive0.stop();\n return;\n}\n\nvoid VEXcode_auton_task() {\n // Start the auton control tasks....\n vex::task auto0(onauton_autonomous_0);\n while(Competition.isAutonomous() && Competition.isEnabled()) {this_thread::sleep_for(10);}\n auto0.stop();\n return;\n}\n\n\n\nint main() {\n vex::competition::bStopTasksBetweenModes = false;\n Competition.autonomous(VEXcode_auton_task);\n Competition.drivercontrol(VEXcode_driver_task);\n\n // post event registration\n\n // set default print color to black\n printf(\"\\033[30m\");\n\n // wait for rotation sensor to fully initialize\n wait(30, msec);\n\n whenStarted1();\n}","target":"Physical"}