From d38c4795021d0a6572e44cadcf8e318a1970fd40 Mon Sep 17 00:00:00 2001 From: Octogonapus Date: Tue, 8 Dec 2020 21:21:54 -0500 Subject: [PATCH 01/16] Clarify rotation_get_angle API (#264) --- include/pros/rotation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pros/rotation.h b/include/pros/rotation.h index 28c8e558e..095a92aac 100644 --- a/include/pros/rotation.h +++ b/include/pros/rotation.h @@ -110,7 +110,7 @@ int32_t rotation_get_position(uint8_t port); int32_t rotation_get_velocity(uint8_t port); /** - * Get the Rotation Sensor's current position in centidegrees + * Get the Rotation Sensor's current angle in centidegrees (0-36000) * * This function uses the following values of errno when an error state is * reached: @@ -119,7 +119,7 @@ int32_t rotation_get_velocity(uint8_t port); * * \param port * The V5 Rotation Sensor port number from 1-21 - * \return The angle value or PROS_ERR_F if the operation failed, setting + * \return The angle value (0-36000) or PROS_ERR_F if the operation failed, setting * errno. */ int32_t rotation_get_angle(uint8_t port); From a07944b29a364d0f0a450c97bd10c667e70762a7 Mon Sep 17 00:00:00 2001 From: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Date: Sat, 9 Jan 2021 17:17:35 -0800 Subject: [PATCH 02/16] Fixed all instances of the liscense being outdated in file headers. (#272) --- STYLEGUIDE.md | 2 +- include/api.h | 2 +- include/common/cobs.h | 2 +- include/common/gid.h | 2 +- include/common/linkedlist.h | 2 +- include/common/set.h | 2 +- include/common/string.h | 2 +- include/kapi.h | 2 +- include/main.h | 2 +- include/pros/adi.h | 2 +- include/pros/adi.hpp | 2 +- include/pros/api_legacy.h | 2 +- include/pros/apix.h | 2 +- include/pros/distance.h | 2 +- include/pros/distance.hpp | 2 +- include/pros/ext_adi.h | 2 +- include/pros/imu.h | 2 +- include/pros/imu.hpp | 2 +- include/pros/llemu.h | 2 +- include/pros/llemu.hpp | 2 +- include/pros/misc.h | 2 +- include/pros/misc.hpp | 2 +- include/pros/motors.h | 2 +- include/pros/motors.hpp | 2 +- include/pros/optical.h | 2 +- include/pros/optical.hpp | 2 +- include/pros/rotation.h | 2 +- include/pros/rotation.hpp | 2 +- include/pros/rtos.h | 2 +- include/pros/rtos.hpp | 2 +- include/pros/serial.h | 2 +- include/pros/serial.hpp | 2 +- include/pros/vision.h | 2 +- include/pros/vision.hpp | 2 +- include/system/dev/banners.h | 2 +- include/system/dev/dev.h | 2 +- include/system/dev/ser.h | 2 +- include/system/dev/usd.h | 2 +- include/system/dev/vfs.h | 2 +- include/system/optimizers.h | 2 +- include/vdml/registry.h | 2 +- include/vdml/vdml.h | 2 +- src/common/cobs.c | 2 +- src/common/gid.c | 2 +- src/common/linkedlist.c | 2 +- src/common/set.c | 2 +- src/common/string.c | 2 +- src/devices/battery.c | 2 +- src/devices/battery.cpp | 2 +- src/devices/controller.c | 2 +- src/devices/controller.cpp | 2 +- src/devices/registry.c | 2 +- src/devices/vdml.c | 2 +- src/devices/vdml_adi.c | 2 +- src/devices/vdml_adi.cpp | 2 +- src/devices/vdml_distance.c | 2 +- src/devices/vdml_distance.cpp | 2 +- src/devices/vdml_ext_adi.c | 2 +- src/devices/vdml_imu.c | 2 +- src/devices/vdml_imu.cpp | 2 +- src/devices/vdml_motors.c | 2 +- src/devices/vdml_motors.cpp | 2 +- src/devices/vdml_optical.c | 2 +- src/devices/vdml_optical.cpp | 2 +- src/devices/vdml_rotation.c | 2 +- src/devices/vdml_rotation.cpp | 2 +- src/devices/vdml_serial.c | 2 +- src/devices/vdml_serial.cpp | 2 +- src/devices/vdml_usd.c | 2 +- src/devices/vdml_usd.cpp | 2 +- src/devices/vdml_vision.c | 2 +- src/devices/vdml_vision.cpp | 2 +- src/display/display.c | 2 +- src/display/error.c | 2 +- src/display/llemu.c | 2 +- src/display/llemu.cpp | 2 +- src/rtos/rtos.cpp | 2 +- src/system/cpp_support.cpp | 2 +- src/system/dev/dev_driver.c | 2 +- src/system/dev/file_system_stubs.c | 2 +- src/system/dev/ser_daemon.c | 2 +- src/system/dev/ser_driver.c | 2 +- src/system/dev/usd_driver.c | 2 +- src/system/dev/vfs.c | 2 +- src/system/envlock.c | 2 +- src/system/mlock.c | 2 +- src/system/newlib_stubs.c | 2 +- src/system/rtos_hooks.c | 2 +- src/system/startup.c | 2 +- src/system/system_daemon.c | 2 +- src/system/unwind.c | 2 +- src/tests/adi.cpp | 2 +- src/tests/ext_adi.cpp | 2 +- src/tests/generic_serial.cpp | 2 +- src/tests/generic_serial_file.cpp | 2 +- src/tests/gyro.c | 2 +- src/tests/gyro.cpp | 2 +- src/tests/rtos_function_linking.c | 2 +- src/tests/simple_names.c | 2 +- src/tests/simple_names.cpp | 2 +- 100 files changed, 100 insertions(+), 100 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 3afb8d31b..138552411 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -49,7 +49,7 @@ These should be placed at the very start of a file. * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/api.h b/include/api.h index 70af8173d..5de639ece 100644 --- a/include/api.h +++ b/include/api.h @@ -8,7 +8,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/common/cobs.h b/include/common/cobs.h index ca4340b61..7fddd80e1 100644 --- a/include/common/cobs.h +++ b/include/common/cobs.h @@ -5,7 +5,7 @@ * * See common/cobs.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/common/gid.h b/include/common/gid.h index b7adcb94c..58a98c433 100644 --- a/include/common/gid.h +++ b/include/common/gid.h @@ -5,7 +5,7 @@ * * See common/gid.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/common/linkedlist.h b/include/common/linkedlist.h index ad89ba3d4..d67c1a180 100644 --- a/include/common/linkedlist.h +++ b/include/common/linkedlist.h @@ -6,7 +6,7 @@ * This file defines a linked list implementation that operates on the FreeRTOS * heap, and is able to generically store function pointers and data * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/common/set.h b/include/common/set.h index b024ba2c4..7487c72ae 100644 --- a/include/common/set.h +++ b/include/common/set.h @@ -5,7 +5,7 @@ * * See common/set.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/common/string.h b/include/common/string.h index 85ec99a7a..d8128e525 100644 --- a/include/common/string.h +++ b/include/common/string.h @@ -5,7 +5,7 @@ * * See common/string.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/kapi.h b/include/kapi.h index fb9c91130..688cea44e 100644 --- a/include/kapi.h +++ b/include/kapi.h @@ -8,7 +8,7 @@ * creation of statically allocated FreeRTOS primitives like tasks, semaphores, * and queues. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/main.h b/include/main.h index 9f9a06f14..0ce65af50 100644 --- a/include/main.h +++ b/include/main.h @@ -4,7 +4,7 @@ * Contains common definitions and header files used throughout your PROS * project. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/adi.h b/include/pros/adi.h index b850fc0a9..e0d2ae7db 100644 --- a/include/pros/adi.h +++ b/include/pros/adi.h @@ -8,7 +8,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/adi.hpp b/include/pros/adi.hpp index 305480546..60e350bff 100644 --- a/include/pros/adi.hpp +++ b/include/pros/adi.hpp @@ -8,7 +8,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/api_legacy.h b/include/pros/api_legacy.h index 8768b5157..748072c74 100644 --- a/include/pros/api_legacy.h +++ b/include/pros/api_legacy.h @@ -10,7 +10,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/apix.h b/include/pros/apix.h index 71146ada8..e516d2591 100644 --- a/include/pros/apix.h +++ b/include/pros/apix.h @@ -12,7 +12,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/distance.h b/include/pros/distance.h index 115cf2adb..fae64a842 100644 --- a/include/pros/distance.h +++ b/include/pros/distance.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/distance.hpp b/include/pros/distance.hpp index b584966aa..0007035d0 100644 --- a/include/pros/distance.hpp +++ b/include/pros/distance.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * \copyright (c) 2017-2018, Purdue University ACM SIGBots. + * \copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/ext_adi.h b/include/pros/ext_adi.h index 391617f4d..11351fd00 100644 --- a/include/pros/ext_adi.h +++ b/include/pros/ext_adi.h @@ -8,7 +8,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/imu.h b/include/pros/imu.h index 0caf68430..3022b42b5 100644 --- a/include/pros/imu.h +++ b/include/pros/imu.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/imu.hpp b/include/pros/imu.hpp index 07159f525..0f56bdda7 100644 --- a/include/pros/imu.hpp +++ b/include/pros/imu.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/llemu.h b/include/pros/llemu.h index aef90d6f9..7b4d64d38 100644 --- a/include/pros/llemu.h +++ b/include/pros/llemu.h @@ -13,7 +13,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/llemu.hpp b/include/pros/llemu.hpp index a7eaa3729..aa96e9d69 100644 --- a/include/pros/llemu.hpp +++ b/include/pros/llemu.hpp @@ -13,7 +13,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/misc.h b/include/pros/misc.h index 7bdb00f58..b629ec041 100644 --- a/include/pros/misc.h +++ b/include/pros/misc.h @@ -10,7 +10,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reservered. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/misc.hpp b/include/pros/misc.hpp index 72a689af2..efc3ed57a 100644 --- a/include/pros/misc.hpp +++ b/include/pros/misc.hpp @@ -10,7 +10,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reservered. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/motors.h b/include/pros/motors.h index 35ef6e45a..428374f8a 100644 --- a/include/pros/motors.h +++ b/include/pros/motors.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index adcce8add..b4eeeb3ed 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * \copyright (c) 2017-2018, Purdue University ACM SIGBots. + * \copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/optical.h b/include/pros/optical.h index 18bacff71..b2867aa30 100644 --- a/include/pros/optical.h +++ b/include/pros/optical.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/optical.hpp b/include/pros/optical.hpp index 4b3c39da4..381c52d2e 100644 --- a/include/pros/optical.hpp +++ b/include/pros/optical.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/rotation.h b/include/pros/rotation.h index 095a92aac..435c6b399 100644 --- a/include/pros/rotation.h +++ b/include/pros/rotation.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/rotation.hpp b/include/pros/rotation.hpp index 58595f59c..256ed16f9 100644 --- a/include/pros/rotation.hpp +++ b/include/pros/rotation.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/rtos.h b/include/pros/rtos.h index 23cfc7c22..089b33cf9 100644 --- a/include/pros/rtos.h +++ b/include/pros/rtos.h @@ -10,7 +10,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/rtos.hpp b/include/pros/rtos.hpp index c44f322ab..a3c62cb62 100644 --- a/include/pros/rtos.hpp +++ b/include/pros/rtos.hpp @@ -10,7 +10,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/serial.h b/include/pros/serial.h index 81de139ff..625604545 100644 --- a/include/pros/serial.h +++ b/include/pros/serial.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/serial.hpp b/include/pros/serial.hpp index 07378e958..60e82c1cd 100644 --- a/include/pros/serial.hpp +++ b/include/pros/serial.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * \copyright (c) 2017-2018, Purdue University ACM SIGBots. + * \copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/pros/vision.h b/include/pros/vision.h index a21db2d19..f565255fd 100644 --- a/include/pros/vision.h +++ b/include/pros/vision.h @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/pros/vision.hpp b/include/pros/vision.hpp index edcc5a3cc..05a4bd2eb 100644 --- a/include/pros/vision.hpp +++ b/include/pros/vision.hpp @@ -9,7 +9,7 @@ * This file should not be modified by users, since it gets replaced whenever * a kernel upgrade occurs. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/system/dev/banners.h b/include/system/dev/banners.h index 407d9ac22..2376d4bbd 100644 --- a/include/system/dev/banners.h +++ b/include/system/dev/banners.h @@ -7,7 +7,7 @@ * * See system/dev/serial_daemon.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/system/dev/dev.h b/include/system/dev/dev.h index 313c3d964..e6ab57b7f 100644 --- a/include/system/dev/dev.h +++ b/include/system/dev/dev.h @@ -3,7 +3,7 @@ * * Generic Serial Device driver header * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/system/dev/ser.h b/include/system/dev/ser.h index b6495375e..521f1ec63 100644 --- a/include/system/dev/ser.h +++ b/include/system/dev/ser.h @@ -5,7 +5,7 @@ * * See system/dev/ser_driver.c and system/dev/ser_daemon.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/system/dev/usd.h b/include/system/dev/usd.h index f7b3ba83c..4a74e2ede 100644 --- a/include/system/dev/usd.h +++ b/include/system/dev/usd.h @@ -5,7 +5,7 @@ * * See system/dev/usd_driver.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/system/dev/vfs.h b/include/system/dev/vfs.h index 222201fd2..834eb820c 100644 --- a/include/system/dev/vfs.h +++ b/include/system/dev/vfs.h @@ -5,7 +5,7 @@ * * See system/dev/vfs.c for discussion * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/system/optimizers.h b/include/system/optimizers.h index 91bfde492..c49370db2 100644 --- a/include/system/optimizers.h +++ b/include/system/optimizers.h @@ -5,7 +5,7 @@ * * Probably shouldn't use anything from this header * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/include/vdml/registry.h b/include/vdml/registry.h index 3ad7dcc7b..9b34a0368 100644 --- a/include/vdml/registry.h +++ b/include/vdml/registry.h @@ -4,7 +4,7 @@ * This file contains the standard header info for the VDML (Vex Data Management * Layer) registry. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/include/vdml/vdml.h b/include/vdml/vdml.h index 99595ed81..8eae3d654 100644 --- a/include/vdml/vdml.h +++ b/include/vdml/vdml.h @@ -4,7 +4,7 @@ * This file contains all types and functions used throughout multiple VDML * (Vex Data Management Layer) files. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/common/cobs.c b/src/common/cobs.c index 86fe9d7cd..e775d687e 100644 --- a/src/common/cobs.c +++ b/src/common/cobs.c @@ -6,7 +6,7 @@ * Contains an implementation of Consistent Overhead Byte Stuffing, adapted from * https://github.com/jacquesf/COBS-Consistent-Overhead-Byte-Stuffing * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/common/gid.c b/src/common/gid.c index 38581ad64..53a64c0e0 100644 --- a/src/common/gid.c +++ b/src/common/gid.c @@ -6,7 +6,7 @@ * Contains an implementation to efficiently assign globally unique IDs * e.g. to assign entries in a global table * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/common/linkedlist.c b/src/common/linkedlist.c index fe719ad17..da7ee0a2a 100644 --- a/src/common/linkedlist.c +++ b/src/common/linkedlist.c @@ -6,7 +6,7 @@ * This file defines a linked list implementation that operates on the FreeRTOS * heap, and is able to generically store function pointers and data * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/common/set.c b/src/common/set.c index 28c85c11f..6b09afc4e 100644 --- a/src/common/set.c +++ b/src/common/set.c @@ -5,7 +5,7 @@ * It's used to check which streams are enabled in ser_driver for the moment, * but also has list_contains which may be useful in other contexts. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/common/string.c b/src/common/string.c index 4ddfa47cb..2d4d26248 100644 --- a/src/common/string.c +++ b/src/common/string.c @@ -4,7 +4,7 @@ * Contains extra string functions useful for PROS and kstrdup/kstrndup which * use the kernel heap instead of the user heap * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/battery.c b/src/devices/battery.c index 1dbafdcc0..1da781d8d 100644 --- a/src/devices/battery.c +++ b/src/devices/battery.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Battery. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/battery.cpp b/src/devices/battery.cpp index 805dc0a84..b830af31c 100644 --- a/src/devices/battery.cpp +++ b/src/devices/battery.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Battery. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/controller.c b/src/devices/controller.c index 48081d8d2..d844635b7 100644 --- a/src/devices/controller.c +++ b/src/devices/controller.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Controller. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/controller.cpp b/src/devices/controller.cpp index 06416f076..324609af1 100644 --- a/src/devices/controller.cpp +++ b/src/devices/controller.cpp @@ -4,7 +4,7 @@ * Contains functions for interacting with the V5 Controller, as well as the * competition control functions. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/registry.c b/src/devices/registry.c index 04a293490..f11808a82 100644 --- a/src/devices/registry.c +++ b/src/devices/registry.c @@ -5,7 +5,7 @@ * what devices are in use on the V5. Therefore, in order to use V5 devices with * PROS, they must be registered and deregistered using the registry. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml.c b/src/devices/vdml.c index bb310bbeb..431e24912 100644 --- a/src/devices/vdml.c +++ b/src/devices/vdml.c @@ -6,7 +6,7 @@ * VDML ensures thread saftey for operations on smart devices by maintaining * an array of RTOS Mutexes and implementing functions to take and give them. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_adi.c b/src/devices/vdml_adi.c index 3e623d81d..5176e61c8 100644 --- a/src/devices/vdml_adi.c +++ b/src/devices/vdml_adi.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 ADI. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_adi.cpp b/src/devices/vdml_adi.cpp index 339288804..83a192470 100644 --- a/src/devices/vdml_adi.cpp +++ b/src/devices/vdml_adi.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 ADI. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_distance.c b/src/devices/vdml_distance.c index 3b560541d..853bb6b0f 100644 --- a/src/devices/vdml_distance.c +++ b/src/devices/vdml_distance.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Inertial sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_distance.cpp b/src/devices/vdml_distance.cpp index bc2ae880b..afb0c34c4 100644 --- a/src/devices/vdml_distance.cpp +++ b/src/devices/vdml_distance.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 ADI. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_ext_adi.c b/src/devices/vdml_ext_adi.c index 7247d935c..de8db3799 100644 --- a/src/devices/vdml_ext_adi.c +++ b/src/devices/vdml_ext_adi.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 3-Wire Expander. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_imu.c b/src/devices/vdml_imu.c index 393838584..6cf5f11c9 100644 --- a/src/devices/vdml_imu.c +++ b/src/devices/vdml_imu.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Inertial sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_imu.cpp b/src/devices/vdml_imu.cpp index ef02b40bb..1956ccaae 100644 --- a/src/devices/vdml_imu.cpp +++ b/src/devices/vdml_imu.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Inertial sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_motors.c b/src/devices/vdml_motors.c index 81ba54bef..7bfdb442d 100644 --- a/src/devices/vdml_motors.c +++ b/src/devices/vdml_motors.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Motors. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_motors.cpp b/src/devices/vdml_motors.cpp index 6d7b8dd3e..1f636c812 100644 --- a/src/devices/vdml_motors.cpp +++ b/src/devices/vdml_motors.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Motors. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_optical.c b/src/devices/vdml_optical.c index 5153fd315..37fa384e2 100644 --- a/src/devices/vdml_optical.c +++ b/src/devices/vdml_optical.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Inertial sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_optical.cpp b/src/devices/vdml_optical.cpp index b5c5ad9e3..4483fbb7f 100644 --- a/src/devices/vdml_optical.cpp +++ b/src/devices/vdml_optical.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Inertial sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_rotation.c b/src/devices/vdml_rotation.c index b76b3f440..5cd9ba33e 100644 --- a/src/devices/vdml_rotation.c +++ b/src/devices/vdml_rotation.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Rotation sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_rotation.cpp b/src/devices/vdml_rotation.cpp index dff0b3ba2..8649785df 100644 --- a/src/devices/vdml_rotation.cpp +++ b/src/devices/vdml_rotation.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the VEX Rotation sensor. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_serial.c b/src/devices/vdml_serial.c index 6f4dae2ae..cd378511f 100644 --- a/src/devices/vdml_serial.c +++ b/src/devices/vdml_serial.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with V5 Generic Serial devices. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_serial.cpp b/src/devices/vdml_serial.cpp index 8e94c9c2b..8e34bf07e 100644 --- a/src/devices/vdml_serial.cpp +++ b/src/devices/vdml_serial.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with V5 Generic Serial devices. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_usd.c b/src/devices/vdml_usd.c index 15e453234..b18d98e3a 100644 --- a/src/devices/vdml_usd.c +++ b/src/devices/vdml_usd.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the SD card. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/vdml_usd.cpp b/src/devices/vdml_usd.cpp index 7d1507b1c..9445f9e05 100644 --- a/src/devices/vdml_usd.cpp +++ b/src/devices/vdml_usd.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the SD card. * - * Copyright (c) 2017-2019, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/devices/vdml_vision.c b/src/devices/vdml_vision.c index 2663937c1..50493f413 100644 --- a/src/devices/vdml_vision.c +++ b/src/devices/vdml_vision.c @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Vision Sensor. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/devices/vdml_vision.cpp b/src/devices/vdml_vision.cpp index e82c9690c..b9a2af833 100644 --- a/src/devices/vdml_vision.cpp +++ b/src/devices/vdml_vision.cpp @@ -3,7 +3,7 @@ * * Contains functions for interacting with the V5 Vision Sensor. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/display/display.c b/src/display/display.c index b9a3025d3..26e72c92b 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -3,7 +3,7 @@ * * Main source code for interacting with the V5 Brain's LCD screen. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/display/error.c b/src/display/error.c index e846da882..ec5236cc3 100644 --- a/src/display/error.c +++ b/src/display/error.c @@ -4,7 +4,7 @@ * Error display handling. Prints an error message to the screen when the kernel * is put in an error state. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/display/llemu.c b/src/display/llemu.c index bb2067411..1ca15e72c 100644 --- a/src/display/llemu.c +++ b/src/display/llemu.c @@ -7,7 +7,7 @@ * VEX LCD, containing a set of functions that facilitate the use of a software- * emulated version of the classic VEX LCD module. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/display/llemu.cpp b/src/display/llemu.cpp index 04d38a251..39cc6e378 100644 --- a/src/display/llemu.cpp +++ b/src/display/llemu.cpp @@ -7,7 +7,7 @@ * VEX LCD, containing a set of functions that facilitate the use of a software- * emulated version of the classic VEX LCD module. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/src/rtos/rtos.cpp b/src/rtos/rtos.cpp index fe21e7d09..3bce6542f 100644 --- a/src/rtos/rtos.cpp +++ b/src/rtos/rtos.cpp @@ -6,7 +6,7 @@ * * See https://pros.cs.purdue.edu/v5/tutorials/multitasking.html to learn more. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/cpp_support.cpp b/src/system/cpp_support.cpp index b4e603b02..481d0b64a 100644 --- a/src/system/cpp_support.cpp +++ b/src/system/cpp_support.cpp @@ -3,7 +3,7 @@ * * C++ support hooks * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots + * Copyright (c) 2017-2021, Purdue University ACM SIGBots * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/dev/dev_driver.c b/src/system/dev/dev_driver.c index 7ea89983f..f2eaadee5 100644 --- a/src/system/dev/dev_driver.c +++ b/src/system/dev/dev_driver.c @@ -6,7 +6,7 @@ * Contains the driver for writing to any smart port with no regard to the * device on the other end. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/dev/file_system_stubs.c b/src/system/dev/file_system_stubs.c index 388441e0a..4105245e0 100644 --- a/src/system/dev/file_system_stubs.c +++ b/src/system/dev/file_system_stubs.c @@ -6,7 +6,7 @@ * Contains temporary stubs for the file system to allow compilation under gcc 9.2 * This is temporary and should be removed as part of #184 * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/dev/ser_daemon.c b/src/system/dev/ser_daemon.c index 6898b3a35..05c0b51af 100644 --- a/src/system/dev/ser_daemon.c +++ b/src/system/dev/ser_daemon.c @@ -7,7 +7,7 @@ * characters and responding to any kernel commands (like printing the banner or * enabling COBS) * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/dev/ser_driver.c b/src/system/dev/ser_driver.c index 9c7783c71..8cb1b9b3f 100644 --- a/src/system/dev/ser_driver.c +++ b/src/system/dev/ser_driver.c @@ -6,7 +6,7 @@ * Contains the driver for communicating over the serial line. The serial driver * is responsible for shipping out all data. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/dev/usd_driver.c b/src/system/dev/usd_driver.c index 22836cffd..b5aaa0952 100644 --- a/src/system/dev/usd_driver.c +++ b/src/system/dev/usd_driver.c @@ -3,7 +3,7 @@ * * Contains the driver for writing files to the microSD card. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/dev/vfs.c b/src/system/dev/vfs.c index 2acf4d908..c6d0d750b 100644 --- a/src/system/dev/vfs.c +++ b/src/system/dev/vfs.c @@ -13,7 +13,7 @@ * fileno. A file number maps to a driver and driver argument, which would be * whatever metadata the driver needs to open the file * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots + * Copyright (c) 2017-2021, Purdue University ACM SIGBots * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/envlock.c b/src/system/envlock.c index b7f84b6ed..839c50e6c 100644 --- a/src/system/envlock.c +++ b/src/system/envlock.c @@ -5,7 +5,7 @@ * * Contains implementations of environment-locking functions for newlib. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/mlock.c b/src/system/mlock.c index 80b16b360..954d77b2b 100644 --- a/src/system/mlock.c +++ b/src/system/mlock.c @@ -5,7 +5,7 @@ * * Contains implementations of memory-locking functions for newlib. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/newlib_stubs.c b/src/system/newlib_stubs.c index 29a41ba64..814877f44 100644 --- a/src/system/newlib_stubs.c +++ b/src/system/newlib_stubs.c @@ -6,7 +6,7 @@ * Contains the various methods needed to enable standard C library support * through the use of the Arm-distributed implementation of newlib. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/rtos_hooks.c b/src/system/rtos_hooks.c index 3f4751755..277e44d0d 100644 --- a/src/system/rtos_hooks.c +++ b/src/system/rtos_hooks.c @@ -6,7 +6,7 @@ * FreeRTOS requires some porting to each platform to handle certain tasks. This * file contains the various methods required to be implemented for FreeRTOS. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots + * Copyright (c) 2017-2021, Purdue University ACM SIGBots * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/startup.c b/src/system/startup.c index 0b65f4386..6dee6af75 100644 --- a/src/system/startup.c +++ b/src/system/startup.c @@ -5,7 +5,7 @@ * code. Our main() initializes data structures and starts the FreeRTOS * scheduler. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/system_daemon.c b/src/system/system_daemon.c index b8c8e5279..969158255 100644 --- a/src/system/system_daemon.c +++ b/src/system/system_daemon.c @@ -3,7 +3,7 @@ * * Competition control daemon responsible for invoking the user tasks. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots + * Copyright (c) 2017-2021, Purdue University ACM SIGBots * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/system/unwind.c b/src/system/unwind.c index 751efb3db..9ac6c180e 100644 --- a/src/system/unwind.c +++ b/src/system/unwind.c @@ -5,7 +5,7 @@ * be arbitrarily stopped, requiring us to call all the destructors of the task * to be killed. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots + * Copyright (c) 2017-2021, Purdue University ACM SIGBots * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/adi.cpp b/src/tests/adi.cpp index 62b6e6296..190df546e 100644 --- a/src/tests/adi.cpp +++ b/src/tests/adi.cpp @@ -6,7 +6,7 @@ * NOTE: There should also be a call to the constructor for the gyroscope object * in initialize() for calibration to occur before the opcontrol code. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/ext_adi.cpp b/src/tests/ext_adi.cpp index a69e6d99c..6d6ea0647 100644 --- a/src/tests/ext_adi.cpp +++ b/src/tests/ext_adi.cpp @@ -3,7 +3,7 @@ * * Test code for various External ADI things * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/generic_serial.cpp b/src/tests/generic_serial.cpp index 9922505a5..6be38beda 100644 --- a/src/tests/generic_serial.cpp +++ b/src/tests/generic_serial.cpp @@ -6,7 +6,7 @@ * NOTE: There should be a cable plugged into ports 1 and 2, connecting * them together * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/generic_serial_file.cpp b/src/tests/generic_serial_file.cpp index 75533d8f5..6562528e1 100644 --- a/src/tests/generic_serial_file.cpp +++ b/src/tests/generic_serial_file.cpp @@ -6,7 +6,7 @@ * NOTE: There should be a cable plugged into ports 1 and 2, connecting * them together * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/gyro.c b/src/tests/gyro.c index 7c66d2f92..599ce3c14 100644 --- a/src/tests/gyro.c +++ b/src/tests/gyro.c @@ -6,7 +6,7 @@ * NOTE: There should also be a call to the constructor for the gyroscope object * in initialize() for calibration to occur before the opcontrol code. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/gyro.cpp b/src/tests/gyro.cpp index 83acc7d57..d69c42ffc 100644 --- a/src/tests/gyro.cpp +++ b/src/tests/gyro.cpp @@ -6,7 +6,7 @@ * NOTE: There should also be a call to the constructor for the gyroscope object * in initialize() for calibration to occur before the opcontrol code. * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/rtos_function_linking.c b/src/tests/rtos_function_linking.c index 53acde2ac..900b22e1c 100644 --- a/src/tests/rtos_function_linking.c +++ b/src/tests/rtos_function_linking.c @@ -5,7 +5,7 @@ * * Do not actually run this test - just make sure it compiles * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/simple_names.c b/src/tests/simple_names.c index c405b0e39..0848cfced 100644 --- a/src/tests/simple_names.c +++ b/src/tests/simple_names.c @@ -5,7 +5,7 @@ * * Do not actually run this test - just make sure it compiles * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public diff --git a/src/tests/simple_names.cpp b/src/tests/simple_names.cpp index c45fc283e..04101089b 100644 --- a/src/tests/simple_names.cpp +++ b/src/tests/simple_names.cpp @@ -5,7 +5,7 @@ * * Do not actually run this test - just make sure it compiles * - * Copyright (c) 2017-2020, Purdue University ACM SIGBots. + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. * All rights reserved. * * This Source Code Form is subject to the terms of the Mozilla Public From 871e4911fd84e484e555e14693a5eb7c8f9bdf3b Mon Sep 17 00:00:00 2001 From: Kunwar Sahni Date: Fri, 22 Jan 2021 20:54:57 -0500 Subject: [PATCH 03/16] =?UTF-8?q?=F0=9F=91=BD=20Add=20missing=20filesystem?= =?UTF-8?q?=20syscalls=20(#275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add missing file system stubs * Update src/system/dev/file_system_stubs.c Co-authored-by: nathan-moore * Put fchmod and fchmodat by chmod Co-authored-by: nathan-moore --- src/system/dev/file_system_stubs.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/system/dev/file_system_stubs.c b/src/system/dev/file_system_stubs.c index 4105245e0..73717ae4a 100644 --- a/src/system/dev/file_system_stubs.c +++ b/src/system/dev/file_system_stubs.c @@ -32,6 +32,16 @@ int chmod(const char* pathname, mode_t mode) { return -1; } +int fchmod(int fd, mode_t mode) { + errno = ENOSYS; + return -1; +} + +int fchmodat(int dirfd, const char* pathname, mode_t mode, int flags) { + errno = ENOSYS; + return -1; +} + long pathconf(const char* path, int name) { errno = ENOSYS; return -1; @@ -56,3 +66,18 @@ int _stat(const char* file, struct stat* st) { errno = ENOSYS; return -1; } + +int symlink(const char* file, const char* linkpath) { + errno = ENOSYS; + return -1; +} + +ssize_t readlink(const char* pathname, char* buf, size_t bufsiz) { + errno = ENOSYS; + return -1; +} + +int truncate(const char* path, off_t length) { + errno = ENOSYS; + return -1; +} From 44812e5732f4682bb01d78e8d730b677d22700d1 Mon Sep 17 00:00:00 2001 From: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Date: Sat, 23 Jan 2021 17:41:08 -0500 Subject: [PATCH 04/16] =?UTF-8?q?=E2=9C=A8=20Add=20Zeroing=20and=20Positio?= =?UTF-8?q?n=20Setting=20Functions=20for=20the=20IMU=20(#260)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Started on getter, setter, and zeroing features for IMU offset and read values respectively for the cpp api only. * Added comments to header files for all new functions and finished up setter functions. * Fixed documentation and removed extraneous ::IMU * version fix * Version Fix (anotha one) * Update version * Update version * Update version * Changed IMU offsets to initializer list * Reordered initializer list * Fixed a few file headers, changed CPP back to previous state, renamed reset function to calibrate, and started work on thread safe reset functions. * Added working C functions for resetting rotation and header. * C api for yaw, pitch, and roll reset working. * Added a new imu_reset function that resets all values from the IMU. * Added resets for CPP api (not tested yet) * Fixed build issue * Properly fixed the issue now. * Added setter functions for value readings, reworked reset functions accordingly. * Added missing semicolon, finished testing C API. * Added CPP api for setting values. * Added documentation for reset and set value functions. * Added imubl (IMU Backend Layer) for non-threadsafe functions, and also added documentation for those functions. Made get_euler thread safe again with a new seperate function for non-threadsafe use. * Added untracked file (IMUBL) * Fixed up all other debugging * Changed imubl location to VDML to hide it from users. * Changed imubl header description * Reverted version and drive code. * Added newlines back to the end of files * Updated Header Liscense Years * Revert "Updated Header Liscense Years" This reverts commit 36074f0a937cff9aa86fb0622964fa939c224055. * Packed the enum for imu reset data, fixed formatting and newline at end of imu.hpp. * Revert accidental change to get_accel docs. * Removed imubl and fixed packed attribute * Changed mentions of reset back to tare, and changed calibrate back to tare. * Revert drive code * Revert version * Revert version properly * Update include/pros/imu.hpp Co-authored-by: nathan-moore * Combined the declarations and definitions for device pointers. * Fixed offset for get euler, and also changed the quaternion function to involve offsets. (TO BE TESTED, no V5 on hand). * Finished testing and fixing quaternion, revert version and drive code. * Fixed indentation * Added euler setting and taring functions. * Added limits to the setting functions. * Added proper limiting (still needs work though) * Added proper value wrapping for when a value + offset exceeds a measurable range. * Revert version and drive code, added and tested C++ API for euler. * Added documentation about setter behaviors. * Added newline at end of vdml_imu.c * Stylization changes. * Fixed inconsistent sentence Co-authored-by: nathan-moore --- include/pros/imu.h | 235 ++++++++++++++++++++++++++++++++- include/pros/imu.hpp | 221 ++++++++++++++++++++++++++++++- src/devices/vdml_distance.c | 2 +- src/devices/vdml_imu.c | 252 ++++++++++++++++++++++++++++++++---- src/devices/vdml_imu.cpp | 54 +++++++- src/devices/vdml_optical.c | 2 +- 6 files changed, 730 insertions(+), 36 deletions(-) diff --git a/include/pros/imu.h b/include/pros/imu.h index 3022b42b5..ab3bc8d55 100644 --- a/include/pros/imu.h +++ b/include/pros/imu.h @@ -127,7 +127,7 @@ double imu_get_rotation(uint8_t port); * Get the Inertial Sensor's heading relative to the initial direction of its * x-axis * - * This value is bounded by (-360,360). Clockwise rotations are represented with + * This value is bounded by [0,360). Clockwise rotations are represented with * positive degree values, while counterclockwise rotations are represented with * negative ones. * @@ -179,7 +179,7 @@ quaternion_s_t imu_get_quaternion(uint8_t port); euler_s_t imu_get_euler(uint8_t port); /** - * Get the Inertial Sensor's pitch angle + * Get the Inertial Sensor's pitch angle bounded by (-180,180) * * This function uses the following values of errno when an error state is * reached: @@ -195,7 +195,7 @@ euler_s_t imu_get_euler(uint8_t port); double imu_get_pitch(uint8_t port); /** - * Get the Inertial Sensor's roll angle + * Get the Inertial Sensor's roll angle bounded by (-180,180) * * This function uses the following values of errno when an error state is * reached: @@ -210,7 +210,7 @@ double imu_get_pitch(uint8_t port); double imu_get_roll(uint8_t port); /** - * Get the Inertial Sensor's yaw angle + * Get the Inertial Sensor's yaw angle bounded by (-180,180) * * This function uses the following values of errno when an error state is * reached: @@ -276,6 +276,233 @@ 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); + +/** + * Reset all 3 euler 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_euler(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 euler values to + * target euler values. Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target euler values for the euler values to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t imu_set_euler(uint8_t port, euler_s_t target); + +/** + * 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 + * \param target + * Target value for the rotation value to be set to + * \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 heading to target value + * Target will default to 360 if above 360 and default to 0 if below 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 + * \param target + * Target value for the heading value to be set to + * \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 + * Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target value for the pitch value to be set to + * \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 + * Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target value for the roll value to be set to + * \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 + * Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target value for the yaw value to be set to + * \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 } } diff --git a/include/pros/imu.hpp b/include/pros/imu.hpp index 0f56bdda7..a19074416 100644 --- a/include/pros/imu.hpp +++ b/include/pros/imu.hpp @@ -89,7 +89,7 @@ class Imu { * Get the Inertial Sensor's heading relative to the initial direction of its * x-axis * - * This value is bounded by (-360,360). Clockwise rotations are represented with + * This value is bounded by [0,360). Clockwise rotations are represented with * positive degree values, while counterclockwise rotations are represented with * negative ones. * @@ -138,7 +138,7 @@ class Imu { */ virtual pros::c::euler_s_t get_euler() const; /** - * Get the Inertial Sensor's pitch angle + * Get the Inertial Sensor's pitch angle bounded by (-180,180) * * This function uses the following values of errno when an error state is * reached: @@ -153,7 +153,7 @@ class Imu { */ virtual double get_pitch() const; /** - * Get the Inertial Sensor's roll angle + * Get the Inertial Sensor's roll angle bounded by (-180,180) * * This function uses the following values of errno when an error state is * reached: @@ -167,7 +167,7 @@ class Imu { */ virtual double get_roll() const; /** - * Get the Inertial Sensor's yaw angle + * Get the Inertial Sensor's yaw angle bounded by (-180,180) * * This function uses the following values of errno when an error state is * reached: @@ -196,7 +196,218 @@ 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 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. + */ + 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; + /** + * Reset all 3 euler 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_euler() const; + /** + * Sets the current reading of the Inertial Sensor's heading to target value + * Target will default to 360 if above 360 and default to 0 if below 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 + * \param target + * Target value for the heading value to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_heading(const 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 + * \param target + * Target value for the rotation value to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_rotation(const double target) const; + /** + * Sets the current reading of the Inertial Sensor's yaw to target value + * Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target value for yaw value to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_yaw(const 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 + * \param target + * Target value for the pitch value to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_pitch(const double target) const; + /** + * Sets the current reading of the Inertial Sensor's roll to target value + * Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target euler values for the euler values to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_roll(const double target) const; + /** + * Sets the current reading of the Inertial Sensor's euler values to + * target euler values. Will default to +/- 180 if target exceeds +/- 180. + * + * 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 + * \param target + * Target euler values for the euler values to be set to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_euler(const pros::c::euler_s_t target) const; + /** + * Get the Inertial Sensor's raw accelerometer values * * This function uses the following values of errno when an error state is * reached: diff --git a/src/devices/vdml_distance.c b/src/devices/vdml_distance.c index 853bb6b0f..97eba0755 100644 --- a/src/devices/vdml_distance.c +++ b/src/devices/vdml_distance.c @@ -1,5 +1,5 @@ /** - * \file devices/vdml_imu.c + * \file devices/vdml_distance.c * * Contains functions for interacting with the VEX Inertial sensor. * diff --git a/src/devices/vdml_imu.c b/src/devices/vdml_imu.c index 6cf5f11c9..ee5ff4147 100644 --- a/src/devices/vdml_imu.c +++ b/src/devices/vdml_imu.c @@ -16,12 +16,25 @@ #include "vdml/registry.h" #include "vdml/vdml.h" +#define IMU_EULER_LIMIT 180 +#define IMU_HEADING_MAX 360 + +#define DEGTORAD (M_PI / 180) + #define ERROR_IMU_STILL_CALIBRATING(port, device, err_return) \ if (vexDeviceImuStatusGet(device->device_info) & E_IMU_STATUS_CALIBRATING) { \ errno = EAGAIN; \ return_port(port - 1, err_return); \ } +typedef struct __attribute__ ((packed)) imu_reset_data { + double heading_offset; + double rotation_offset; + double pitch_offset; + double yaw_offset; + double roll_offset; +} imu_data_s_t; + int32_t imu_reset(uint8_t port) { claim_port_i(port - 1, E_DEVICE_IMU); ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); @@ -47,14 +60,16 @@ int32_t imu_set_data_rate(uint8_t port, uint32_t rate) { double imu_get_rotation(uint8_t port) { claim_port_f(port - 1, E_DEVICE_IMU); ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR_F); - double rtn = vexDeviceImuHeadingGet(device->device_info); + double rtn = vexDeviceImuHeadingGet(device->device_info) + ((imu_data_s_t*)registry_get_device(port - 1)->pad)->rotation_offset; return_port(port - 1, rtn); } double imu_get_heading(uint8_t port) { claim_port_f(port - 1, E_DEVICE_IMU); ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR_F); - double rtn = vexDeviceImuDegreesGet(device->device_info); + double rtn = vexDeviceImuDegreesGet(device->device_info) + ((imu_data_s_t*)registry_get_device(port - 1)->pad)->heading_offset; + if (rtn > IMU_HEADING_MAX) rtn -= IMU_HEADING_MAX; + if (rtn < 0) rtn += IMU_HEADING_MAX; return_port(port - 1, rtn); } @@ -63,21 +78,39 @@ double imu_get_heading(uint8_t port) { quaternion_s_t imu_get_quaternion(uint8_t port) { quaternion_s_t rtn = QUATERNION_ERR_INIT; - v5_smart_device_s_t* device; if (!claim_port_try(port - 1, E_DEVICE_IMU)) { return rtn; } - device = registry_get_device(port - 1); + v5_smart_device_s_t* device = registry_get_device(port - 1); ERROR_IMU_STILL_CALIBRATING(port, device, rtn); - // HACK: vexos represents quaternions as {a,b,c,d} and we want them in - // {x,y,z,w}. we don't know how exactly the quaternion data is filled, so best - // just to manually shuffle stuff into the right places here - V5_DeviceImuQuaternion qt; - vexDeviceImuQuaternionGet(device->device_info, &qt); - rtn.x = qt.b; - rtn.y = qt.c; - rtn.z = qt.d; - rtn.w = qt.a; + euler_s_t euler; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + // To calculate the quaternion values, we first get the euler values, add the offsets, + // and then do the calculations. + double roll = euler.roll + data->roll_offset; + double yaw = euler.yaw + data->yaw_offset; + double pitch = euler.pitch + data->pitch_offset; + + if (roll > IMU_EULER_LIMIT) roll -= 2 * IMU_EULER_LIMIT; + if (roll < -IMU_EULER_LIMIT) roll += 2 * IMU_EULER_LIMIT; + if (yaw > IMU_EULER_LIMIT) yaw -= 2 * IMU_EULER_LIMIT; + if (yaw < -IMU_EULER_LIMIT) yaw += 2 * IMU_EULER_LIMIT; + if (pitch > IMU_EULER_LIMIT) pitch -= 2 * IMU_EULER_LIMIT; + if (pitch < -IMU_EULER_LIMIT) pitch += 2 * IMU_EULER_LIMIT; + + double cy = cos(DEGTORAD * yaw * 0.5); + double sy = sin(DEGTORAD * yaw * 0.5); + double cp = cos(DEGTORAD * pitch * 0.5); + double sp = sin(DEGTORAD * pitch * 0.5); + double cr = cos(DEGTORAD * roll * 0.5); + double sr = sin(DEGTORAD * roll * 0.5); + + rtn.w = cr * cp * cy + sr * sp * sy; + rtn.x = sr * cp * cy - cr * sp * sy; + rtn.y = cr * sp * cy + sr * cp * sy; + rtn.z = cr * cp * sy - sr * sp * cy; + return_port(port - 1, rtn); } @@ -86,37 +119,75 @@ quaternion_s_t imu_get_quaternion(uint8_t port) { euler_s_t imu_get_euler(uint8_t port) { euler_s_t rtn = ATTITUDE_ERR_INIT; - v5_smart_device_s_t* device; if (!claim_port_try(port - 1, E_DEVICE_IMU)) { return rtn; } - device = registry_get_device(port - 1); + v5_smart_device_s_t* device = registry_get_device(port - 1); + imu_data_s_t* data = (imu_data_s_t*)device->pad; ERROR_IMU_STILL_CALIBRATING(port, device, rtn); vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&rtn); + rtn.pitch += data->pitch_offset; + rtn.yaw += data->yaw_offset; + rtn.roll += data->roll_offset; + if (rtn.roll > IMU_EULER_LIMIT) rtn.roll -= 2 * IMU_EULER_LIMIT; + if (rtn.roll < -IMU_EULER_LIMIT) rtn.roll += 2 * IMU_EULER_LIMIT; + if (rtn.yaw > IMU_EULER_LIMIT) rtn.yaw -= 2 * IMU_EULER_LIMIT; + if (rtn.yaw < -IMU_EULER_LIMIT) rtn.yaw += 2 * IMU_EULER_LIMIT; + if (rtn.pitch > IMU_EULER_LIMIT) rtn.pitch -= 2 * IMU_EULER_LIMIT; + if (rtn.pitch < -IMU_EULER_LIMIT) rtn.pitch += 2 * IMU_EULER_LIMIT; return_port(port - 1, rtn); } double imu_get_pitch(uint8_t port) { - return imu_get_euler(port).pitch; + double rtn = PROS_ERR_F; + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return rtn; + } + euler_s_t euler_values; + v5_smart_device_s_t* device = registry_get_device(port - 1); + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + rtn = euler_values.pitch + ((imu_data_s_t*)registry_get_device(port - 1)->pad)->pitch_offset; + if (rtn > IMU_EULER_LIMIT) rtn -= 2 * IMU_EULER_LIMIT; + if (rtn < -IMU_EULER_LIMIT) rtn += 2 * IMU_EULER_LIMIT; + return_port(port - 1, rtn); } double imu_get_roll(uint8_t port) { - return imu_get_euler(port).roll; + double rtn = PROS_ERR_F; + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return rtn; + } + euler_s_t euler_values; + v5_smart_device_s_t* device = registry_get_device(port - 1); + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + rtn = euler_values.roll + ((imu_data_s_t*)registry_get_device(port - 1)->pad)->roll_offset; + if (rtn > IMU_EULER_LIMIT) rtn -= 2 * IMU_EULER_LIMIT; + if (rtn < -IMU_EULER_LIMIT) rtn += 2 * IMU_EULER_LIMIT; + return_port(port - 1, rtn); } double imu_get_yaw(uint8_t port) { - return imu_get_euler(port).yaw; + double rtn = PROS_ERR_F; + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return rtn; + } + euler_s_t euler_values; + v5_smart_device_s_t* device = registry_get_device(port - 1); + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + rtn = euler_values.yaw + ((imu_data_s_t*)registry_get_device(port - 1)->pad)->yaw_offset; + if (rtn > IMU_EULER_LIMIT) rtn -= 2 * IMU_EULER_LIMIT; + if (rtn < -IMU_EULER_LIMIT) rtn += 2 * IMU_EULER_LIMIT; + return_port(port - 1, rtn); } #define RAW_IMU_ERR_INIT {.x = PROS_ERR_F, .y = PROS_ERR_F, .z = PROS_ERR_F}; imu_gyro_s_t imu_get_gyro_rate(uint8_t port) { imu_gyro_s_t rtn = RAW_IMU_ERR_INIT; - v5_smart_device_s_t* device; if (!claim_port_try(port - 1, E_DEVICE_IMU)) { return rtn; } - device = registry_get_device(port - 1); + v5_smart_device_s_t* device = registry_get_device(port - 1); ERROR_IMU_STILL_CALIBRATING(port, device, rtn); // NOTE: `V5_DeviceImuRaw` has the same form as a quaternion, but this call // never fills the `w` field, so we make a dummy quaternion container and copy @@ -131,11 +202,10 @@ imu_gyro_s_t imu_get_gyro_rate(uint8_t port) { imu_accel_s_t imu_get_accel(uint8_t port) { imu_accel_s_t rtn = RAW_IMU_ERR_INIT; - v5_smart_device_s_t* device; if (!claim_port_try(port - 1, E_DEVICE_IMU)) { return rtn; } - device = registry_get_device(port - 1); + v5_smart_device_s_t* device = registry_get_device(port - 1); ERROR_IMU_STILL_CALIBRATING(port, device, rtn); // NOTE: this is the same as `imu_get_raw_gyro` quaternion_s_t dummy; @@ -148,11 +218,145 @@ imu_accel_s_t imu_get_accel(uint8_t port) { imu_status_e_t imu_get_status(uint8_t port) { imu_status_e_t rtn = E_IMU_STATUS_ERROR; - v5_smart_device_s_t* device; if (!claim_port_try(port - 1, E_DEVICE_IMU)) { return rtn; } - device = registry_get_device(port - 1); + v5_smart_device_s_t* device = registry_get_device(port - 1); rtn = vexDeviceImuStatusGet(device->device_info); return_port(port - 1, rtn); } + +//Reset Functions: +int32_t imu_tare(uint8_t port){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + data->rotation_offset = -vexDeviceImuHeadingGet(device->device_info); + data->heading_offset = -vexDeviceImuDegreesGet(device->device_info); + data->pitch_offset = -euler_values.pitch; + data->roll_offset = -euler_values.roll; + data->yaw_offset = -euler_values.yaw; + return_port(port - 1, 1); +} + +int32_t imu_tare_euler(uint8_t port){ + return imu_set_euler(port, (euler_s_t){0,0,0}); +} + +int32_t imu_tare_heading(uint8_t port){ + return imu_set_heading(port, 0); +} + +int32_t imu_tare_rotation(uint8_t port){ + return imu_set_rotation(port, 0); +} + +int32_t imu_tare_pitch(uint8_t port){ + return imu_set_pitch(port, 0); +} + +int32_t imu_tare_roll(uint8_t port){ + return imu_set_roll(port, 0); +} + +int32_t imu_tare_yaw(uint8_t port){ + return imu_set_yaw(port, 0); +} + +//Setter Functions: +int32_t imu_set_rotation(uint8_t port, double target){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + data->rotation_offset = target - vexDeviceImuHeadingGet(device->device_info); + return_port(port - 1, 1); +} + +int32_t imu_set_heading(uint8_t port, double target){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + if (target > IMU_HEADING_MAX) target = IMU_HEADING_MAX; + if (target < 0) target = 0; + data->heading_offset = target - vexDeviceImuDegreesGet(device->device_info); + return_port(port - 1, 1); +} + +int32_t imu_set_pitch(uint8_t port, double target){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + if (target > IMU_EULER_LIMIT) target = IMU_EULER_LIMIT; + if (target < -IMU_EULER_LIMIT) target = -IMU_EULER_LIMIT; + data->pitch_offset = target - euler_values.pitch; + return_port(port - 1, 1); +} + +int32_t imu_set_roll(uint8_t port, double target){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + if (target > IMU_EULER_LIMIT) target = IMU_EULER_LIMIT; + if (target < -IMU_EULER_LIMIT) target = -IMU_EULER_LIMIT; + data->roll_offset = target - euler_values.roll; + return_port(port - 1, 1); +} + +int32_t imu_set_yaw(uint8_t port, double target){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + data->yaw_offset = target - euler_values.yaw; + if (target > IMU_EULER_LIMIT) target = IMU_EULER_LIMIT; + if (target < -IMU_EULER_LIMIT) target = -IMU_EULER_LIMIT; + return_port(port - 1, 1); +} + +int32_t imu_set_euler(uint8_t port, euler_s_t target){ + if (!claim_port_try(port - 1, E_DEVICE_IMU)) { + return PROS_ERR; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + euler_s_t euler_values; + vexDeviceImuAttitudeGet(device->device_info, (V5_DeviceImuAttitude*)&euler_values); + imu_data_s_t* data = (imu_data_s_t*)device->pad; + if (target.pitch > IMU_EULER_LIMIT) target.pitch = IMU_EULER_LIMIT; + if (target.pitch < -IMU_EULER_LIMIT) target.pitch = -IMU_EULER_LIMIT; + if (target.yaw > IMU_EULER_LIMIT) target.yaw = IMU_EULER_LIMIT; + if (target.yaw < -IMU_EULER_LIMIT) target.yaw = -IMU_EULER_LIMIT; + if (target.roll > IMU_EULER_LIMIT) target.roll = IMU_EULER_LIMIT; + if (target.roll < -IMU_EULER_LIMIT) target.roll = -IMU_EULER_LIMIT; + data->pitch_offset = target.pitch - euler_values.pitch; + data->roll_offset = target.roll - euler_values.roll; + data->yaw_offset = target.yaw - euler_values.yaw; + return_port(port - 1, 1); +} diff --git a/src/devices/vdml_imu.cpp b/src/devices/vdml_imu.cpp index 1956ccaae..ac7d1fc37 100644 --- a/src/devices/vdml_imu.cpp +++ b/src/devices/vdml_imu.cpp @@ -10,7 +10,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "pros/imu.h" #include "pros/imu.hpp" namespace pros { @@ -65,4 +64,57 @@ pros::c::imu_status_e_t Imu::get_status() const { bool Imu::is_calibrating() const { return get_status() & pros::c::E_IMU_STATUS_CALIBRATING; } + +std::int32_t Imu::tare_heading() const { + return pros::c::imu_tare_heading(_port); +} + +std::int32_t Imu::tare_rotation() const { + return pros::c::imu_tare_rotation(_port); +} + +std::int32_t Imu::tare_pitch() const { + return pros::c::imu_tare_pitch(_port); +} + +std::int32_t Imu::tare_yaw() const { + return pros::c::imu_tare_yaw(_port); +} + +std::int32_t Imu::tare_roll() const { + return pros::c::imu_tare_roll(_port); +} + +std::int32_t Imu::tare_euler() const { + return pros::c::imu_tare_euler(_port); +} + +std::int32_t Imu::set_heading(double target) const { + return pros::c::imu_set_heading(_port, target); +} + +std::int32_t Imu::set_rotation(double target) const { + return pros::c::imu_set_rotation(_port, target); +} + +std::int32_t Imu::set_pitch(double target) const { + return pros::c::imu_set_pitch(_port, target); +} + +std::int32_t Imu::set_yaw(double target) const { + return pros::c::imu_set_yaw(_port, target); +} + +std::int32_t Imu::set_roll(double target) const { + return pros::c::imu_set_roll(_port, target); +} + +std::int32_t Imu::set_euler(pros::c::euler_s_t target) const { + return pros::c::imu_set_euler(_port, target); +} + +std::int32_t Imu::tare() const { + return pros::c::imu_tare(_port); +} + } // namespace pros diff --git a/src/devices/vdml_optical.c b/src/devices/vdml_optical.c index 37fa384e2..75f2201fa 100644 --- a/src/devices/vdml_optical.c +++ b/src/devices/vdml_optical.c @@ -1,5 +1,5 @@ /** - * \file devices/vdml_imu.c + * \file devices/vdml_optical.c * * Contains functions for interacting with the VEX Inertial sensor. * From fb0225de1ca94da4b5a1909f3669d00c7a94a654 Mon Sep 17 00:00:00 2001 From: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Date: Thu, 18 Feb 2021 10:04:27 -0500 Subject: [PATCH 05/16] =?UTF-8?q?=F0=9F=9A=B8Change=20pros-cli-v5=20to=20p?= =?UTF-8?q?ros-cli=20(#277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Changed pros-v5-cli to pros-cli Co-authored-by: Alex Brooke --- azure-pipelines.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 980b66417..661e11e31 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,10 +22,12 @@ jobs: inputs: addToPath: true versionSpec: '3.6' - - task: PipAuthenticate@0 + - task: PipAuthenticate@1 inputs: artifactFeeds: 'pros-cli' - - bash: pip install pros-cli-v5 + # use official PyPi registry first and fall back to internal feed as needed + onlyAddExtraIndex: true + - bash: pip install pros-cli displayName: Install CLI - bash: | make template From 866cfefcf7b089ca28e9e0bdfcb14cd126ecbe42 Mon Sep 17 00:00:00 2001 From: Alex Brooke Date: Tue, 9 Mar 2021 01:25:12 -0500 Subject: [PATCH 06/16] =?UTF-8?q?=20=F0=9F=94=96=20Release=203.4.0=20(#279?= =?UTF-8?q?)=20(#283)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Clarify rotation_get_angle API (#264) * Fixed all instances of the liscense being outdated in file headers. (#272) * 👽 Add missing filesystem syscalls (#275) * Add missing file system stubs * Update src/system/dev/file_system_stubs.c Co-authored-by: nathan-moore * Put fchmod and fchmodat by chmod Co-authored-by: nathan-moore * ✨ Add Zeroing and Position Setting Functions for the IMU (#260) * Started on getter, setter, and zeroing features for IMU offset and read values respectively for the cpp api only. * Added comments to header files for all new functions and finished up setter functions. * Fixed documentation and removed extraneous ::IMU * version fix * Version Fix (anotha one) * Update version * Update version * Update version * Changed IMU offsets to initializer list * Reordered initializer list * Fixed a few file headers, changed CPP back to previous state, renamed reset function to calibrate, and started work on thread safe reset functions. * Added working C functions for resetting rotation and header. * C api for yaw, pitch, and roll reset working. * Added a new imu_reset function that resets all values from the IMU. * Added resets for CPP api (not tested yet) * Fixed build issue * Properly fixed the issue now. * Added setter functions for value readings, reworked reset functions accordingly. * Added missing semicolon, finished testing C API. * Added CPP api for setting values. * Added documentation for reset and set value functions. * Added imubl (IMU Backend Layer) for non-threadsafe functions, and also added documentation for those functions. Made get_euler thread safe again with a new seperate function for non-threadsafe use. * Added untracked file (IMUBL) * Fixed up all other debugging * Changed imubl location to VDML to hide it from users. * Changed imubl header description * Reverted version and drive code. * Added newlines back to the end of files * Updated Header Liscense Years * Revert "Updated Header Liscense Years" This reverts commit 36074f0a937cff9aa86fb0622964fa939c224055. * Packed the enum for imu reset data, fixed formatting and newline at end of imu.hpp. * Revert accidental change to get_accel docs. * Removed imubl and fixed packed attribute * Changed mentions of reset back to tare, and changed calibrate back to tare. * Revert drive code * Revert version * Revert version properly * Update include/pros/imu.hpp Co-authored-by: nathan-moore * Combined the declarations and definitions for device pointers. * Fixed offset for get euler, and also changed the quaternion function to involve offsets. (TO BE TESTED, no V5 on hand). * Finished testing and fixing quaternion, revert version and drive code. * Fixed indentation * Added euler setting and taring functions. * Added limits to the setting functions. * Added proper limiting (still needs work though) * Added proper value wrapping for when a value + offset exceeds a measurable range. * Revert version and drive code, added and tested C++ API for euler. * Added documentation about setter behaviors. * Added newline at end of vdml_imu.c * Stylization changes. * Fixed inconsistent sentence Co-authored-by: nathan-moore * 🔖 Bumped version to 3.4.0 * 🚸Change pros-cli-v5 to pros-cli (#277) * Changed pros-v5-cli to pros-cli Co-authored-by: Alex Brooke * ✨ Add microsecond timing (#281) * Add micros as a wrapper to vexSystemHighResTimeGet * Add micros using to rtos.hpp * Fix comment formatting * Add necessary include for VEXos function Co-authored-by: Alex Brooke Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss Co-authored-by: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss --- include/api.h | 6 +++--- include/pros/rtos.h | 7 +++++++ include/pros/rtos.hpp | 7 +++++++ src/rtos/tasks.c | 7 +++++++ version | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/api.h b/include/api.h index 5de639ece..822ac15f8 100644 --- a/include/api.h +++ b/include/api.h @@ -40,9 +40,9 @@ #endif /* __cplusplus */ #define PROS_VERSION_MAJOR 3 -#define PROS_VERSION_MINOR 3 -#define PROS_VERSION_PATCH 1 -#define PROS_VERSION_STRING "3.3.1" +#define PROS_VERSION_MINOR 4 +#define PROS_VERSION_PATCH 0 +#define PROS_VERSION_STRING "3.4.0" #define PROS_ERR (INT32_MAX) #define PROS_ERR_F (INFINITY) diff --git a/include/pros/rtos.h b/include/pros/rtos.h index 089b33cf9..7b29526fc 100644 --- a/include/pros/rtos.h +++ b/include/pros/rtos.h @@ -125,6 +125,13 @@ namespace c { */ uint32_t millis(void); +/** + * Gets the number of microseconds since PROS initialized, + * + * \return The number of microseconds since PROS initialized + */ +uint64_t micros(void); + /** * Creates a new task and add it to the list of tasks that are ready to run. * diff --git a/include/pros/rtos.hpp b/include/pros/rtos.hpp index a3c62cb62..02dae6372 100644 --- a/include/pros/rtos.hpp +++ b/include/pros/rtos.hpp @@ -367,6 +367,13 @@ class Mutex { */ using pros::c::millis; +/** + * Gets the number of microseconds since PROS initialized. + * + * \return The number of microseconds since PROS initialized + */ +using pros::c::micros; + /** * Delays a task for a given number of milliseconds. * diff --git a/src/rtos/tasks.c b/src/rtos/tasks.c index ec828d542..cd1f51b28 100644 --- a/src/rtos/tasks.c +++ b/src/rtos/tasks.c @@ -29,6 +29,8 @@ #include #include +#include "v5_api.h" + /* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining all the API functions to use the MPU wrappers. That should only be done when task.h is included from an application file. */ @@ -2060,6 +2062,11 @@ uint32_t xTicks; return xTicks * (configTICK_RATE_HZ / 1000); } + +uint64_t micros(void) +{ + return vexSystemHighResTimeGet(); +} /*-----------------------------------------------------------*/ uint32_t xTaskGetTickCountFromISR( void ) diff --git a/version b/version index bea438e9a..18091983f 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.3.1 +3.4.0 From 320fe94395412244411ae346ccf573631c8f37ff Mon Sep 17 00:00:00 2001 From: Kunwar Sahni Date: Fri, 14 May 2021 14:35:57 -0400 Subject: [PATCH 07/16] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20upgrade=20VEXos=20to?= =?UTF-8?q?=201.0.13=20(#289)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- firmware/libv5rts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/libv5rts b/firmware/libv5rts index d2f0845b4..e2a6f9e2f 160000 --- a/firmware/libv5rts +++ b/firmware/libv5rts @@ -1 +1 @@ -Subproject commit d2f0845b49a4dc1a583e34d6a53c1f5274d62a67 +Subproject commit e2a6f9e2f7488f7352b90d6a95a32c866702b5fa From 06e7e75063f1312b6d30d2900a82b1b6a5e1e256 Mon Sep 17 00:00:00 2001 From: Kunwar Sahni Date: Fri, 14 May 2021 18:22:06 -0400 Subject: [PATCH 08/16] Add rotation data rate function (#290) --- include/pros/rotation.h | 22 +++++++++++++++++++++ include/pros/rotation.hpp | 37 ++++++++++++++++++++++++++++------- src/devices/vdml_rotation.c | 14 +++++++++++++ src/devices/vdml_rotation.cpp | 4 ++++ 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/include/pros/rotation.h b/include/pros/rotation.h index 435c6b399..021a84171 100644 --- a/include/pros/rotation.h +++ b/include/pros/rotation.h @@ -28,6 +28,8 @@ namespace pros { namespace c { #endif +#define ROTATION_MINIMUM_DATA_RATE 5 + /** * Reset Rotation Sensor * @@ -46,6 +48,26 @@ namespace c { */ int32_t rotation_reset(uint8_t port); +/** + * Set the Rotation Sensor's refresh interval in milliseconds. + * + * The rate may be specified in increments of 5ms, and will be rounded down to + * the nearest increment. The minimum allowable refresh rate is 5ms. The default + * rate is 10ms. + * + * 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 Rotation Sensor + * + * \param port + * The V5 Rotation Sensor port number from 1-21 + * \param rate The data refresh interval in milliseconds + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t rotation_set_data_rate(uint8_t port, uint32_t rate); + /** * Set the Rotation Sensor position reading to a desired rotation value * diff --git a/include/pros/rotation.hpp b/include/pros/rotation.hpp index 256ed16f9..fa9de5528 100644 --- a/include/pros/rotation.hpp +++ b/include/pros/rotation.hpp @@ -30,11 +30,11 @@ class Rotation { Rotation(const std::uint8_t port) : _port(port){}; /** - * Reset the Rotation Sensor - * + * Reset the Rotation Sensor + * * Reset the current absolute position to be the same as the * Rotation Sensor angle. - * + * * 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). @@ -46,7 +46,30 @@ class Rotation { virtual std::int32_t reset(); /** - * Set the Rotation Sensor position reading to a desired rotation value + * Set the Rotation Sensor's refresh interval in milliseconds. + * + * The rate may be specified in increments of 5ms, and will be rounded down to + * the nearest increment. The minimum allowable refresh rate is 5ms. The default + * rate is 10ms. + * + * As values are copied into the shared memory buffer only at 10ms intervals, + * setting this value to less than 10ms does not mean that you can poll the + * sensor's values any faster. However, it will guarantee that the data is as + * recent as possible. + * + * 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 Rotation Sensor + * + * \param rate The data refresh interval in milliseconds + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_data_rate(std::uint32_t rate) const; + + /** + * Set the Rotation Sensor position reading to a desired rotation value * * This function uses the following values of errno when an error state is * reached: @@ -76,7 +99,7 @@ class Rotation { virtual std::int32_t reset_position(void); /** - * Get the Rotation Sensor's current position in centidegrees + * Get the Rotation Sensor's current position in centidegrees * * This function uses the following values of errno when an error state is * reached: @@ -89,7 +112,7 @@ class Rotation { virtual std::int32_t get_position(); /** - * Get the Rotation Sensor's current velocity in centidegrees per second + * Get the Rotation Sensor's current velocity in centidegrees per second * * This function uses the following values of errno when an error state is * reached: @@ -98,7 +121,7 @@ class Rotation { * * \param port * The V5 Rotation Sensor port number from 1-21 - * \return The + * \return The value or PROS_ERR_F if the operation failed, setting * errno. */ diff --git a/src/devices/vdml_rotation.c b/src/devices/vdml_rotation.c index 5cd9ba33e..19d150fe3 100644 --- a/src/devices/vdml_rotation.c +++ b/src/devices/vdml_rotation.c @@ -23,6 +23,20 @@ int32_t rotation_reset(uint8_t port) { return_port(port - 1, 1); } +int32_t rotation_set_data_rate(uint8_t port, uint32_t rate) { + claim_port_i(port - 1, E_DEVICE_IMU); + + // rate is not less than 5ms, and rounded down to nearest increment of 5 + if (rate < ROTATION_MINIMUM_DATA_RATE) { + rate = ROTATION_MINIMUM_DATA_RATE; + } else { + rate -= rate % ROTATION_MINIMUM_DATA_RATE; + } + + vexDeviceAbsEncDataRateSet(device->device_info, rate); + return_port(port - 1, 1); +} + int32_t rotation_reset_position(uint8_t port) { claim_port_i(port - 1, E_DEVICE_ROTATION); vexDeviceAbsEncPositionSet(device->device_info, 0); diff --git a/src/devices/vdml_rotation.cpp b/src/devices/vdml_rotation.cpp index 8649785df..a1c5009d5 100644 --- a/src/devices/vdml_rotation.cpp +++ b/src/devices/vdml_rotation.cpp @@ -17,6 +17,10 @@ std::int32_t Rotation::reset() { return pros::c::rotation_reset(_port); } +std::int32_t Rotation::set_data_rate(std::uint32_t rate) const { + return pros::c::rotation_set_data_rate(_port, rate); +} + std::int32_t Rotation::set_position(std::uint32_t position) { return pros::c::rotation_set_position(_port, position); } From 5abe15720be575b38511d3ac2518498dd8e0bfcc Mon Sep 17 00:00:00 2001 From: Andrew Strauss Date: Sat, 15 May 2021 18:14:01 -0400 Subject: [PATCH 09/16] =?UTF-8?q?=E2=9C=A8=20Allow=20user=20code=20to=20qu?= =?UTF-8?q?ery=20registry=20status=20(#282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Move registry_get_bound_type and registry_get_plugged_type to apix.h * Fix docs for registry functions to reflect their zero-indexed port number --- include/pros/apix.h | 38 ++++++++++++++++++++++++++++++++++---- include/vdml/registry.h | 30 ------------------------------ src/devices/registry.c | 1 - 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/include/pros/apix.h b/include/pros/apix.h index e516d2591..f95e7d075 100644 --- a/include/pros/apix.h +++ b/include/pros/apix.h @@ -381,14 +381,14 @@ typedef enum v5_device_e { } v5_device_e_t; /* - * Registers a device in the given port + * Registers a device in the given zero-indexed port * * Registers a device of the given type in the given port into the registry, if * that type of device is detected to be plugged in to that port. * * 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), or a + * ENXIO - The given value is not within the range of V5 ports (0-20), or a * a different device than specified is plugged in. * EADDRINUSE - The port is already registered to another device. * @@ -402,13 +402,13 @@ typedef enum v5_device_e { int registry_bind_port(uint8_t port, v5_device_e_t device_type); /* - * Deregisters a devices from the given port + * Deregisters a devices from the given zero-indexed port * * Removes the device registed in the given port, if there is one. * * 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). + * ENXIO - The given value is not within the range of V5 ports (0-20). * * \param port * The port number to deregister @@ -417,6 +417,36 @@ int registry_bind_port(uint8_t port, v5_device_e_t device_type); */ int registry_unbind_port(uint8_t port); +/* + * Returns the type of device registered to the zero-indexed port. + * + * 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 (0-20). + * + * \param port + * The V5 port number from 0-20 + * + * \return The type of device that is registered into the port (NOT what is + * plugged in) + */ +v5_device_e_t registry_get_bound_type(uint8_t port); + +/* + * Returns the type of the device plugged into the zero-indexed port. + * + * 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 (0-20). + * + * \param port + * The V5 port number from 0-20 + * + * \return The type of device that is plugged into the port (NOT what is + * registered) + */ +v5_device_e_t registry_get_plugged_type(uint8_t port); + /******************************************************************************/ /** Filesystem **/ /******************************************************************************/ diff --git a/include/vdml/registry.h b/include/vdml/registry.h index 9b34a0368..ea5800e98 100644 --- a/include/vdml/registry.h +++ b/include/vdml/registry.h @@ -65,36 +65,6 @@ v5_smart_device_s_t* registry_get_device(uint8_t port); */ v5_smart_device_s_t* registry_get_device_internal(uint8_t port); -/* - * Returns the type of device registered to the port. - * - * 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). - * - * \param port - * The V5 port number from 1-21 - * - * \return The type of device that is registered into the port (NOT what is - * plugged in) - */ -v5_device_e_t registry_get_bound_type(uint8_t port); - -/* - * Returns the type of the device plugged into the port. - * - * 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). - * - * \param port - * The V5 port number from 1-21 - * - * \return The type of device that is plugged into the port (NOT what is - * registered) - */ -v5_device_e_t registry_get_plugged_type(uint8_t port); - /* * Checks whether there is a discrepancy between the binding of the port and * what is actually plugged in. diff --git a/src/devices/registry.c b/src/devices/registry.c index f11808a82..3f5b55017 100644 --- a/src/devices/registry.c +++ b/src/devices/registry.c @@ -68,7 +68,6 @@ int registry_bind_port(uint8_t port, v5_device_e_t device_type) { } int registry_unbind_port(uint8_t port) { - port--; if (!VALIDATE_PORT_NO(port)) { errno = ENXIO; return PROS_ERR; From 07b0121b5d95e2b9765e6efc65925ac2158b855d Mon Sep 17 00:00:00 2001 From: AyushShukla3 <71904196+AyushShukla3@users.noreply.github.com> Date: Mon, 17 May 2021 10:06:09 -0700 Subject: [PATCH 10/16] =?UTF-8?q?=F0=9F=9A=B8=20add=20pros::IMU=20alias=20?= =?UTF-8?q?(#293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create alias for Imu in IMU.h and IMU.hpp * Revert version changes * Fix version number and add typdef to pros namespace * Revert typdef location to inside class * Move alias statement, remove c implementation Move the alias statement in imu.hpp outside of IMU class. Remove c implementation of alias. Resolves #288 * Add newline in version * Fix indent of alias --- include/pros/imu.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/pros/imu.hpp b/include/pros/imu.hpp index a19074416..6078aef9f 100644 --- a/include/pros/imu.hpp +++ b/include/pros/imu.hpp @@ -444,6 +444,9 @@ class Imu { */ virtual bool is_calibrating() const; }; + +using IMU = Imu; + } // namespace pros #endif From fc65d5818b441907936681369d8df9c775777149 Mon Sep 17 00:00:00 2001 From: AyushShukla3 <71904196+AyushShukla3@users.noreply.github.com> Date: Tue, 8 Jun 2021 08:48:43 -0700 Subject: [PATCH 11/16] =?UTF-8?q?=F0=9F=94=A5=20Deprecate=20PID=20setting?= =?UTF-8?q?=20functions=20(#294)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Keep functionality along with deprecation tags * Add message to deprecation warning * Deprecate other functions related to pid setting --- include/pros/motors.h | 16 ++++++++-------- include/pros/motors.hpp | 13 +++++++++++-- src/devices/vdml_motors.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/include/pros/motors.h b/include/pros/motors.h index 428374f8a..62a79662c 100644 --- a/include/pros/motors.h +++ b/include/pros/motors.h @@ -780,7 +780,7 @@ int32_t motor_set_gearing(uint8_t port, const motor_gearset_e_t gearset); * * \return A motor_pid_s_t struct formatted properly in 4.4. */ -motor_pid_s_t motor_convert_pid(double kf, double kp, double ki, double kd); +motor_pid_s_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_convert_pid(double kf, double kp, double ki, double kd); /** * Takes in floating point values and returns a properly formatted pid struct. @@ -814,7 +814,7 @@ motor_pid_s_t motor_convert_pid(double kf, double kp, double ki, double kd); * * \return A motor_pid_s_t struct formatted properly in 4.4. */ -motor_pid_full_s_t motor_convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, +motor_pid_full_s_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, double threshold, double loopspeed); /** @@ -839,7 +839,7 @@ motor_pid_full_s_t motor_convert_pid_full(double kf, double kp, double ki, doubl * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ -int32_t motor_set_pos_pid(uint8_t port, const motor_pid_s_t pid); +int32_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_set_pos_pid(uint8_t port, const motor_pid_s_t pid); /** * Sets one of motor_pid_full_s_t for the motor. @@ -862,7 +862,7 @@ int32_t motor_set_pos_pid(uint8_t port, const motor_pid_s_t pid); * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ -int32_t motor_set_pos_pid_full(uint8_t port, const motor_pid_full_s_t pid); +int32_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_set_pos_pid_full(uint8_t port, const motor_pid_full_s_t pid); /** * Sets one of motor_pid_s_t for the motor. This intended to just modify the @@ -886,7 +886,7 @@ int32_t motor_set_pos_pid_full(uint8_t port, const motor_pid_full_s_t pid); * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ -int32_t motor_set_vel_pid(uint8_t port, const motor_pid_s_t pid); +int32_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_set_vel_pid(uint8_t port, const motor_pid_s_t pid); /** * Sets one of motor_pid_full_s_t for the motor. @@ -909,7 +909,7 @@ int32_t motor_set_vel_pid(uint8_t port, const motor_pid_s_t pid); * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ -int32_t motor_set_vel_pid_full(uint8_t port, const motor_pid_full_s_t pid); +int32_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_set_vel_pid_full(uint8_t port, const motor_pid_full_s_t pid); /** * Sets the reverse flag for the motor. @@ -1034,7 +1034,7 @@ motor_gearset_e_t motor_get_gearing(uint8_t port); * \return A motor_pid_full_s_t containing the position PID constants last set * to the given motor */ -motor_pid_full_s_t motor_get_pos_pid(uint8_t port); +motor_pid_full_s_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_get_pos_pid(uint8_t port); /** * Gets the velocity PID that was set for the motor. This function will return @@ -1055,7 +1055,7 @@ motor_pid_full_s_t motor_get_pos_pid(uint8_t port); * \return A motor_pid_full_s_t containing the velocity PID constants last set * to the given motor */ -motor_pid_full_s_t motor_get_vel_pid(uint8_t port); +motor_pid_full_s_t __attribute__((deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage."))) motor_get_vel_pid(uint8_t port); /** * Gets the operation direction of the motor as set by the user. diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index b4eeeb3ed..6d743cfe3 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -20,6 +20,7 @@ #define _PROS_MOTORS_HPP_ #include + #include "pros/motors.h" namespace pros { @@ -565,6 +566,7 @@ class Motor { * * \return A motor_pid_s_t struct formatted properly in 4.4. */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] static motor_pid_s_t convert_pid(double kf, double kp, double ki, double kd); /** @@ -594,8 +596,9 @@ class Motor { * * \return A motor_pid_s_t struct formatted properly in 4.4. */ - static motor_pid_full_s_t convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, - double threshold, double loopspeed); + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] + static motor_pid_full_s_t convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, double threshold, + double loopspeed); /** * Sets one of motor_pid_s_t for the motor. This intended to just modify the @@ -614,6 +617,7 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t set_pos_pid(const motor_pid_s_t pid) const; /** @@ -632,6 +636,7 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t set_pos_pid_full(const motor_pid_full_s_t pid) const; /** @@ -651,6 +656,7 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t set_vel_pid(const motor_pid_s_t pid) const; /** @@ -669,6 +675,7 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t set_vel_pid_full(const motor_pid_full_s_t pid) const; /** @@ -768,6 +775,7 @@ class Motor { * \return A motor_pid_full_s_t containing the position PID constants last set * to the given motor */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual motor_pid_full_s_t get_pos_pid(void) const; /** @@ -785,6 +793,7 @@ class Motor { * \return A motor_pid_full_s_t containing the velocity PID constants last set * to the given motor */ + [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual motor_pid_full_s_t get_vel_pid(void) const; /** diff --git a/src/devices/vdml_motors.cpp b/src/devices/vdml_motors.cpp index 1f636c812..016dd341f 100644 --- a/src/devices/vdml_motors.cpp +++ b/src/devices/vdml_motors.cpp @@ -112,11 +112,17 @@ motor_gearset_e_t Motor::get_gearing(void) const { } motor_pid_full_s_t Motor::get_pos_pid(void) const { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_get_pos_pid(_port); + #pragma GCC diagnostic pop } motor_pid_full_s_t Motor::get_vel_pid(void) const { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_get_vel_pid(_port); + #pragma GCC diagnostic pop } std::int32_t Motor::get_raw_position(std::uint32_t* const timestamp) const { @@ -196,28 +202,46 @@ std::int32_t Motor::set_gearing(const motor_gearset_e_t gearset) const { } motor_pid_s_t Motor::convert_pid(double kf, double kp, double ki, double kd) { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_convert_pid(kf, kp, ki, kd); + #pragma GCC diagnostic pop } motor_pid_full_s_t Motor::convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, double threshold, double loopspeed) { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_convert_pid_full(kf, kp, ki, kd, filter, limit, threshold, loopspeed); + #pragma GCC diagnostic pop } std::int32_t Motor::set_pos_pid(const motor_pid_s_t pid) const { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_pos_pid(_port, pid); + #pragma GCC diagnostic pop } std::int32_t Motor::set_pos_pid_full(const motor_pid_full_s_t pid) const { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_pos_pid_full(_port, pid); + #pragma GCC diagnostic pop } std::int32_t Motor::set_vel_pid(const motor_pid_s_t pid) const { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_vel_pid(_port, pid); + #pragma GCC diagnostic pop } std::int32_t Motor::set_vel_pid_full(const motor_pid_full_s_t pid) const { + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_vel_pid_full(_port, pid); + #pragma GCC diagnostic pop } std::int32_t Motor::set_zero_position(const double position) const { From c58f04c2ae710bfacd4313ff0694e9836714db5c Mon Sep 17 00:00:00 2001 From: Eric Dong Date: Thu, 1 Jul 2021 18:27:18 -0400 Subject: [PATCH 12/16] =?UTF-8?q?=E2=9C=A8Added=20Delay=20to=20IMU=20Reset?= =?UTF-8?q?=20(#286)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added delay to IMU reset * variable delay * change comments --- include/pros/imu.h | 3 ++- include/pros/imu.hpp | 3 ++- src/devices/vdml_imu.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/pros/imu.h b/include/pros/imu.h index ab3bc8d55..18fdc8af7 100644 --- a/include/pros/imu.h +++ b/include/pros/imu.h @@ -61,7 +61,8 @@ typedef struct __attribute__((__packed__)) euler_s { /** * Calibrate IMU * - * This takes approximately 2 seconds, and is a non-blocking operation. + * Calibration takes approximately 2 seconds, but this function only blocks + * until the IMU status flag is set properly to E_IMU_STATUS_CALIBRATING. * * This function uses the following values of errno when an error state is * reached: diff --git a/include/pros/imu.hpp b/include/pros/imu.hpp index 6078aef9f..9e3991fb6 100644 --- a/include/pros/imu.hpp +++ b/include/pros/imu.hpp @@ -31,7 +31,8 @@ class Imu { /** * Calibrate IMU * - * This takes approximately 2 seconds, and is a non-blocking operation. + * Calibration takes approximately 2 seconds, but this function only blocks + * until the IMU status flag is set properly to E_IMU_STATUS_CALIBRATING. * * This function uses the following values of errno when an error state is * reached: diff --git a/src/devices/vdml_imu.c b/src/devices/vdml_imu.c index ee5ff4147..f6bef1bd9 100644 --- a/src/devices/vdml_imu.c +++ b/src/devices/vdml_imu.c @@ -39,6 +39,8 @@ int32_t imu_reset(uint8_t port) { claim_port_i(port - 1, E_DEVICE_IMU); ERROR_IMU_STILL_CALIBRATING(port, device, PROS_ERR); vexDeviceImuReset(device->device_info); + // delay for vexos to set calibration flag + while(!(vexDeviceImuStatusGet(device->device_info) & E_IMU_STATUS_CALIBRATING)) delay(5); return_port(port - 1, 1); } From dedc4b1a4ed51460921cc9b3ae064193787f6c8b Mon Sep 17 00:00:00 2001 From: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Date: Tue, 6 Jul 2021 15:05:50 -0500 Subject: [PATCH 13/16] =?UTF-8?q?=E2=9C=A8Add=20Simplified=20Screen=20API?= =?UTF-8?q?=20Option=20(#299)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✨Add Simplified Screen API Option (#299) Co-authored-by: Ayush Shukla --- include/api.h | 2 + include/pros/screen.h | 345 ++++++++++++++++++++++++++++++++++++++++ include/pros/screen.hpp | 251 +++++++++++++++++++++++++++++ src/devices/screen.c | 328 ++++++++++++++++++++++++++++++++++++++ src/devices/screen.cpp | 101 ++++++++++++ src/system/startup.c | 4 +- 6 files changed, 1030 insertions(+), 1 deletion(-) create mode 100644 include/pros/screen.h create mode 100644 include/pros/screen.hpp create mode 100644 src/devices/screen.c create mode 100644 src/devices/screen.cpp diff --git a/include/api.h b/include/api.h index 822ac15f8..84598e0d9 100644 --- a/include/api.h +++ b/include/api.h @@ -58,6 +58,7 @@ #include "pros/optical.h" #include "pros/rtos.h" #include "pros/rotation.h" +#include "pros/screen.h" #include "pros/vision.h" #ifdef __cplusplus @@ -70,6 +71,7 @@ #include "pros/optical.hpp" #include "pros/rotation.hpp" #include "pros/rtos.hpp" +#include "pros/screen.hpp" #include "pros/vision.hpp" #endif diff --git a/include/pros/screen.h b/include/pros/screen.h new file mode 100644 index 000000000..9d0f22513 --- /dev/null +++ b/include/pros/screen.h @@ -0,0 +1,345 @@ +/** + * \file screen.h + * + * Brain screen display and touch functions. + * + * Contains user calls to the v5 screen for touching and displaying graphics. + * + * \copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _PROS_SCREEN_H_ +#define _PROS_SCREEN_H_ + +#include +#include +#define _GNU_SOURCE +#include +#undef _GNU_SOURCE +#include + +#include "pros/colors.h" // c color macros + +#ifdef __cplusplus +extern "C" { +namespace pros { +#endif + +/** + * ! Different font sizes that can be used in printing text. + */ +typedef enum { + E_TEXT_SMALL = 0, ///< Small text font size + E_TEXT_MEDIUM, ///< Normal/Medium text font size + E_TEXT_LARGE, ///< Large text font size + E_TEXT_MEDIUM_CENTER, ///< Medium centered text + E_TEXT_LARGE_CENTER ///< Large centered text +} text_format_e_t; + +/** + * ! Enum indicating what the current touch status is for the touchscreen. + */ +typedef enum { + E_TOUCH_RELEASED = 0, ///< Last interaction with screen was a quick press + E_TOUCH_PRESSED, ///< Last interaction with screen was a release + E_TOUCH_HELD ///< User is holding screen down +} last_touch_e_t; + +/** + * ! Struct representing screen touch status, screen last x, screen last y, press count, release count. + */ +typedef struct screen_touch_status_s { + last_touch_e_t touch_status; ///< Represents if the screen is being held, released, or pressed. + int16_t x; ///< Represents the x value of the location of the touch. + int16_t y; ///< Represents the y value of the location of the touch. + int32_t press_count; ///< Represents how many times the screen has be pressed. + int32_t release_count; ///< Represents how many times the user released after a touch on the screen. +} screen_touch_status_s_t; + +#ifdef PROS_USE_SIMPLE_NAMES +#ifdef __cplusplus +#define TEXT_SMALL pros::E_TEXT_SMALL +#define TEXT_MEDIUM pros::E_TEXT_MEDIUM +#define TEXT_LARGE pros::E_TEXT_LARGE +#define TEXT_MEDIUM_CENTER pros::E_TEXT_MEDIUM_CENTER +#define TEXT_LARGE_CENTER pros::E_LARGE_CENTER +#define TOUCH_RELEASED pros::E_TOUCH_RELEASED +#define TOUCH_PRESSED pros::E_TOUCH_PRESSED +#define TOUCH_HELD pros::E_TOUCH_HELD +#else +#define TEXT_SMALL E_TEXT_SMALL +#define TEXT_MEDIUM E_TEXT_MEDIUM +#define TEXT_LARGE E_TEXT_LARGE +#define TEXT_MEDIUM_CENTER E_TEXT_MEDIUM_CENTER +#define TEXT_LARGE_CENTER E_TEXT_LARGE_CENTER +#define TOUCH_RELEASED E_TOUCH_RELEASED +#define TOUCH_PRESSED E_TOUCH_PRESSED +#define TOUCH_HELD E_TOUCH_HELD +#endif +#endif + +typedef void (*touch_event_cb_fn_t)(int16_t, int16_t); + +#ifdef __cplusplus +namespace c { +#endif + +/******************************************************************************/ +/** Screen Graphical Display Functions **/ +/** **/ +/** These functions allow programmers to display shapes on the v5 screen **/ +/******************************************************************************/ + +/** + * Set the pen color for subsequent graphics operations + * + * \param color The pen color to set (it is recommended to use values + * from the enum defined in colors.h) + */ +void screen_set_pen(uint32_t color); + +/** + * Set the eraser color for erasing and the current background. + * + * \param color The background color to set (it is recommended to use values + * from the enum defined in colors.h) + */ +void screen_set_eraser(uint32_t color); + +/** + * Get the current pen color. + * + * \return The current pen color in the form of a value from the enum defined in colors.h. + */ +uint32_t screen_get_pen(void); + +/** + * Get the current eraser color. + * + * \return The current eraser color in the form of a value from the enum defined in colors.h. + */ +uint32_t screen_get_eraser(void); + +/** + * Clear display with eraser color + */ +void screen_erase(void); + +/** + * Scroll lines on the display upwards. + * + * \param start_line The line from which scrolling will start + * \param lines The number of lines to scroll up + */ +void screen_scroll(int16_t start_line, int16_t lines); + +/** + * Scroll lines within a region on the display + * + * This function behaves in the same way as `screen_scroll`, except that you + * specify a rectangular region within which to scroll lines instead of a start + * line. + * + * \param x0, y0 The (x,y) coordinates of the first corner of the + * rectangular region + * \param x1, y1 The (x,y) coordinates of the second corner of the + * rectangular region + * \param lines The number of lines to scroll upwards + */ +void screen_scroll_area(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t lines); + +/** + * Copy a screen region (designated by a rectangle) from an off-screen buffer + * to the screen + * + * \param x0, y0 The (x,y) coordinates of the first corner of the + * rectangular region of the screen + * \param x1, y1 The (x,y) coordinates of the second corner of the + * rectangular region of the screen + * \param buf Off-screen buffer containing screen data + * \param stride Off-screen buffer width in pixels, such that image size + * is stride-padding + */ +void screen_copy_area(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint32_t* buf, int32_t stride); + +/** + * Draw a single pixel on the screen using the current pen color + * + * \param x, y The (x,y) coordinates of the pixel + */ +void screen_draw_pixel(int16_t x, int16_t y); + +/** + * Erase a pixel from the screen (Sets the location) + * + * \param x, y The (x,y) coordinates of the erased + */ +void screen_erase_pixel(int16_t x, int16_t y); + +/** + * Draw a line on the screen using the current pen color + * + * \param x0, y0 The (x, y) coordinates of the first point of the line + * \param x1, y1 The (x, y) coordinates of the second point of the line + */ +void screen_draw_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1); + +/** + * Erase a line on the screen using the current eraser color + * + * \param x0, y0 The (x, y) coordinates of the first point of the line + * \param x1, y1 The (x, y) coordinates of the second point of the line + */ +void screen_erase_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1); + +/** + * Draw a rectangle on the screen using the current pen color + * + * \param x0, y0 The (x,y) coordinates of the first point of the rectangle + * \param x1, y1 The (x,y) coordinates of the second point of the rectangle + */ +void screen_draw_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1); + +/** + * Erase a rectangle on the screen using the current eraser color + * + * \param x0, y0 The (x,y) coordinates of the first point of the rectangle + * \param x1, y1 The (x,y) coordinates of the second point of the rectangle + */ +void screen_erase_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1); + +/** + * Fill a rectangular region of the screen using the current pen + * color + * + * \param x0, y0 The (x,y) coordinates of the first point of the rectangle + * \param x1, y1 The (x,y) coordinates of the second point of the rectangle + */ +void screen_fill_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1); + +/** + * Draw a circle on the screen using the current pen color + * + * \param x, y The (x,y) coordinates of the center of the circle + * \param r The radius of the circle + */ +void screen_draw_circle(int16_t x, int16_t y, int16_t radius); + +/** + * Erase a circle on the screen using the current eraser color + * + * \param x, y The (x,y) coordinates of the center of the circle + * \param r The radius of the circle + */ +void screen_erase_circle(int16_t x, int16_t y, int16_t radius); + +/** + * Fill a circular region of the screen using the current pen + * color + * + * \param x, y The (x,y) coordinates of the center of the circle + * \param r The radius of the circle + */ +void screen_fill_circle(int16_t x, int16_t y, int16_t radius); + +/******************************************************************************/ +/** Screen Text Display Functions **/ +/** **/ +/** These functions allow programmers to display text on the v5 screen **/ +/******************************************************************************/ + +/** + * Print a formatted string to the screen on the specified line + * + * Will default to a medium sized font by default if invalid txt_fmt is given. + * + * \param txt_fmt Text format enum that determines if the text is medium, large, medium_center, or large_center. (DOES NOT SUPPORT SMALL) + * \param line The line number on which to print + * \param text Format string + * \param ... Optional list of arguments for the format string + */ +void screen_print(text_format_e_t txt_fmt, const int16_t line, const char* text, ...); + +/** + * Print a formatted string to the screen at the specified point + * + * Will default to a medium sized font by default if invalid txt_fmt is given. + * + * Text formats medium_center and large_center will default to medium and large respectively. + * + * \param txt_fmt Text format enum that determines if the text is small, medium, or large. + * \param x The y coordinate of the top left corner of the string + * \param y The x coordinate of the top left corner of the string + * \param text Format string + * \param ... Optional list of arguments for the format string + */ +void screen_print_at(text_format_e_t txt_fmt, const int16_t x, const int16_t y, const char* text, ...); + +/** + * Print a formatted string to the screen on the specified line + * + * Same as `display_printf` except that this uses a `va_list` instead of the + * ellipsis operator so this can be used by other functions. + * + * Will default to a medium sized font by default if invalid txt_fmt is given. + * Exposed mostly for writing libraries and custom functions. + * + * \param txt_fmt Text format enum that determines if the text is medium, large, medium_center, or large_center. (DOES NOT SUPPORT SMALL) + * \param line The line number on which to print + * \param text Format string + * \param args List of arguments for the format string + */ +void screen_vprintf(text_format_e_t txt_fmt, const int16_t line, const char* text, va_list args); + +/** + * Print a formatted string to the screen at the specified coordinates + * + * Same as `display_printf_at` except that this uses a `va_list` instead of the + * ellipsis operator so this can be used by other functions. + * + * Will default to a medium sized font by default if invalid txt_fmt is given. + * + * Text formats medium_center and large_center will default to medium and large respectively. + * Exposed mostly for writing libraries and custom functions. + * + * \param txt_fmt Text format enum that determines if the text is small, medium, or large. + * \param x, y The (x,y) coordinates of the top left corner of the string + * \param text Format string + * \param args List of arguments for the format string + */ +void screen_vprintf_at(text_format_e_t txt_fmt, const int16_t x, const int16_t y, const char* text, va_list args); + +/******************************************************************************/ +/** Screen Touch Functions **/ +/** **/ +/** These functions allow programmers to access **/ +/** information about screen touches **/ +/******************************************************************************/ + +/** + * Gets the touch status of the last touch of the screen. + * + * \return The last_touch_e_t enum specifier that indicates the last touch status of the screen (E_TOUCH_EVENT_RELEASE, E_TOUCH_EVENT_PRESS, or E_TOUCH_EVENT_PRESS_AND_HOLD). + * This will be released by default if no action was taken. + */ +screen_touch_status_s_t screen_touch_status(void); + +/** + * Assigns a callback function to be called when a certain touch event happens. + * + * \param cb Function pointer to callback when event type happens + * \param event_type Touch event that will trigger the callback. + */ +void screen_touch_callback(touch_event_cb_fn_t cb, last_touch_e_t event_type); + +#ifdef __cplusplus +} //namespace c +} //namespace pros +} +#endif + +#endif diff --git a/include/pros/screen.hpp b/include/pros/screen.hpp new file mode 100644 index 000000000..75e3a62f1 --- /dev/null +++ b/include/pros/screen.hpp @@ -0,0 +1,251 @@ +/** + * \file screen.hpp + * + * Brain screen display and touch functions. + * + * Contains user calls to the v5 screen for touching and displaying graphics. + * + * \copyright (c) 2017, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _PROS_SCREEN_HPP_ +#define _PROS_SCREEN_HPP_ + +#include "pros/screen.h" +#include +#include + +namespace pros { +namespace screen { + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" + +namespace { +template +T convert_args(T arg) { + return arg; +} +const char* convert_args(const std::string& arg) { + return arg.c_str(); +} +} // namespace + +#pragma GCC diagnostic pop + + /******************************************************************************/ + /** Screen Graphical Display Functions **/ + /** **/ + /** These functions allow programmers to display shapes on the v5 screen **/ + /******************************************************************************/ + + /** + * Set the pen color for subsequent graphics operations + * + * \param color The pen color to set (it is recommended to use values + * from the enum defined in colors.h) + */ + void set_pen(const std::uint32_t color); + + /** + * Set the eraser color for clearing and the current background. + * + * \param color The background color to set (it is recommended to use values + * from the enum defined in colors.h) + */ + void set_eraser(const std::uint32_t color); + + /** + * Get the current pen color. + * + * \return The current pen color of the screen object in the form of a value from the enum defined in colors.h. + */ + std::uint32_t get_pen(); + + /** + * Get the current eraser color. + * + * \return The current eraser color of the screen object in the form of a value from the enum defined in colors.h. + */ + std::uint32_t get_eraser(); + + /** + * Clear display with eraser color + */ + void erase(); + + /** + * Scroll lines on the display upwards. + * + * \param start_line The line from which scrolling will start + * \param lines The number of lines to scroll up + */ + void scroll(const std::int16_t start_line, const std::int16_t lines); + + /** + * Scroll lines within a region on the display + * + * This function behaves in the same way as `screen_scroll`, except that you + * specify a rectangular region within which to scroll lines instead of a start + * line. + * + * \param x0, y0 The (x,y) coordinates of the first corner of the + * rectangular region + * \param x1, y1 The (x,y) coordinates of the second corner of the + * rectangular region + * \param lines The number of lines to scroll upwards + */ + void scroll_area(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1, std::int16_t lines); + + /** + * Copy a screen region (designated by a rectangle) from an off-screen buffer + * to the screen + * + * \param x0, y0 The (x,y) coordinates of the first corner of the + * rectangular region of the screen + * \param x1, y1 The (x,y) coordinates of the second corner of the + * rectangular region of the screen + * \param buf Off-screen buffer containing screen data + * \param stride Off-screen buffer width in pixels, such that image size + * is stride-padding + */ + void copy_area(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1, uint32_t* buf, const std::int32_t stride); + + /** + * Draw a single pixel on the screen using the current pen color + * + * \param x, y The (x,y) coordinates of the pixel + */ + void draw_pixel(const std::int16_t x, const std::int16_t y); + + /** + * Erase a pixel from the screen (Sets the location) + * + * \param x, y The (x,y) coordinates of the erased pixel + */ + void erase_pixel(const std::int16_t x, const std::int16_t y); + + /** + * Draw a line on the screen using the current pen color + * + * \param x0, y0 The (x, y) coordinates of the first point of the line + * \param x1, y1 The (x, y) coordinates of the second point of the line + */ + void draw_line(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1); + + /** + * Erase a line on the screen using the current eraser color + * + * \param x0, y0 The (x, y) coordinates of the first point of the line + * \param x1, y1 The (x, y) coordinates of the second point of the line + */ + void erase_line(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1); + + /** + * Draw a rectangle on the screen using the current pen color + * + * \param x0, y0 The (x,y) coordinates of the first point of the rectangle + * \param x1, y1 The (x,y) coordinates of the second point of the rectangle + */ + void draw_rect(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1); + + /** + * Erase a rectangle on the screen using the current eraser color + * + * \param x0, y0 The (x,y) coordinates of the first point of the rectangle + * \param x1, y1 The (x,y) coordinates of the second point of the rectangle + */ + void erase_rect(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1); + + /** + * Fill a rectangular region of the screen using the current pen + * color + * + * \param x0, y0 The (x,y) coordinates of the first point of the rectangle + * \param x1, y1 The (x,y) coordinates of the second point of the rectangle + */ + void fill_rect(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1); + + /** + * Draw a circle on the screen using the current pen color + * + * \param x, y The (x,y) coordinates of the center of the circle + * \param r The radius of the circle + */ + void draw_circle(const std::int16_t x, const std::int16_t y, const std::int16_t radius); + + /** + * Erase a circle on the screen using the current eraser color + * + * \param x, y The (x,y) coordinates of the center of the circle + * \param r The radius of the circle + */ + void erase_circle(const std::int16_t x, const std::int16_t y, const std::int16_t radius); + + /** + * Fill a circular region of the screen using the current pen + * color + * + * \param x, y The (x,y) coordinates of the center of the circle + * \param r The radius of the circle + */ + void fill_circle(const std::int16_t x, const std::int16_t y, const std::int16_t radius); + + /******************************************************************************/ + /** Screen Text Display Functions **/ + /** **/ + /** These functions allow programmers to display text on the v5 screen **/ + /******************************************************************************/ + + /** + * Print a formatted string to the screen, overwrite available for printing at location too. + * + * Will default to a medium sized font by default if invalid txt_fmt is given. + * + * \param txt_fmt Text format enum that determines if the text is medium, large, medium_center, or large_center. (DOES NOT SUPPORT SMALL) + * \param line The line number on which to print + * \param x The (x,y) coordinates of the top left corner of the string + * \param y The (x,y) coordinates of the top left corner of the string + * \param fmt Format string + * \param ... Optional list of arguments for the format string + */ + template + void print(pros::text_format_e_t txt_fmt, const std::int16_t line, const char* text, Params... args){ + pros::c::screen_print(txt_fmt, line, text, convert_args(args)...); + } + + template + void print(pros::text_format_e_t txt_fmt, const std::int16_t x, const std::int16_t y, const char* text, Params... args){ + pros::c::screen_print_at(txt_fmt, x, y, text, convert_args(args)...); + } + + /******************************************************************************/ + /** Screen Touch Functions **/ + /** **/ + /** These functions allow programmers to access **/ + /** information about screen touches **/ + /******************************************************************************/ + + /** + * Gets the touch status of the last touch of the screen. 0 by default. + * + * \return The last_touch_e_t enum specifier that indicates the last touch status of the screen (E_TOUCH_EVENT_RELEASE, E_TOUCH_EVENT_PRESS, or E_TOUCH_EVENT_PRESS_AND_HOLD). + */ + screen_touch_status_s_t touch_status(); + + /** + * Assigns a callback function to be called when a certain touch event happens. + * + * \param cb Function pointer to callback when event type happens + * \param event_type Touch event that will trigger the callback. + */ + void touch_callback(touch_event_cb_fn_t cb, last_touch_e_t event_type); + +} //namespace screen +} //namespace pros + +#endif //header guard diff --git a/src/devices/screen.c b/src/devices/screen.c new file mode 100644 index 000000000..e919f0253 --- /dev/null +++ b/src/devices/screen.c @@ -0,0 +1,328 @@ +/** + * \file screen.c + * + * \brief Brain screen display and touch functions. + * + * Contains user calls to the v5 screen for touching and displaying graphics. + * + * \copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "pros/screen.h" + +#include +#include +#include + +#include "common/linkedlist.h" +#include "kapi.h" +#include "pros/apix.h" +#include "v5_api.h" // vexDisplay* + +/******************************************************************************/ +/** Screen Graphical Display Functions **/ +/** **/ +/** These functions allow programmers to display shapes on the v5 screen **/ +/******************************************************************************/ + +static mutex_t _screen_mutex = NULL; + +typedef struct touch_event_position_data_s { + int16_t x; + int16_t y; +} touch_event_position_data_s_t; + +void screen_set_pen(uint32_t color){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayForegroundColor(color); + mutex_give(_screen_mutex); +} + +void screen_set_eraser(uint32_t color){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayBackgroundColor(color); + mutex_give(_screen_mutex); +} + +uint32_t screen_get_pen(void){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + uint32_t color = vexDisplayForegroundColorGet(); + mutex_give(_screen_mutex); + return color; +} + +uint32_t screen_get_eraser(void){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + uint32_t color = vexDisplayBackgroundColorGet(); + mutex_give(_screen_mutex); + return color; +} + +void screen_erase(void){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayErase(); + mutex_give(_screen_mutex); +} + +void screen_scroll(int16_t start_line, int16_t lines){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayScroll(start_line, lines); + mutex_give(_screen_mutex); +} + +void screen_scroll_area(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t lines){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayScrollRect(x0, y0, x1, y1, lines); + mutex_give(_screen_mutex); +} + +void screen_copy_area(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint32_t* buf, int32_t stride){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayCopyRect(x0, y0, x1, y1, buf, stride); + mutex_give(_screen_mutex); +} + +void screen_draw_pixel(int16_t x, int16_t y){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayPixelSet(x, y); + mutex_give(_screen_mutex); +} + +void screen_erase_pixel(int16_t x, int16_t y){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayPixelClear(x, y); + mutex_give(_screen_mutex); +} + +void screen_draw_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayLineDraw(x0, y0, x1, y1); + mutex_give(_screen_mutex); +} + +void screen_erase_line(int16_t x0, int16_t y0, int16_t x1, int16_t y1){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayLineClear(x0, y0, x1, y1); + mutex_give(_screen_mutex); +} + +void screen_draw_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayRectDraw(x0, y0, x1, y1); + mutex_give(_screen_mutex); +} + +void screen_erase_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayRectClear(x0, y0, x1, y1); + mutex_give(_screen_mutex); +} + +void screen_fill_rect(int16_t x0, int16_t y0, int16_t x1, int16_t y1){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayRectFill(x0, y0, x1, y1); + mutex_give(_screen_mutex); +} + +void screen_draw_circle(int16_t x, int16_t y, int16_t radius){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayCircleDraw(x, y, radius); + mutex_give(_screen_mutex); +} + +void screen_erase_circle(int16_t x, int16_t y, int16_t radius){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayCircleClear(x, y, radius); + mutex_give(_screen_mutex); +} + +void screen_fill_circle(int16_t x, int16_t y, int16_t radius){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexDisplayCircleFill(x, y, radius); + mutex_give(_screen_mutex); +} + +/******************************************************************************/ +/** Screen Text Display Functions **/ +/** **/ +/** These functions allow programmers to display text on the v5 screen **/ +/******************************************************************************/ + +void screen_print(text_format_e_t txt_fmt, const int16_t line, const char* text, ...){ + va_list args; + va_start(args, text); + screen_vprintf((uint8_t)txt_fmt, line, text, args); + va_end(args); +} + +void screen_print_at(text_format_e_t txt_fmt, int16_t x, int16_t y, const char* text, ...){ + va_list args; + va_start(args, text); + screen_vprintf_at((uint8_t)txt_fmt, x, y, text, args); + va_end(args); +} + +void screen_vprintf(text_format_e_t txt_fmt, const int16_t line, const char* text, va_list args){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + char* out; + vasprintf(&out, text, args); + va_list empty; + switch(txt_fmt){ + case E_TEXT_SMALL: + case E_TEXT_MEDIUM: + { + vexDisplayVString(line, out, empty); + break; + } + case E_TEXT_LARGE: + { + vexDisplayVBigString(line, out, empty); + break; + } + case E_TEXT_MEDIUM_CENTER: + { + vexDisplayVCenteredString(line, out, empty); + break; + } + case E_TEXT_LARGE_CENTER: + { + vexDisplayVBigCenteredString(line, out, empty); + break; + } + default: + { + vexDisplayVString(line, out, empty); + break; + } + } + mutex_give(_screen_mutex); +} + +void screen_vprintf_at(text_format_e_t txt_fmt, const int16_t x, const int16_t y, const char* text, va_list args){ + mutex_take(_screen_mutex, TIMEOUT_MAX); + char* out; + vasprintf(&out, text, args); + va_list empty; + switch(txt_fmt){ + case E_TEXT_SMALL: + { + vexDisplayVSmallStringAt(x, y, out, empty); + break; + } + case E_TEXT_MEDIUM: + case E_TEXT_MEDIUM_CENTER: + { + vexDisplayVStringAt(x, y, out, empty); + break; + } + case E_TEXT_LARGE: + case E_TEXT_LARGE_CENTER: + { + vexDisplayVBigStringAt(x, y, out, empty); + break; + } + default: + { + vexDisplayVStringAt(x, y, out, empty); + break; + } + } + mutex_give(_screen_mutex); +} +/******************************************************************************/ +/** Screen Touch Functions **/ +/** **/ +/** These functions allow programmers to access **/ +/** information about screen touches **/ +/******************************************************************************/ + +screen_touch_status_s_t screen_touch_status(void){ + V5_TouchStatus v5_touch_status; + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexTouchDataGet(&v5_touch_status); + screen_touch_status_s_t rtv; + rtv.touch_status = (last_touch_e_t)v5_touch_status.lastEvent; + rtv.x = v5_touch_status.lastXpos; + rtv.y = v5_touch_status.lastYpos; + rtv.press_count = v5_touch_status.pressCount; + rtv.release_count = v5_touch_status.releaseCount; + mutex_give(_screen_mutex); + return rtv; +} + +static linked_list_s_t* _touch_event_release_handler_list = NULL; +static linked_list_s_t* _touch_event_press_handler_list = NULL; +static linked_list_s_t* _touch_event_press_auto_handler_list = NULL; + +static void _set_up_touch_callback_storage() { + _touch_event_release_handler_list = linked_list_init(); + _touch_event_press_handler_list = linked_list_init(); + _touch_event_press_auto_handler_list = linked_list_init(); +} + +void screen_touch_callback(touch_event_cb_fn_t cb, last_touch_e_t event_type) { + mutex_take(_screen_mutex, TIMEOUT_MAX); + switch (event_type) { + case E_TOUCH_RELEASED: + linked_list_prepend_func(_touch_event_release_handler_list, (generic_fn_t)cb); + break; + case E_TOUCH_PRESSED: + linked_list_prepend_func(_touch_event_press_handler_list, (generic_fn_t)cb); + break; + case E_TOUCH_HELD: + linked_list_prepend_func(_touch_event_press_auto_handler_list, (generic_fn_t)cb); + break; + } + mutex_give(_screen_mutex); +} + +static task_stack_t touch_handle_task_stack[TASK_STACK_DEPTH_DEFAULT]; +static static_task_s_t touch_handle_task_buffer; +static task_t touch_handle_task; + +static void _handle_cb(ll_node_s_t* current, void* data) { + ((touch_event_cb_fn_t)(current->payload.func))(((touch_event_position_data_s_t*)(data))->x, + ((touch_event_position_data_s_t*)(data))->y); +} + +static inline bool _touch_status_equivalent(V5_TouchStatus x, V5_TouchStatus y) { + return (x.lastEvent == y.lastEvent) && (x.lastXpos == y.lastXpos) && (x.lastYpos == y.lastYpos); +} + +void _touch_handle_task(void* ignore) { + V5_TouchStatus last, current; + while (true) { + mutex_take(_screen_mutex, TIMEOUT_MAX); + vexTouchDataGet(¤t); + if (!_touch_status_equivalent(current, last)) { + touch_event_position_data_s_t event_data = { .x = current.lastXpos, .y = current.lastYpos }; + switch (current.lastEvent) { + case E_TOUCH_RELEASED: + linked_list_foreach(_touch_event_release_handler_list, _handle_cb, (void*)&event_data); + break; + case E_TOUCH_PRESSED: + linked_list_foreach(_touch_event_press_handler_list, _handle_cb, (void*)&event_data); + break; + case E_TOUCH_HELD: + linked_list_foreach(_touch_event_press_auto_handler_list, _handle_cb, + (void*)&event_data); + break; + } + last = current; + } + mutex_give(_screen_mutex); + delay(10); + } +} + +void graphical_context_daemon_initialize(void) { + _screen_mutex = mutex_create(); + _set_up_touch_callback_storage(); + touch_handle_task = + task_create_static(_touch_handle_task, NULL, TASK_PRIORITY_MIN + 2, TASK_STACK_DEPTH_DEFAULT, + "PROS Graphics Touch Handler", touch_handle_task_stack, &touch_handle_task_buffer); +} diff --git a/src/devices/screen.cpp b/src/devices/screen.cpp new file mode 100644 index 000000000..0ca811bdb --- /dev/null +++ b/src/devices/screen.cpp @@ -0,0 +1,101 @@ +/** + * \file screen.cpp + * + * \brief Brain screen display and touch functions. + * + * Contains user calls to the v5 screen for touching and displaying graphics. + * + * \copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "pros/screen.hpp" + +namespace pros { +namespace screen { + + void set_pen(const std::uint32_t color){ + pros::c::screen_set_pen(color); + } + + void set_eraser(const std::uint32_t color){ + pros::c::screen_set_eraser(color); + } + + std::uint32_t get_pen(){ + return pros::c::screen_get_pen(); + } + + std::uint32_t get_eraser(){ + return pros::c::screen_get_eraser(); + } + + void erase(){ + pros::c::screen_erase(); + } + + void scroll(const std::int16_t start_line, const std::int16_t lines){ + pros::c::screen_scroll(start_line, lines); + } + + void scroll_area(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1, std::int16_t lines){ + pros::c::screen_scroll_area(x0, y0, x1, y1, lines); + } + + void copy_area(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1, uint32_t* buf, const std::int32_t stride){ + pros::c::screen_copy_area( x0, y0, x1, y1, buf, stride); + } + + void draw_pixel(const std::int16_t x, const std::int16_t y){ + pros::c::screen_draw_pixel(x, y); + } + + void erase_pixel(const std::int16_t x, const std::int16_t y){ + pros::c::screen_erase_pixel(x, y); + } + + void draw_line(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1){ + pros::c::screen_draw_line(x0, y0, x1, y1); + } + + void erase_line(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1){ + pros::c::screen_erase_line(x0, y0, x1, y1); + } + + void draw_rect(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1){ + pros::c::screen_draw_rect(x0, y0, x1, y1); + } + + void erase_rect(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1){ + pros::c::screen_erase_rect(x0, y0, x1, y1); + } + + void fill_rect(const std::int16_t x0, const std::int16_t y0, const std::int16_t x1, const std::int16_t y1){ + pros::c::screen_fill_rect(x0, y0, x1, y1); + } + + void draw_circle(const std::int16_t x, const std::int16_t y, const std::int16_t radius){ + pros::c::screen_draw_circle(x, y, radius); + } + + void erase_circle(const std::int16_t x, const std::int16_t y, const std::int16_t radius){ + pros::c::screen_erase_circle(x, y, radius); + } + + void fill_circle(const std::int16_t x, const std::int16_t y, const std::int16_t radius){ + pros::c::screen_fill_circle(x, y, radius); + } + + screen_touch_status_s_t touch_status() { + return pros::c::screen_touch_status(); + } + + void touch_callback(touch_event_cb_fn_t cb, last_touch_e_t event_type){ + pros::c::screen_touch_callback(cb, event_type); + } + +} // namespace screen +} // namespace pros diff --git a/src/system/startup.c b/src/system/startup.c index 6dee6af75..4eb91d104 100644 --- a/src/system/startup.c +++ b/src/system/startup.c @@ -21,7 +21,7 @@ extern void rtos_initialize(); extern void vfs_initialize(); extern void system_daemon_initialize(); -// extern void graphical_context_daemon_initialize(void); +extern void graphical_context_daemon_initialize(void); extern void display_initialize(void); extern void rtos_sched_start(); extern void vdml_initialize(); @@ -40,6 +40,8 @@ __attribute__((constructor(101))) static void pros_init(void) { vdml_initialize(); + graphical_context_daemon_initialize(); + display_initialize(); // NOTE: this function should be called after all other initialize From 8584c0eaf8f0e318f56ed1fde91ba23eff6292c6 Mon Sep 17 00:00:00 2001 From: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Date: Thu, 12 Aug 2021 10:33:27 -0700 Subject: [PATCH 14/16] =?UTF-8?q?=F0=9F=9A=B8=20Fix=20Rotation=20Data=20Ra?= =?UTF-8?q?te=20Setting=20(#302)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔖 Release 3.4.0 (#279) * Clarify rotation_get_angle API (#264) * Fixed all instances of the liscense being outdated in file headers. (#272) * 👽 Add missing filesystem syscalls (#275) * Add missing file system stubs * Update src/system/dev/file_system_stubs.c Co-authored-by: nathan-moore * Put fchmod and fchmodat by chmod Co-authored-by: nathan-moore * ✨ Add Zeroing and Position Setting Functions for the IMU (#260) * Started on getter, setter, and zeroing features for IMU offset and read values respectively for the cpp api only. * Added comments to header files for all new functions and finished up setter functions. * Fixed documentation and removed extraneous ::IMU * version fix * Version Fix (anotha one) * Update version * Update version * Update version * Changed IMU offsets to initializer list * Reordered initializer list * Fixed a few file headers, changed CPP back to previous state, renamed reset function to calibrate, and started work on thread safe reset functions. * Added working C functions for resetting rotation and header. * C api for yaw, pitch, and roll reset working. * Added a new imu_reset function that resets all values from the IMU. * Added resets for CPP api (not tested yet) * Fixed build issue * Properly fixed the issue now. * Added setter functions for value readings, reworked reset functions accordingly. * Added missing semicolon, finished testing C API. * Added CPP api for setting values. * Added documentation for reset and set value functions. * Added imubl (IMU Backend Layer) for non-threadsafe functions, and also added documentation for those functions. Made get_euler thread safe again with a new seperate function for non-threadsafe use. * Added untracked file (IMUBL) * Fixed up all other debugging * Changed imubl location to VDML to hide it from users. * Changed imubl header description * Reverted version and drive code. * Added newlines back to the end of files * Updated Header Liscense Years * Revert "Updated Header Liscense Years" This reverts commit 36074f0a937cff9aa86fb0622964fa939c224055. * Packed the enum for imu reset data, fixed formatting and newline at end of imu.hpp. * Revert accidental change to get_accel docs. * Removed imubl and fixed packed attribute * Changed mentions of reset back to tare, and changed calibrate back to tare. * Revert drive code * Revert version * Revert version properly * Update include/pros/imu.hpp Co-authored-by: nathan-moore * Combined the declarations and definitions for device pointers. * Fixed offset for get euler, and also changed the quaternion function to involve offsets. (TO BE TESTED, no V5 on hand). * Finished testing and fixing quaternion, revert version and drive code. * Fixed indentation * Added euler setting and taring functions. * Added limits to the setting functions. * Added proper limiting (still needs work though) * Added proper value wrapping for when a value + offset exceeds a measurable range. * Revert version and drive code, added and tested C++ API for euler. * Added documentation about setter behaviors. * Added newline at end of vdml_imu.c * Stylization changes. * Fixed inconsistent sentence Co-authored-by: nathan-moore * 🔖 Bumped version to 3.4.0 * 🚸Change pros-cli-v5 to pros-cli (#277) * Changed pros-v5-cli to pros-cli Co-authored-by: Alex Brooke * ✨ Add microsecond timing (#281) * Add micros as a wrapper to vexSystemHighResTimeGet * Add micros using to rtos.hpp * Fix comment formatting * Add necessary include for VEXos function Co-authored-by: Alex Brooke Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss * 🔖 Release 3.5.0: Quality Post Event Update (#300) * Clarify rotation_get_angle API (#264) * Fixed all instances of the liscense being outdated in file headers. (#272) * 👽 Add missing filesystem syscalls (#275) * Add missing file system stubs * Update src/system/dev/file_system_stubs.c Co-authored-by: nathan-moore * Put fchmod and fchmodat by chmod Co-authored-by: nathan-moore * ✨ Add Zeroing and Position Setting Functions for the IMU (#260) * Started on getter, setter, and zeroing features for IMU offset and read values respectively for the cpp api only. * Added comments to header files for all new functions and finished up setter functions. * Fixed documentation and removed extraneous ::IMU * version fix * Version Fix (anotha one) * Update version * Update version * Update version * Changed IMU offsets to initializer list * Reordered initializer list * Fixed a few file headers, changed CPP back to previous state, renamed reset function to calibrate, and started work on thread safe reset functions. * Added working C functions for resetting rotation and header. * C api for yaw, pitch, and roll reset working. * Added a new imu_reset function that resets all values from the IMU. * Added resets for CPP api (not tested yet) * Fixed build issue * Properly fixed the issue now. * Added setter functions for value readings, reworked reset functions accordingly. * Added missing semicolon, finished testing C API. * Added CPP api for setting values. * Added documentation for reset and set value functions. * Added imubl (IMU Backend Layer) for non-threadsafe functions, and also added documentation for those functions. Made get_euler thread safe again with a new seperate function for non-threadsafe use. * Added untracked file (IMUBL) * Fixed up all other debugging * Changed imubl location to VDML to hide it from users. * Changed imubl header description * Reverted version and drive code. * Added newlines back to the end of files * Updated Header Liscense Years * Revert "Updated Header Liscense Years" This reverts commit 36074f0a937cff9aa86fb0622964fa939c224055. * Packed the enum for imu reset data, fixed formatting and newline at end of imu.hpp. * Revert accidental change to get_accel docs. * Removed imubl and fixed packed attribute * Changed mentions of reset back to tare, and changed calibrate back to tare. * Revert drive code * Revert version * Revert version properly * Update include/pros/imu.hpp Co-authored-by: nathan-moore * Combined the declarations and definitions for device pointers. * Fixed offset for get euler, and also changed the quaternion function to involve offsets. (TO BE TESTED, no V5 on hand). * Finished testing and fixing quaternion, revert version and drive code. * Fixed indentation * Added euler setting and taring functions. * Added limits to the setting functions. * Added proper limiting (still needs work though) * Added proper value wrapping for when a value + offset exceeds a measurable range. * Revert version and drive code, added and tested C++ API for euler. * Added documentation about setter behaviors. * Added newline at end of vdml_imu.c * Stylization changes. * Fixed inconsistent sentence Co-authored-by: nathan-moore * 🚸Change pros-cli-v5 to pros-cli (#277) * Changed pros-v5-cli to pros-cli Co-authored-by: Alex Brooke * 🔖 Release 3.4.0 (#279) (#283) * Clarify rotation_get_angle API (#264) * Fixed all instances of the liscense being outdated in file headers. (#272) * 👽 Add missing filesystem syscalls (#275) * Add missing file system stubs * Update src/system/dev/file_system_stubs.c Co-authored-by: nathan-moore * Put fchmod and fchmodat by chmod Co-authored-by: nathan-moore * ✨ Add Zeroing and Position Setting Functions for the IMU (#260) * Started on getter, setter, and zeroing features for IMU offset and read values respectively for the cpp api only. * Added comments to header files for all new functions and finished up setter functions. * Fixed documentation and removed extraneous ::IMU * version fix * Version Fix (anotha one) * Update version * Update version * Update version * Changed IMU offsets to initializer list * Reordered initializer list * Fixed a few file headers, changed CPP back to previous state, renamed reset function to calibrate, and started work on thread safe reset functions. * Added working C functions for resetting rotation and header. * C api for yaw, pitch, and roll reset working. * Added a new imu_reset function that resets all values from the IMU. * Added resets for CPP api (not tested yet) * Fixed build issue * Properly fixed the issue now. * Added setter functions for value readings, reworked reset functions accordingly. * Added missing semicolon, finished testing C API. * Added CPP api for setting values. * Added documentation for reset and set value functions. * Added imubl (IMU Backend Layer) for non-threadsafe functions, and also added documentation for those functions. Made get_euler thread safe again with a new seperate function for non-threadsafe use. * Added untracked file (IMUBL) * Fixed up all other debugging * Changed imubl location to VDML to hide it from users. * Changed imubl header description * Reverted version and drive code. * Added newlines back to the end of files * Updated Header Liscense Years * Revert "Updated Header Liscense Years" This reverts commit 36074f0a937cff9aa86fb0622964fa939c224055. * Packed the enum for imu reset data, fixed formatting and newline at end of imu.hpp. * Revert accidental change to get_accel docs. * Removed imubl and fixed packed attribute * Changed mentions of reset back to tare, and changed calibrate back to tare. * Revert drive code * Revert version * Revert version properly * Update include/pros/imu.hpp Co-authored-by: nathan-moore * Combined the declarations and definitions for device pointers. * Fixed offset for get euler, and also changed the quaternion function to involve offsets. (TO BE TESTED, no V5 on hand). * Finished testing and fixing quaternion, revert version and drive code. * Fixed indentation * Added euler setting and taring functions. * Added limits to the setting functions. * Added proper limiting (still needs work though) * Added proper value wrapping for when a value + offset exceeds a measurable range. * Revert version and drive code, added and tested C++ API for euler. * Added documentation about setter behaviors. * Added newline at end of vdml_imu.c * Stylization changes. * Fixed inconsistent sentence Co-authored-by: nathan-moore * 🔖 Bumped version to 3.4.0 * 🚸Change pros-cli-v5 to pros-cli (#277) * Changed pros-v5-cli to pros-cli Co-authored-by: Alex Brooke * ✨ Add microsecond timing (#281) * Add micros as a wrapper to vexSystemHighResTimeGet * Add micros using to rtos.hpp * Fix comment formatting * Add necessary include for VEXos function Co-authored-by: Alex Brooke Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss Co-authored-by: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss * ⬆️ upgrade VEXos to 1.0.13 (#289) * Add rotation data rate function (#290) * ✨ Allow user code to query registry status (#282) * Move registry_get_bound_type and registry_get_plugged_type to apix.h * Fix docs for registry functions to reflect their zero-indexed port number * 🚸 add pros::IMU alias (#293) * Create alias for Imu in IMU.h and IMU.hpp * Revert version changes * Fix version number and add typdef to pros namespace * Revert typdef location to inside class * Move alias statement, remove c implementation Move the alias statement in imu.hpp outside of IMU class. Remove c implementation of alias. Resolves #288 * Add newline in version * Fix indent of alias * 🔥 Deprecate PID setting functions (#294) * Keep functionality along with deprecation tags * Add message to deprecation warning * Deprecate other functions related to pid setting * ✨Added Delay to IMU Reset (#286) * added delay to IMU reset * variable delay * change comments * ✨Add Simplified Screen API Option (#299) ✨Add Simplified Screen API Option (#299) Co-authored-by: Ayush Shukla * 🔖 Release 3.5.0 Co-authored-by: Alex Brooke Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss Co-authored-by: AyushShukla3 <71904196+AyushShukla3@users.noreply.github.com> Co-authored-by: Eric Dong * Changed IMU port claim to rotation port claim Co-authored-by: Alex Brooke Co-authored-by: Octogonapus Co-authored-by: Kunwar Sahni Co-authored-by: nathan-moore Co-authored-by: Andrew Strauss Co-authored-by: AyushShukla3 <71904196+AyushShukla3@users.noreply.github.com> Co-authored-by: Eric Dong --- include/api.h | 4 ++-- src/devices/vdml_rotation.c | 2 +- version | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/api.h b/include/api.h index 84598e0d9..15ae25d2c 100644 --- a/include/api.h +++ b/include/api.h @@ -40,9 +40,9 @@ #endif /* __cplusplus */ #define PROS_VERSION_MAJOR 3 -#define PROS_VERSION_MINOR 4 +#define PROS_VERSION_MINOR 5 #define PROS_VERSION_PATCH 0 -#define PROS_VERSION_STRING "3.4.0" +#define PROS_VERSION_STRING "3.5.0" #define PROS_ERR (INT32_MAX) #define PROS_ERR_F (INFINITY) diff --git a/src/devices/vdml_rotation.c b/src/devices/vdml_rotation.c index 19d150fe3..a9a0027e0 100644 --- a/src/devices/vdml_rotation.c +++ b/src/devices/vdml_rotation.c @@ -24,7 +24,7 @@ int32_t rotation_reset(uint8_t port) { } int32_t rotation_set_data_rate(uint8_t port, uint32_t rate) { - claim_port_i(port - 1, E_DEVICE_IMU); + claim_port_i(port - 1, E_DEVICE_ROTATION); // rate is not less than 5ms, and rounded down to nearest increment of 5 if (rate < ROTATION_MINIMUM_DATA_RATE) { diff --git a/version b/version index 18091983f..1545d9665 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.4.0 +3.5.0 From 06af9774cc3be27cd18e8a70e54713f59fd84214 Mon Sep 17 00:00:00 2001 From: Will Xu <54247087+WillXuCodes@users.noreply.github.com> Date: Fri, 13 Aug 2021 08:47:38 -0700 Subject: [PATCH 15/16] =?UTF-8?q?=E2=9C=A8Add=20Support=20for=20the=20Game?= =?UTF-8?q?=20Positioning=20System=20Sensor=20(#305)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial Commit * Added GPS Files * Finished C file * Added C++ files * Added proper error handling * Upgrade SDK * Fixed compilation issues * Added documentation and fixed constructor * Update Implementation * Added newlines after header files Co-authored-by: Kunwar Sahni --- firmware/libv5rts | 2 +- include/api.h | 2 + include/pros/apix.h | 1 + include/pros/gps.h | 313 +++++++++++++++++++++++++++++++++++++++ include/pros/gps.hpp | 284 +++++++++++++++++++++++++++++++++++ src/devices/vdml_gps.c | 146 ++++++++++++++++++ src/devices/vdml_gps.cpp | 74 +++++++++ 7 files changed, 821 insertions(+), 1 deletion(-) create mode 100644 include/pros/gps.h create mode 100644 include/pros/gps.hpp create mode 100644 src/devices/vdml_gps.c create mode 100644 src/devices/vdml_gps.cpp diff --git a/firmware/libv5rts b/firmware/libv5rts index e2a6f9e2f..6113a67b5 160000 --- a/firmware/libv5rts +++ b/firmware/libv5rts @@ -1 +1 @@ -Subproject commit e2a6f9e2f7488f7352b90d6a95a32c866702b5fa +Subproject commit 6113a67b5599301020a8bf81b7a0456cb298d703 diff --git a/include/api.h b/include/api.h index 15ae25d2c..c682dc1d7 100644 --- a/include/api.h +++ b/include/api.h @@ -51,6 +51,7 @@ #include "pros/colors.h" #include "pros/distance.h" #include "pros/ext_adi.h" +#include "pros/gps.h" #include "pros/imu.h" #include "pros/llemu.h" #include "pros/misc.h" @@ -64,6 +65,7 @@ #ifdef __cplusplus #include "pros/adi.hpp" #include "pros/distance.hpp" +#include "pros/gps.hpp" #include "pros/imu.hpp" #include "pros/llemu.hpp" #include "pros/misc.hpp" diff --git a/include/pros/apix.h b/include/pros/apix.h index f95e7d075..14c8a3138 100644 --- a/include/pros/apix.h +++ b/include/pros/apix.h @@ -376,6 +376,7 @@ typedef enum v5_device_e { E_DEVICE_VISION = 11, E_DEVICE_ADI = 12, E_DEVICE_OPTICAL = 16, + E_DEVICE_GPS = 20, E_DEVICE_GENERIC = 129, E_DEVICE_UNDEFINED = 255 } v5_device_e_t; diff --git a/include/pros/gps.h b/include/pros/gps.h new file mode 100644 index 000000000..0a83edea9 --- /dev/null +++ b/include/pros/gps.h @@ -0,0 +1,313 @@ +/** + * \file pros/gps.h + * + * Contains prototypes for functions related to the VEX GPS. + * + * Visit https://pros.cs.purdue.edu/v5/api/c/gps.html to learn + * more. + * + * This file should not be modified by users, since it gets replaced whenever + * a kernel upgrade occurs. + * + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _PROS_GPS_H_ +#define _PROS_GPS_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +namespace pros { +namespace c { +#endif + +typedef struct __attribute__((__packed__)) gps_status_s { + double x; ///< X Position (meters) + double y; ///< Y Position (meters) + double pitch; ///< Percieved Pitch based on GPS + IMU + double roll; ///< Percieved Roll based on GPS + IMU + double yaw; ///< Percieved Yaw based on GPS + IMU +} gps_status_s_t; + +struct gps_raw_s { + double x; ///< Percieved Pitch based on GPS + IMU + double y; ///< Percieved Roll based on GPS + IMU + double z; ///< Percieved Yaw based on GPS + IMU +}; + +typedef struct gps_raw_s gps_accel_s_t; +typedef struct gps_raw_s gps_gyro_s_t; + +/** + * Set the GPS's offset relative to the center of turning in meters, + * as well as its initial position. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \param xOffset + * Cartesian 4-Quadrant X offset from center of turning (meters) + * \param yOffset + * Cartesian 4-Quadrant Y offset from center of turning (meters) + * \param xInitial + * Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters) + * \param yInitial + * Initial 4-Quadrant Y Position, with (0,0) being at the center of the field (meters) + * \param headingInitial + * Heading with 0 being north on the field, in degrees [0,360) going clockwise + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_initialize_full(uint8_t port, double xInitial, double yInitial, double headingInitial, double xOffset, + double yOffset); + +/** + * Set the GPS's offset relative to the center of turning in meters. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \param xOffset + * Cartesian 4-Quadrant X offset from center of turning (meters) + * \param yOffset + * Cartesian 4-Quadrant Y offset from center of turning (meters) + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_set_offset(uint8_t port, double xOffset, double yOffset); + +/** + * Get the GPS's location relative to the center of turning/origin in meters. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \param xOffset + * Pointer to cartesian 4-Quadrant X offset from center of turning (meters) + * \param yOffset + * Pointer to cartesian 4-Quadrant Y offset from center of turning (meters) + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_get_offset(uint8_t port, double* xOffset, double* yOffset); + +/** + * Sets the robot's location relative to the center of the field in meters. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \param xInitial + * Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters) + * \param yInitial + * Initial 4-Quadrant Y Position, with (0,0) being at the center of the field (meters) + * \param headingInitial + * Heading with 0 being north on the field, in degrees [0,360) going clockwise + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_set_position(uint8_t port, double xInitial, double yInitial, double headingInitial); + +/** + * Set the GPS sensor's data rate in milliseconds, only applies to IMU on GPS. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \param rate + * Data rate in milliseconds (Minimum: 5 ms) + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_set_data_rate(uint8_t port, uint32_t rate); + +/** + * Get the possible RMS (Root Mean Squared) error in meters for GPS position. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return Possible RMS (Root Mean Squared) error in meters for GPS position. + * If the operation failed, returns PROS_ERR_F and errno is set. + */ +double gps_get_error(uint8_t port); + +/** + * Gets the position and roll, yaw, and pitch of the GPS. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return A struct (gps_status_s_t) containing values mentioned above. + * If the operation failed, all the structure's members are filled with + * PROS_ERR_F and errno is set. + */ +gps_status_s_t gps_get_status(uint8_t port); + +/** + * Get the heading in [0,360) degree values. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The heading in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_heading(uint8_t port); + +/** + * Get the heading in the max double value and min double value scale. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The heading in [DOUBLE_MIN, DOUBLE_MAX] values. If the operation + * fails, returns PROS_ERR_F and errno is set. + */ +double gps_get_heading_raw(uint8_t port); + +/** + * Gets the GPS sensor's elapsed rotation 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \return The elased heading in degrees. If the operation fails, returns + * PROS_ERR_F and errno is set. + */ +double gps_get_rotation(uint8_t port); + +/** + * Set the GPS sensor's rotation value 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \param target + * Target rotation value to set rotation value to + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_set_rotation(uint8_t port, double target); + +/** + * Tare the GPS sensor's rotation 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ +int32_t gps_tare_rotation(uint8_t port); + +/** + * Get the GPS's raw gyroscope values + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * \return The raw gyroscope values. If the operation failed, all the + * structure's members are filled with PROS_ERR_F and errno is set. + */ +gps_gyro_s_t gps_get_gyro_rate(uint8_t port); + +/** + * Get the GPS's raw accelerometer values + * + * 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 GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS's port number from 1-21 + * \return The raw accelerometer values. If the operation failed, all the + * structure's members are filled with PROS_ERR_F and errno is set. + */ +gps_accel_s_t gps_get_accel(uint8_t port); + +#ifdef __cplusplus +} +} +} +#endif + +#endif diff --git a/include/pros/gps.hpp b/include/pros/gps.hpp new file mode 100644 index 000000000..fd4ed96d3 --- /dev/null +++ b/include/pros/gps.hpp @@ -0,0 +1,284 @@ +/** + * \file pros/gps.hpp + * + * Contains prototypes for functions related to the VEX GPS. + * + * Visit https://pros.cs.purdue.edu/v5/api/cpp/gps.html to learn + * more. + * + * This file should not be modified by users, since it gets replaced whenever + * a kernel upgrade occurs. + * + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef _PROS_IMU_HPP_ +#define _PROS_IMU_HPP_ + +#include + +#include + +#include "pros/gps.h" + +namespace pros { +class Gps { + const std::uint8_t _port; + + public: + Gps(const std::uint8_t port) : _port(port){}; + + Gps(const std::uint8_t port, double xInitial, double yInitial, double headingInitial) : _port(port) { + pros::c::gps_set_position(port, xInitial, yInitial, headingInitial); + }; + + Gps(const std::uint8_t port, double xOffset, double yOffset) : _port(port) { + pros::c::gps_set_offset(port, xOffset, yOffset); + }; + + Gps(const std::uint8_t port, double xInitial, double yInitial, double headingInitial, double xOffset, double yOffset) + : _port(port) { + pros::c::gps_initialize_full(port, xInitial, yInitial, headingInitial, xOffset, yOffset); + }; + + /** + * Set the GPS's offset relative to the center of turning in meters, + * as well as its initial position. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param xOffset + * Cartesian 4-Quadrant X offset from center of turning (meters) + * \param yOffset + * Cartesian 4-Quadrant Y offset from center of turning (meters) + * \param xInitial + * Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters) + * \param yInitial + * Initial 4-Quadrant Y Position, with (0,0) being at the center of the field (meters) + * \param headingInitial + * Heading with 0 being north on the field, in degrees [0,360) going clockwise + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t initialize_full(double xInitial, double yInitial, double headingInitial, double xOffset, + double yOffset) const; + + /** + * Set the GPS's offset relative to the center of turning in meters. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param xOffset + * Cartesian 4-Quadrant X offset from center of turning (meters) + * \param yOffset + * Cartesian 4-Quadrant Y offset from center of turning (meters) + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_offset(double xOffset, double yOffset) const; + + /** + * Get the GPS's location relative to the center of turning/origin in meters. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param xOffset + * Pointer to cartesian 4-Quadrant X offset from center of turning (meters) + * \param yOffset + * Pointer to cartesian 4-Quadrant Y offset from center of turning (meters) + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t get_offset(double* xOffset, double* yOffset) const; + + /** + * Sets the robot's location relative to the center of the field in meters. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param xInitial + * Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters) + * \param yInitial + * Initial 4-Quadrant Y Position, with (0,0) being at the center of the field (meters) + * \param headingInitial + * Heading with 0 being north on the field, in degrees [0,360) going clockwise + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_position(double xInitial, double yInitial, double headingInitial) const; + + /** + * Set the GPS sensor's data rate in milliseconds, only applies to IMU on GPS. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param rate + * Data rate in milliseconds (Minimum: 5 ms) + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t set_data_rate(std::uint32_t rate) const; + + /** + * Get the possible RMS (Root Mean Squared) error in meters for GPS position. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \return Possible RMS (Root Mean Squared) error in meters for GPS position. + * If the operation failed, returns PROS_ERR_F and errno is set. + */ + virtual double get_error() const; + + /** + * Gets the position and roll, yaw, and pitch of the GPS. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * + * \return A struct (gps_status_s_t) containing values mentioned above. + * If the operation failed, all the structure's members are filled with + * PROS_ERR_F and errno is set. + */ + virtual pros::c::gps_status_s_t get_status() const; + + /** + * Get the heading in [0,360) degree values. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * + * \return The heading in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_heading() const; + + /** + * Get the heading in the max double value and min double value scale. + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \return The heading in [DOUBLE_MIN, DOUBLE_MAX] values. If the operation + * fails, returns PROS_ERR_F and errno is set. + */ + virtual double get_heading_raw() const; + + /** + * Gets the GPS sensor's elapsed rotation 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \return The elased heading in degrees. If the operation fails, returns + * PROS_ERR_F and errno is set. + */ + virtual double get_rotation() const; + + /** + * Set the GPS sensor's rotation value 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \param target + * Target rotation value to set rotation value to + * \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; + + /** + * Tare the GPS sensor's rotation 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + virtual std::int32_t tare_rotation() const; + + /** + * Get the GPS's raw gyroscope values + * + * 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 a GPS + * EAGAIN - The sensor is still calibrating + * + * \return The raw gyroscope values. If the operation failed, all the + * structure's members are filled with PROS_ERR_F and errno is set. + */ + virtual pros::c::gps_gyro_s_t get_gyro_rate() const; + + /** + * Get the GPS's raw accelerometer values + * + * 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 GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS's port number from 1-21 + * \return The raw accelerometer values. If the operation failed, all the + * structure's members are filled with PROS_ERR_F and errno is set. + */ + virtual pros::c::gps_accel_s_t get_accel() const; + +}; // Gps Class + +using GPS = Gps; + +} // namespace pros +#endif diff --git a/src/devices/vdml_gps.c b/src/devices/vdml_gps.c new file mode 100644 index 000000000..fafc0e184 --- /dev/null +++ b/src/devices/vdml_gps.c @@ -0,0 +1,146 @@ +/** + * \file devices/vdml_gps.c + * + * Contains functions for interacting with the VEX GPS. + * + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include "pros/gps.h" +#include "v5_api.h" +#include "vdml/registry.h" +#include "vdml/vdml.h" + +#define GPS_MINIMUM_DATA_RATE 5 + +#define GPS_STATUS_ERR_INIT \ + { .x = PROS_ERR_F, .y = PROS_ERR_F, .roll = PROS_ERR_F, .pitch = PROS_ERR_F, .yaw = PROS_ERR_F } + +#define GPS_RAW_ERR_INIT \ + { .x = PROS_ERR_F, .y = PROS_ERR_F, .z = PROS_ERR_F } + +int32_t gps_initialize_full(uint8_t port, double xInitial, double yInitial, double headingInitial, double xOffset, + double yOffset) { + claim_port_i(port - 1, E_DEVICE_GPS); + vexDeviceGpsOriginSet(device->device_info, xOffset, yOffset); + vexDeviceGpsInitialPositionSet(device->device_info, xInitial, yInitial, headingInitial); + return_port(port - 1, 1); +} + +int32_t gps_set_offset(uint8_t port, double xOffset, double yOffset) { + claim_port_i(port - 1, E_DEVICE_GPS); + vexDeviceGpsOriginSet(device->device_info, xOffset, yOffset); + return_port(port - 1, 1); +} + +int32_t gps_get_offset(uint8_t port, double* xOffset, double* yOffset) { + claim_port_i(port - 1, E_DEVICE_GPS); + vexDeviceGpsOriginGet(device->device_info, xOffset, yOffset); + return_port(port - 1, 1); +} + +int32_t gps_set_position(uint8_t port, double xInitial, double yInitial, double headingInitial) { + claim_port_i(port - 1, E_DEVICE_GPS); + vexDeviceGpsInitialPositionSet(device->device_info, xInitial, yInitial, headingInitial); + return_port(port - 1, 1); +} + +int32_t gps_set_data_rate(uint8_t port, uint32_t rate) { + claim_port_i(port - 1, E_DEVICE_GPS); + + // rate is not less than 5ms, and rounded down to nearest increment of 5 + if (rate < GPS_MINIMUM_DATA_RATE) { + rate = GPS_MINIMUM_DATA_RATE; + } else { + rate -= rate % GPS_MINIMUM_DATA_RATE; + } + + vexDeviceGpsDataRateSet(device->device_info, rate); + return_port(port - 1, 1); +} + +double gps_get_error(uint8_t port) { + claim_port_f(port - 1, E_DEVICE_GPS); + double rtv = vexDeviceGpsErrorGet(device->device_info); + return_port(port - 1, rtv); +} + +gps_status_s_t gps_get_status(uint8_t port) { + gps_status_s_t rtv = GPS_STATUS_ERR_INIT; + if (!claim_port_try(port - 1, E_DEVICE_GPS)) { + return rtv; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + V5_DeviceGpsAttitude data; + vexDeviceGpsAttitudeGet(device->device_info, &data, false); + rtv.x = data.position_x; + rtv.y = data.position_y; + rtv.pitch = data.pitch; + rtv.roll = data.roll; + rtv.yaw = data.yaw; + return_port(port - 1, rtv); +} + +double gps_get_heading(uint8_t port) { + claim_port_f(port - 1, E_DEVICE_GPS); + double rtv = vexDeviceGpsDegreesGet(device->device_info); + return_port(port - 1, rtv); +} + +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); +} + +double gps_get_rotation(uint8_t port) { + claim_port_f(port - 1, E_DEVICE_GPS); + double rtv = vexDeviceGpsRotationGet(device->device_info); + return_port(port - 1, rtv); +} + +int32_t gps_set_rotation(uint8_t port, double target) { + claim_port_i(port - 1, E_DEVICE_GPS); + vexDeviceGpsRotationSet(device->device_info, target); + return_port(port - 1, 1); +} + +int32_t gps_tare_rotation(uint8_t port) { + claim_port_i(port - 1, E_DEVICE_GPS); + vexDeviceGpsRotationSet(device->device_info, 0); + return_port(port - 1, 1); +} + +gps_gyro_s_t gps_get_gyro_rate(uint8_t port) { + gps_gyro_s_t rtv = GPS_RAW_ERR_INIT; + if (!claim_port_try(port - 1, E_DEVICE_GPS)) { + return rtv; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + V5_DeviceGpsRaw data; + vexDeviceGpsRawGyroGet(device->device_info, &data); + rtv.x = data.x; + rtv.y = data.y; + rtv.z = data.z; + return_port(port - 1, rtv); +} + +gps_accel_s_t gps_get_accel(uint8_t port) { + gps_accel_s_t rtv = GPS_RAW_ERR_INIT; + if (!claim_port_try(port - 1, E_DEVICE_GPS)) { + return rtv; + } + v5_smart_device_s_t* device = registry_get_device(port - 1); + V5_DeviceGpsRaw data; + vexDeviceGpsRawAccelGet(device->device_info, &data); + rtv.x = data.x; + rtv.y = data.y; + rtv.z = data.z; + return_port(port - 1, rtv); +} diff --git a/src/devices/vdml_gps.cpp b/src/devices/vdml_gps.cpp new file mode 100644 index 000000000..5410efd8b --- /dev/null +++ b/src/devices/vdml_gps.cpp @@ -0,0 +1,74 @@ +/** + * \file devices/vdml_gps.cpp + * + * Contains functions for interacting with the VEX GPS. + * + * Copyright (c) 2017-2021, Purdue University ACM SIGBots. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "pros/gps.hpp" + +namespace pros { + +std::int32_t Gps::initialize_full(double xInitial, double yInitial, double headingInitial, double xOffset, + double yOffset) const { + return pros::c::gps_initialize_full(_port, xInitial, yInitial, headingInitial, xOffset, yOffset); +} + +std::int32_t Gps::set_offset(double xOffset, double yOffset) const { + return pros::c::gps_set_offset(_port, xOffset, yOffset); +} + +std::int32_t Gps::get_offset(double* xOffset, double* yOffset) const { + return pros::c::gps_get_offset(_port, xOffset, yOffset); +} + +std::int32_t Gps::set_position(double xInitial, double yInitial, double headingInitial) const { + return pros::c::gps_set_position(_port, xInitial, yInitial, headingInitial); +} + +std::int32_t Gps::set_data_rate(std::uint32_t rate) const { + return pros::c::gps_set_data_rate(_port, rate); +} + +double Gps::get_error() const { + return pros::c::gps_get_error(_port); +} + +pros::c::gps_status_s_t Gps::get_status() const { + return pros::c::gps_get_status(_port); +} + +double Gps::get_heading() const { + return pros::c::gps_get_heading(_port); +} + +double Gps::get_heading_raw() const { + return pros::c::gps_get_heading_raw(_port); +} + +double Gps::get_rotation() const { + return pros::c::gps_get_rotation(_port); +} + +std::int32_t Gps::set_rotation(double target) const { + return pros::c::gps_set_rotation(_port, target); +} + +std::int32_t Gps::tare_rotation() const { + return pros::c::gps_tare_rotation(_port); +} + +pros::c::gps_gyro_s_t Gps::get_gyro_rate() const { + return pros::c::gps_get_gyro_rate(_port); +} + +pros::c::gps_accel_s_t Gps::get_accel() const { + return pros::c::gps_get_accel(_port); +} + +} // namespace pros From 51658de905cc7c1f3f2bd2973e7c8c655072b4cd Mon Sep 17 00:00:00 2001 From: Will Xu Date: Tue, 17 Aug 2021 19:31:26 -0400 Subject: [PATCH 16/16] =?UTF-8?q?=F0=9F=94=96=20Release=203.5.1:=20GPS=20S?= =?UTF-8?q?upport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index 1545d9665..d5c0c9914 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.5.0 +3.5.1