mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-07 16:28:09 +00:00
Compare commits
7 Commits
18aad6bf70
...
6fff0e1055
Author | SHA1 | Date | |
---|---|---|---|
6fff0e1055 | |||
dd7ad1b54e | |||
698fe61657 | |||
095e34ce77 | |||
07dee7bca4 | |||
a7bdd21c34 | |||
2133918eeb |
@@ -379,8 +379,8 @@ void onDataReceived (const uint8_t *mac_addr, const uint8_t *data, uint8_t data_
|
|||||||
rc_x = buf.x_axis; // Save joystic x-axis value
|
rc_x = buf.x_axis; // Save joystic x-axis value
|
||||||
rc_y = buf.y_axis; // Save joystic y-axis value
|
rc_y = buf.y_axis; // Save joystic y-axis value
|
||||||
update_pwm(rc_x, rc_y);
|
update_pwm(rc_x, rc_y);
|
||||||
mqtt_update_pwm_1(rc_x);
|
mqtt_update_pwm_1(rc_x); // Publish PWM-1 on MQTT Broker
|
||||||
mqtt_update_pwm_2(rc_y);
|
mqtt_update_pwm_2(rc_y); // Publish PWM-2 on MQTT Broker
|
||||||
}
|
}
|
||||||
|
|
||||||
void ultrasonic_task (void *arg) {
|
void ultrasonic_task (void *arg) {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#ifndef MOTOR_CONTROLS_H
|
#ifndef MOTOR_CONTROLS_H
|
||||||
#define MOTOR_CONTROLSC_H
|
#define MOTOR_CONTROLS_H
|
||||||
|
|
||||||
// Interpolate value (x) based on raw reading, min/max limits.
|
// Interpolate value (x) based on raw reading, min/max limits.
|
||||||
/*
|
/*
|
||||||
|
@@ -98,6 +98,37 @@ static void update_pwm (int rc_x, int rc_y) {
|
|||||||
if (1024 < x < 2048 && 1024 < y < 2048) {
|
if (1024 < x < 2048 && 1024 < y < 2048) {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
// Smooth update
|
||||||
|
// All forward directions
|
||||||
|
if (y >= 1500) {
|
||||||
|
m.motor1_rpm_pcm = (y - x); // Left side motors, forward
|
||||||
|
m.motor2_rpm_pcm = (y + x); // Right side motors, forward
|
||||||
|
m.motor3_rpm_pcm = 0;
|
||||||
|
m.motor4_rpm_pcm = 0;
|
||||||
|
}
|
||||||
|
// All reverse directions
|
||||||
|
if (y <= -1500) {
|
||||||
|
m.motor1_rpm_pcm = 0;
|
||||||
|
m.motor2_rpm_pcm = 0;
|
||||||
|
m.motor3_rpm_pcm = -(y - x); // Left side motors, reverse
|
||||||
|
m.motor4_rpm_pcm = -(y + x); // Right side motors, reverse
|
||||||
|
}
|
||||||
|
// ROTATIONS
|
||||||
|
// Rotate right
|
||||||
|
if ((y < 1500) && (y > 1500)) && (x > 8000) {
|
||||||
|
m.motor1_rpm_pcm = (y - x);
|
||||||
|
m.motor2_rpm_pcm = 0;
|
||||||
|
m.motor3_rpm_pcm = -(y - x);
|
||||||
|
m.motor4_rpm_pcm = 0;
|
||||||
|
}
|
||||||
|
if ((y < 1500) && (y > 1500)) && (x < 8000) {
|
||||||
|
m.motor1_rpm_pcm = 0;
|
||||||
|
m.motor2_rpm_pcm = (y + x);
|
||||||
|
m.motor3_rpm_pcm = -(y - x);
|
||||||
|
m.motor4_rpm_pcm = 0;
|
||||||
|
}
|
||||||
|
// -------------
|
||||||
|
|
||||||
// Turn Left
|
// Turn Left
|
||||||
if (x == 8190 && y == -8190) {
|
if (x == 8190 && y == -8190) {
|
||||||
m.motor1_rpm_pcm = 6172;
|
m.motor1_rpm_pcm = 6172;
|
||||||
|
Reference in New Issue
Block a user