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

Modify PROS 4 GPS API #650

Merged
merged 5 commits into from
Apr 30, 2024
Merged

Modify PROS 4 GPS API #650

merged 5 commits into from
Apr 30, 2024

Conversation

CChheerryyll
Copy link
Contributor

Summary:

This update modifies the GPS sensor API for PROS 4.
Modified list of functions:

  • initialize_full()
  • set_offset()
  • get_offset()
  • set_position()
  • set_data_rate()
  • get_error()
  • get_position_and_orientation()
  • get_position()
  • get_position_x()
  • get_position_y()
  • get_orientation()
  • get_pitch()
  • get_roll()
  • get_yaw()
  • get_heading()
  • get_heading_raw()
  • get_gyro_rate()
  • get_gyro_rate_x()
  • get_gyro_rate_y()
  • get_gyro_rate_z()
  • get_accel()
  • get_accel_x()
  • get_accel_y()
  • get_accel_z()

Removed functions:

  • get_rotation()
  • set_rotation()
  • tare_rotation()

Motivation:

The purpose of some functions are unclear (e.g. get_rotation), and the name of some functions are not straightforward enough (e.g. get_status)

References (optional):

Test Plan:

  • call the functions individually and print their return values

double gps_get_heading_raw(uint8_t port) {
claim_port_f(port - 1, E_DEVICE_GPS);
double rtv = vexDeviceGpsHeadingGet(device->device_info);
return_port(port - 1, rtv);
}

gps_gyro_s_t gps_get_gyro_rate(uint8_t port) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is completely my fault but can we see if typecasting V5_DeviceGPSRaw to the return type works, I know what I did here was super scuffed and I'd appreciate if we just casted it instead of doing the extraneous copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I have more context on this? vexDeviceGpsHeadingGet() already returns a double value, I don't see a need for typecasting.

@@ -81,7 +81,7 @@ double gps_get_error(uint8_t port) {
return_port(port - 1, rtv);
}

gps_status_s_t gps_get_status(uint8_t port) {
gps_status_s_t gps_get_position_and_orientation(uint8_t port) {
gps_status_s_t rtv = GPS_STATUS_ERR_INIT;
if (!claim_port_try(port - 1, E_DEVICE_GPS)) {
return rtv;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative is typecasting the input parameter (data) from gps_status_s_t or whatever it is to the VEX API struct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of the scope of this PR but the IMU API may have the same issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function currently converts the VEX API struct (V5_DeviceGpsAttitude) into gps_status_s_t, and returns the gps_status_s_t. If we want to cast gps_status_s_t into V5_DeviceGpsAttitude, should the return type be just V5_DeviceGpsAttitude then?

Copy link
Contributor

@noam987 noam987 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like the docs changes. LGTM

@noam987 noam987 merged commit ff03840 into develop-pros-4 Apr 30, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants