My team just started using an inertial sensor for our 6 motor drive robot and I am completely stumped on how to code this thing. I tried following Joseph973’s video on in, but the robot just drove forward forever. It also has 3/5 gearing. I was wondering if anyone could show my their code for this or guide me in the right direction. Thank you.
Could you share your current code so that we can try to find what is wrong with it? Are you trying to turn and it’s driving forward? It could be an issue with what direction you are spinning each motor in.
Hi there,
Without seeing your code I can only do so much. I coded our team’s inertial sensor using python but you can take these and apply it to any coding languge.
First you need to define the inertial sensor, same as you would do a motor:
drivetrain_inertial = Inertial(Ports.PORT7)
In my experience, the best way to incorporate an inertial sensor is to add it to the drivetrain. Some teams code it as a separate entity and use its data to tell the drivetrain when to stop. If you’re coding it this way you can skip this step. To incorporate it into the drivetrain you add it to your drivetrain definition code:
drivetrain = SmartDrive(left_drive_smart, right_drive_smart, drivetrain_inertial, 299.24, 320, 40, MM, 0.6666666666666666)
Now you need to calibrate it to 0 so it can be accurate:
drivetrain_inertial.calibrate()
Now all that’s left to do is code your auton. You can now use the turn_to_heading function with the drivetrain in order to utilize the inertial sensor. I believe the simple “turn” function also incorporates the inertial sensor now as well.
Hope this Helps!
-11865A