Skip to main content

Posts

Showing posts with the label Using objects In Robotics

Using objects In Robotics

In the WPI Robotics Library all sensors, motors, driver station elements, and more are all objects. For the most part, objects correspond to the physical things on your robot. Objects include the code and the data that makes the thing operate. Let’s look at a Gyro. There are a bunch of operations, or methods, you can perform on a gyro: • Create the gyro object – this sets up the gyro and causes it to initialize itself • Get the current heading, or angle, from the gyro • Set the type of the gyro, i.e. its Sensitivity • Reset the current heading to zero • Delete the gyro object when you’re done using it Creating a gyro object is done like this: Gyro robotHeadingGyro(1); robotHeadingGyro is a variable that holds the Gyro object that represents a gyro module connected to analog port 1. That’s all you have to do to make an instance of a Gyro object. Note: by the way, an instance of an object is the chunk of memory that holds the data unique to that object. When you create ...