-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combined Gyro-Mode #9
Comments
It should definitely be possible, although high-level wrappers are not implemented for that. Taking
struct gyro_combo_data {
int16_t rate;
int16_t angle;
}
|
Hi, i have written a git patch that adds this functionality. It can be applied with From 8661f81fa9bc2f2221c4ca36b62f47cee0f48e46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Van=C4=9Bk?= <vanek.jakub4@seznam.cz>
Date: Thu, 20 Feb 2020 17:22:30 +0100
Subject: [PATCH] feat(ev3api/sensors/gyro): add support for fetching
angle+rate
---
common/ev3api/src/ev3api_sensor.c | 14 ++++++++++++++
common/ev3api/src/ev3api_sensor.h | 18 ++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/common/ev3api/src/ev3api_sensor.c b/common/ev3api/src/ev3api_sensor.c
index 1cfb0eb..6495723 100644
--- a/common/ev3api/src/ev3api_sensor.c
+++ b/common/ev3api/src/ev3api_sensor.c
@@ -258,6 +258,20 @@ error_exit:
return 0;
}
+void ev3_gyro_sensor_get_angle_and_rate(sensor_port_t port, angle_rate_t *data) {
+ ER ercd;
+
+// lazy_initialize();
+ CHECK_PORT(port);
+ CHECK_COND(ev3_sensor_get_type(port) == GYRO_SENSOR, E_OBJ);
+
+ uart_sensor_fetch_data(port, GYRO_GnA, data, sizeof(angle_rate_t));
+ return;
+
+error_exit:
+ syslog(LOG_WARNING, "%s(): ercd %d", __FUNCTION__, ercd);
+}
+
ER ev3_gyro_sensor_reset(sensor_port_t port) {
ER ercd;
diff --git a/common/ev3api/src/ev3api_sensor.h b/common/ev3api/src/ev3api_sensor.h
index c31b907..7666e23 100644
--- a/common/ev3api/src/ev3api_sensor.h
+++ b/common/ev3api/src/ev3api_sensor.h
@@ -85,6 +85,15 @@ typedef struct {
uint16_t b; //!< \~English Blue value \~Japanese 青
} rgb_raw_t;
+/**
+ * \~English
+ * \brief Structure for a combined angle-rate gyro state
+ */
+typedef struct {
+ int16_t angle;
+ int16_t rate;
+} angle_rate_t;
+
/**
* \~English
* \brief Configure a sensor port.
@@ -211,6 +220,15 @@ int16_t ev3_gyro_sensor_get_angle(sensor_port_t port);
*/
int16_t ev3_gyro_sensor_get_rate(sensor_port_t port);
+/**
+ * \~English
+ * \brief Get both the angular position and the angular speed by a gyroscope sensor.
+ * \details Always returns 0 (error log is outputted) when an invalid sensor number is specified.
+ * \param port Sensor port to be inquired
+ * \param data Combined angle and rate gyroscope data.
+ */
+void ev3_gyro_sensor_get_angle_and_rate(sensor_port_t port, angle_rate_t *data);
+
/**
* \~English
* \brief Reset the angular position of a gyroscope sensor to zero.
--
2.17.1
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In EV3-G there is a mode to receive Gyro-Rate & Gyro-Angle both in the same cycle.
In ev3rt you have to choose Rate Xor Angle. If you switch it is like a Reset to the Gyro-Sensor.
Is it possible to implement a combined Gyro-Mode in ev3rt?
The text was updated successfully, but these errors were encountered: