Debugging Code for Vex IQ

Hey folks, is there any way to debug IQ code? I am helping the team debug some of their functions. I was wondering if there was a way to look at variable values using a debugger instead of print commands?

We are currently using the recommended VexCode software, but if switching to VSCode etc. enables live debugging that we could happily switch.

Our robot mysteriously stops turning. We have a few places where we use “turn to heading 0”. Some work fine, and in some placed the brain just stalls at the turn function. For example:

  • Print starting to turn
  • Turn to heading 0
  • Print turn done.

In cases where the robot just stalls, we see that it is stuck on the turn command and the next print line isn’t executed. The battery is at 100% and there are no obstructions. We are trying to figure out a way to do precise turns, so usually when the gyro reports the brain is off by (1-10deg), we call turn to heading 0.

Any suggestions?

Debugging IQ code can be a bit tricky, but there are a few approaches you can take to make it easier:

Using VEXcode IQ: VEXcode IQ is the recommended software for VEX IQ robots. It provides a user-friendly interface and supports both graphical blocks and text-based coding in C++ and Python. While VEXcode IQ doesn’t have a built-in debugger, you can use print statements to track variable values and program flow.

Switching to VSCode: Visual Studio Code (VSCode) offers robust debugging capabilities, including live debugging. You can set breakpoints, inspect variables, and step through your code. To use VSCode for VEX IQ, you’ll need to set up the appropriate extensions and configure your project for debugging. This might involve creating a launch.json file to define your debugging configuration.

Collaborative Debugging with Live Share: If you’re working with a team, you can use Visual Studio Live Share to collaborate on debugging sessions. This allows multiple team members to inspect variables, set breakpoints, and step through code together.

Regarding your specific issue with the robot stalling at the “turn to heading 0” command, here are a few suggestions:

Check Sensor Calibration: Ensure that your gyro sensor is properly calibrated. An incorrect calibration can cause the robot to misinterpret its heading and stall.

Add Debugging Prints: While not as elegant as a debugger, adding more print statements can help you pinpoint where the issue occurs. For example, print the gyro sensor’s value before and after the turn command.

Review Code Logic: Double-check the logic in your turn function. Ensure that there are no conditions that could cause an infinite loop or prevent the function from completing.

Battery and Connections: Even though the battery is at 100%, check all connections to ensure there are no loose wires or faulty components that could affect the robot’s performance.