I am under the impression the EXP brain has a built-in gyro which can be used to help program the robot so it will drive in a particular direction. Can someone direct me to information/example codes that will help us achieve this? Thank you.
Hi @Curt_Kornhaus! Great question
Yes, the EXP Brain does have a built-in inertial sensor. First you’ll need to ensure your configuration is correct in VEXcode EXP. To do this, I would use a template (depending on what robot you’re using).
For ease of explanation, i’ll say the BaseBot. Next, you can go to File > Open Examples.
Then you can select the BaseBot template.
From here, you can now see in the config that the built-in inertial sensor.
I cover all of the above in this video.
For more detailed information about the inertial sensor, you can check out this article. This article also talks about the different blocks you can use in VEXcode EXP with the inertial sensor data.
If you’re new to EXP, I would also recommend the Introduction to VEX EXP Training Course
I hope all of this is helpful!
Thank you for your response. Is there an example for C++? I feel more comfortable with text based coding.
Hello! Yes there is
In this article, there are examples for all three coding languages (Blocks, C++, and Python).
To access C++ on EXP, simply select File > New Text Project > C++.
We also have the C++ Tutorial section in the VEX Library.
Accessing examples project and templates are also the same across all languages.
I would also suggest booking a 1-1 Session if you’d like for one of us to walk you through all of this!
Great! This will help big time. I noticed in your response that you were using a drivetrain. Is it possible to use independent motor commands with the same result?
That is a good question. This is something that we have been considering exposing in VEXcode projects, but we need to work out a few details before we can start to work on that. However, since you are using C++ projects, you can directly access the motors used by the drivetrain. You can see the motors for the drive train in the collapsed configuration section of the project.
So you can use any of the motor methods directly on those motor instances just like you would for a normal motor. Say you want the left motor to spin for 1 full rotation, you could use LeftDriveSmart.spinFor(forward, 1, turns);
. This would have only the left drive motor spin.
A few things to keep in mind.
- You will not get any autocomplete suggestions for them since the autocomplete system does not know that they exist
- This will not include any drivetrain gear ratios configured for the drivetrain for the motor commands
- You will need to calculate how far to spin each motor for the desired movement
- You may get unexpected results if you have the drivetrain commanded to drive for a specified amount (drive for and turn for commands) and during that move you tell one motor directly to move while that drivetrain command is still running.
Let me know if you have any other questions.