Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add Zeroing and Position Setting Functions for the IMU #260

Merged
merged 55 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
1a8757b
Started on getter, setter, and zeroing features for IMU offset and read
WillXuCodes Oct 11, 2020
6fbd90a
Added comments to header files for all new functions and finished up
WillXuCodes Oct 15, 2020
91c5997
Fixed documentation and removed extraneous ::IMU
WillXuCodes Oct 15, 2020
a944d2a
version fix
WillXuCodes Oct 15, 2020
419cf4a
Version Fix (anotha one)
WillXuCodes Oct 15, 2020
c14927f
Update version
WillXuCodes Oct 15, 2020
a4fcb7d
Update version
WillXuCodes Oct 15, 2020
234a210
Update version
WillXuCodes Oct 15, 2020
1e41063
Changed IMU offsets to initializer list
WillXuCodes Oct 19, 2020
fddab99
Reordered initializer list
WillXuCodes Oct 19, 2020
e58637b
Merge branch 'develop' into feature/reset-imu
WillXuCodes Dec 13, 2020
bc954d2
Fixed a few file headers, changed CPP back to previous state, renamed
WillXuCodes Dec 24, 2020
dd8d447
Added working C functions for resetting rotation and header.
WillXuCodes Dec 24, 2020
8802eb3
C api for yaw, pitch, and roll reset working.
WillXuCodes Dec 24, 2020
e3cb639
Added a new imu_reset function that resets all values from the IMU.
WillXuCodes Dec 24, 2020
9aefb73
Added resets for CPP api (not tested yet)
WillXuCodes Dec 24, 2020
19d1f3b
Fixed build issue
WillXuCodes Dec 24, 2020
b959bd4
Properly fixed the issue now.
WillXuCodes Dec 24, 2020
9478d67
Added setter functions for value readings, reworked reset functions a…
WillXuCodes Dec 24, 2020
2832ef5
Added missing semicolon, finished testing C API.
WillXuCodes Dec 24, 2020
8591ff2
Added CPP api for setting values.
WillXuCodes Dec 24, 2020
6a3540a
Added documentation for reset and set value functions.
WillXuCodes Dec 24, 2020
c2b6501
Added imubl (IMU Backend Layer) for non-threadsafe functions, and als…
WillXuCodes Dec 25, 2020
4f9f1c7
Added untracked file (IMUBL)
WillXuCodes Dec 25, 2020
7843ee3
Fixed up all other debugging
WillXuCodes Jan 4, 2021
0739c30
Changed imubl location to VDML to hide it from users.
WillXuCodes Jan 4, 2021
76b8b00
Changed imubl header description
WillXuCodes Jan 4, 2021
96e0f22
Reverted version and drive code.
WillXuCodes Jan 4, 2021
db8d0d8
Added newlines back to the end of files
WillXuCodes Jan 4, 2021
36074f0
Updated Header Liscense Years
WillXuCodes Jan 4, 2021
33e3aa3
Revert "Updated Header Liscense Years"
WillXuCodes Jan 4, 2021
9910f27
Packed the enum for imu reset data, fixed formatting and newline at e…
WillXuCodes Jan 10, 2021
9b42aa5
Revert accidental change to get_accel docs.
WillXuCodes Jan 10, 2021
5fd142f
Merge branch 'develop' into feature/reset-imu
WillXuCodes Jan 10, 2021
66532aa
Removed imubl and fixed packed attribute
WillXuCodes Jan 12, 2021
7c98a11
Merge branch 'feature/reset-imu' of https://github.com/purduesigbots/…
WillXuCodes Jan 12, 2021
7871959
Changed mentions of reset back to tare, and changed calibrate back to…
WillXuCodes Jan 12, 2021
1d41962
Revert drive code
WillXuCodes Jan 12, 2021
362b2ab
Revert version
WillXuCodes Jan 12, 2021
9ff4ab2
Revert version properly
WillXuCodes Jan 12, 2021
eca71de
Update include/pros/imu.hpp
WillXuCodes Jan 13, 2021
0fdac2a
Combined the declarations and definitions for device pointers.
WillXuCodes Jan 13, 2021
6f4b107
Merge branch 'feature/reset-imu' of https://github.com/purduesigbots/…
WillXuCodes Jan 13, 2021
d255dd2
Fixed offset for get euler, and also changed the quaternion function …
WillXuCodes Jan 21, 2021
e0666fe
Finished testing and fixing quaternion, revert version and drive code.
WillXuCodes Jan 21, 2021
63955a5
Fixed indentation
WillXuCodes Jan 21, 2021
0f05415
Added euler setting and taring functions.
WillXuCodes Jan 21, 2021
44d26a5
Added limits to the setting functions.
WillXuCodes Jan 22, 2021
383f1ed
Added proper limiting (still needs work though)
WillXuCodes Jan 22, 2021
ab344b3
Added proper value wrapping for when a value + offset exceeds a measu…
WillXuCodes Jan 22, 2021
bdf620e
Revert version and drive code, added and tested C++ API for euler.
WillXuCodes Jan 22, 2021
ff03199
Added documentation about setter behaviors.
WillXuCodes Jan 22, 2021
7c04623
Added newline at end of vdml_imu.c
WillXuCodes Jan 22, 2021
e7d4c2f
Stylization changes.
WillXuCodes Jan 23, 2021
d194fdf
Fixed inconsistent sentence
WillXuCodes Jan 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions include/pros/imu.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,184 @@ imu_status_e_t imu_get_status(uint8_t port);
// void imu_set_mode(uint8_t port, uint32_t mode);
// uint32_t imu_get_mode(uint8_t port);

//Value reset functions:
/**
* Resets the current reading of the Inertial Sensor's heading to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_tare_heading(uint8_t port);

/**
* Resets the current reading of the Inertial Sensor's rotation to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_tare_rotation(uint8_t port);

/**
* Resets the current reading of the Inertial Sensor's pitch to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_tare_pitch(uint8_t port);

/**
* Resets the current reading of the Inertial Sensor's roll to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_tare_roll(uint8_t port);

/**
* Resets the current reading of the Inertial Sensor's yaw to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_tare_yaw(uint8_t port);

/**
* Resets all 5 values of the Inertial Sensor to 0.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_tare(uint8_t port);

//Value set functions:
/**
* Sets the current reading of the Inertial Sensor's rotation to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_set_rotation(uint8_t port, double target);

/**
* Sets the current reading of the Inertial Sensor's set to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_set_heading(uint8_t port, double target);

/**
* Sets the current reading of the Inertial Sensor's pitch to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_set_pitch(uint8_t port, double target);

/**
* Sets the current reading of the Inertial Sensor's roll to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_set_roll(uint8_t port, double target);

/**
* Sets the current reading of the Inertial Sensor's yaw to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t imu_set_yaw(uint8_t port, double target);

#ifdef __cplusplus
}
}
Expand Down
167 changes: 166 additions & 1 deletion include/pros/imu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,172 @@ class Imu {
*/
virtual pros::c::imu_gyro_s_t get_gyro_rate() const;
/**
* Get the Inertial Sensor's raw acceleroneter values
* Resets the current reading of the Inertial Sensor's rotation to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t tare_rotation() const;
/**
* Resets the current reading of the Inertial Sensor's heading to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t tare_heading() const;
/**
* Resets the current reading of the Inertial Sensor's pitch to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t tare_pitch() const;
/**
* Resets the current reading of the Inertial Sensor's pitch to zero
WillXuCodes marked this conversation as resolved.
Show resolved Hide resolved
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t tare_yaw() const;
/**
* Resets the current reading of the Inertial Sensor's roll to zero
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t tare_roll() const;
/**
* Resets all 5 values of the Inertial Sensor to 0.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t tare() const;
/**
* Sets the current reading of the Inertial Sensor's heading to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t set_heading(double target) const;
/**
* Sets the current reading of the Inertial Sensor's rotation to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t set_rotation(double target) const;
/**
* Sets the current reading of the Inertial Sensor's yaw to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t set_yaw(double target) const;
/**
* Sets the current reading of the Inertial Sensor's pitch to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t set_pitch(double target) const;
/**
* Sets the current reading of the Inertial Sensor's roll to target value
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Inertial Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Inertial Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t set_roll(double target) const;
/**
* Get the Inertial Sensor's raw accelerometer values
*
* This function uses the following values of errno when an error state is
* reached:
Expand Down
2 changes: 1 addition & 1 deletion src/devices/vdml_distance.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* \file devices/vdml_imu.c
* \file devices/vdml_distance.c
*
* Contains functions for interacting with the VEX Inertial sensor.
*
Expand Down
Loading