Author SHA1 Message Date
kleiax 00c504fb12 Merge remote-tracking branch 'origin/projektarbeit' into testProjekttoBachelor but only motor things 2024-07-19 15:57:54 +02:00
kleiax f0f75d3fd3 - deactivate a debug print
- activate init screen
- update network config
2024-07-19 15:33:50 +02:00
kleiax a7930e2915 more refactor bug fixes 2023-10-13 14:17:51 +02:00
kleiax f0474027be remove CalcAzimuth 2023-10-12 20:58:30 +02:00
kleiax 12c338def1 fix merge bugs 2023-10-12 20:50:59 +02:00
kleiax e511afb2a5 Merge branch 'main' into projektarbeit 2023-10-12 20:35:31 +02:00
kleiax f78804d836 first build 2023-09-04 14:13:14 +02:00
kleiax 682a99ffea Merge branch 'main' into projektarbeit 2023-09-04 13:35:40 +02:00
kleiax d7a9e9cfd8 delete everthing for bachelore 2023-09-02 18:34:06 +02:00
kleiax fd946f2aa3 Merge branch 'main' into projektarbeit 2023-09-02 18:31:46 +02:00
kleiax 4e2b5bd347 delete old debug python files 2023-09-02 17:51:16 +02:00
34 changed files with 52 additions and 140 deletions
-7
View File
@@ -1,6 +1,5 @@
{
"files.insertFinalNewline": true,
"editor.wordWrap": "on",
"cSpell.ignoreWords": [
"ledc",
"write"
@@ -133,7 +132,6 @@
"Doxygen",
"Dutycycle",
"gast",
"gnss",
"GNSS",
"GPGGA",
"HSPI",
@@ -142,12 +140,9 @@
"kleiax",
"Lebennig",
"microcontroller",
"Mqtt",
"MQTT",
"NMEA",
"NMEAGPGGA",
"ntrip",
"Ntrip",
"NTRIP",
"pcnt",
"pidl",
@@ -155,8 +150,6 @@
"Punica",
"RHEDE",
"Rtcm",
"sapos",
"SAPOS",
"Schalke",
"Soln",
"Systeminformation",
-5
View File
@@ -1,5 +0,0 @@
# Autonomer Rover
Testfahrt auf Youtube: https://youtu.be/GigIyo-vghE?si=jhProl1DQFUrcz7w
# Beschreibung
Vollständige Softwarelösung und Hardwareerweiterungen für einen Rover mit Skid-Antrieb. Das System wurde in C++ geschrieben und es wurden erweiterte Konzepte der Objektorientierung wie Polymorphie eingesetzt. Die Datenhaltung wurde erfolgreich von der Logik getrennt, hierfür wurde unter anderem eine API mit Express.js implementiert. Hardwareseitig wurde PWM für die Motorsteuerung, IC2 für verschiedene Sensoren und SPI für das GNSS-Modul eingesetzt. Zusätzlich wurden Encoder an den Motoren verbaut, um diese präzise zu steuern. Überdies wurde eine RTK-Referenzstation geplant und umgesetzt, dafür wurde die Antenne, ein weiteres GNSS-Modul und ein Embedded-Server installiert und konfiguriert. Durch das Zusammenspiel dieser Systeme kann der Rover Routen im niedrigen einstelligen Zentimeterbereich aufzeichnen und abfahren.
+1 -1
View File
@@ -44,7 +44,7 @@ PROJECT_NUMBER =
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF = "A small verhicle which should be drive a route with GNNS and RTK"
PROJECT_BRIEF = "A small verhicle which should be drive a route with GPS"
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 772 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

+1
View File
@@ -87,6 +87,7 @@ public:
* @param status
*/
void setDrivingStatus(Status status);
Status getDrivingStatus() const { return this->driving_status; }
/**
* @brief Stops the engine immediately
+2 -19
View File
@@ -14,9 +14,7 @@
#include <stdint.h>
#define ZUHAUSE
#define SAPOS_NI
// #define RTK2GO
#define HOTSPOT
#ifdef HOTSPOT
namespace NetworkConfig
@@ -63,7 +61,7 @@ namespace NetworkConfig
{
const char ssid[] = "Tuedelkram";
const char password[] = "3!Kaesehoch";
const char ip[] = "192.168.178.13";
const char ip[] = "192.168.178.11";
const char subnet[] = "255.255.255.0";
const char gateway[] = "192.168.178.1";
const char dns[] = "8.8.8.8";
@@ -79,7 +77,6 @@ namespace MqttConfig
const char password[] = "p?{$_~5%hBM7wrcFkr55KWr#";
}
#ifdef RTK2GO
namespace NtripConfig
{
const char host[] = "rtk2go.com";
@@ -89,18 +86,4 @@ namespace NtripConfig
// const char mountPoint[] = "Rtkramerntrip";
const char user[] = "alklein1@gmx.de";
const char password[] = "none";
const bool sendOwnPosition = false;
}
#endif // RTK2GO
#ifdef SAPOS_NI
namespace NtripConfig
{
const char host[] = "sapos-ni-ntrip.de";
const uint16_t port = 2101;
const char mountPoint[] = "VRS_3_4G_NI";
const char user[] = "ni_FHDo01";
const char password[] = "ALdx-1-3e49";
const bool sendOwnPosition = true;
}
#endif // RTK2GO
+5 -27
View File
@@ -33,6 +33,7 @@ void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8
ledcSetup(this->pwmChannel, MotorControl::pwmFreq, MotorControl::pwmRes);
ledcAttachPin(this->pwmPin, this->pwmChannel);
ledcWrite(this->pwmChannel, 0);
std::cout << "Init pwm" << std::endl;
}
void MotorControl::run()
@@ -56,7 +57,7 @@ void MotorControl::run()
return;
}
// Positive or negative tagret speed
// Positive or negative target speed
if (this->targetPower >= 0)
{
// Positive or negative speed
@@ -97,28 +98,6 @@ void MotorControl::run()
}
}
void MotorControl::setMinPwm(uint8_t min)
{
if (min > MotorControl::maxPwmMin)
{
min = MotorControl::maxPwmMin;
}
// transform percentage to real pwm value
min = static_cast<uint8_t>(((static_cast<uint8_t>(1) << pwmRes) - 1) * (min / 100.0));
this->dutycycleMin = min;
}
void MotorControl::setMaxPwm(uint8_t max)
{
if (max > 100)
{
max = 100;
}
// transform percentage to real pwm value
max = static_cast<uint8_t>(((static_cast<uint8_t>(1) << pwmRes) - 1) * (max / 100.0));
this->dutycycleMax = max;
}
void MotorControl::setTargetPower(int8_t power)
{
if (power <= 100 && power >= -100)
@@ -158,7 +137,6 @@ bool MotorControl::isAccelerationNegative() const
void MotorControl::setRealPower(int8_t power)
{
// TODO: Exceptionhandling
if (power <= 100 && power >= -100)
{
this->power = power;
@@ -175,10 +153,11 @@ void MotorControl::setRealPower(int8_t power)
digitalWrite(this->dir_2, LOW);
ledcWrite(this->pwmChannel, 0);
this->dutycycle = 0;
// std::cout << "abort" << std::endl;
return;
}
const uint8_t pwm_val = map(abs(power), 0, 100, this->dutycycleMin, this->dutycycleMax);
const uint8_t pwm_val = map(abs(power), 0, 100, MotorControl::minPwmVal, MotorControl::maxPwmVal);
if ((this->direction == 1 || this->direction == 0) && power < 0)
{ // new direction backward
@@ -193,6 +172,7 @@ void MotorControl::setRealPower(int8_t power)
digitalWrite(this->dir_2, LOW);
}
std::cout << "MotorControl::setRealPower pwm_val: " << (int) pwm_val << " channel:" << (int) this->pwmChannel << std::endl;
ledcWrite(this->pwmChannel, pwm_val);
std::cout << "MotorControl::serRealPower - pwm: " << static_cast<int>(pwm_val) << std::endl;
this->dutycycle = pwm_val;
@@ -200,8 +180,6 @@ void MotorControl::setRealPower(int8_t power)
void MotorControl::increasePower(int8_t power)
{
// TODO: Exceptionhandling
// TODO: make a stop befor a direction change
if (abs(power) > 2 * MotorControl::powerSteps)
{
Serial.println("Invalid Argument in MotorControl::increasePower");
+2 -16
View File
@@ -38,20 +38,6 @@ public:
*/
void init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2);
/**
* @brief Set the minimum duty cycle
*
* @param min duty cycle in percent
*/
void setMinPwm(uint8_t min);
/**
* @brief Set the maximum duty cycle
*
* @param max duty cycle in percent
*/
void setMaxPwm(uint8_t max);
/**
* @brief Set the Target Power
*
@@ -103,6 +89,8 @@ private:
static constexpr uint8_t pwmRes = 8;
static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms
static constexpr uint8_t maxPwmMin = 80;
static constexpr uint8_t maxPwmVal = 250;
static constexpr uint8_t minPwmVal = 55; // Max 98% of 2^PWM_RES
int8_t targetPower = 0;
int8_t power = 0;
@@ -111,8 +99,6 @@ private:
uint8_t pwmPin = 0;
uint8_t pwmChannel = 0;
uint16_t dutycycle = 0;
uint8_t dutycycleMin = 55;
uint8_t dutycycleMax = 98; // Max 98% of 2^PWM_RES
uint8_t dir_1 = 0;
uint8_t dir_2 = 0;
};
+35 -31
View File
@@ -47,7 +47,6 @@ void NTRIPClient::run()
{
std::cout << "Failed!" << std::endl;
this->state = NTRIPClientStates::waiting;
this->lastReconnectTime = millis();
this->activated = false;
}
break;
@@ -98,7 +97,7 @@ void NTRIPClient::gnssConfiguration()
// Set the differential mode - ambiguities are fixed whenever possible
this->gnss->setDGNSSConfiguration(SFE_UBLOX_DGNSS_MODE_FIXED);
this->gnss->setMainTalkerID(SFE_UBLOX_MAIN_TALKER_ID_GP);
this->gnss->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI);
this->gnss->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10);
}
bool NTRIPClient::setActivated(bool state)
@@ -154,7 +153,11 @@ bool NTRIPClient::beginClient()
{
snprintf(static_cast<char *>(serverRequest),
this->bufferSize,
static_cast<const char *>("GET /%s HTTP/1.0\r\nHost: %s:%u\r\nUser-Agent: NTRIP KleiaxNtripClient/0.1\r\nAccept: */*\r\nConnection: close\r\n"),
static_cast<const char *>("GET /%s HTTP/1.0\r\n\
Host: %s:%u\r\n\
User-Agent: NTRIP KleiaxNtripClient/0.1\r\n\
Accept: */*\r\n\
Connection: close\r\n"),
this->mountPoint,
this->host,
this->port);
@@ -163,7 +166,12 @@ bool NTRIPClient::beginClient()
{
snprintf(static_cast<char *>(serverRequest),
this->bufferSize,
static_cast<const char *>("GET /%s HTTP/1.1\r\nHost: %s:%u\r\nNtrip-Version: Ntrip/2.0\r\nUser-Agent: NTRIP KleiaxNtripClient/0.1\r\nAccept: */*\r\nConnection: close\r\n"),
static_cast<const char *>("GET /%s HTTP/1.1\r\n\
Host: %s:%u\r\n\
Ntrip-Version: Ntrip/2.0\r\n\
User-Agent: NTRIP KleiaxNtripClient/0.1\r\n\
Accept: */*\r\n\
Connection: close\r\n"),
this->mountPoint,
this->host,
this->port);
@@ -172,7 +180,6 @@ bool NTRIPClient::beginClient()
// Add own Position if activated
if (this->transmitLocation && !this->useNtripRev1)
{
std::cout << "NTRIPClient::beginClient - Add own position to server request." << std::endl;
auto *data = new NMEA_GGA_data_t;
const uint8_t res = this->gnss->getLatestNMEAGPGGA(data);
if (res > 0) // valid data
@@ -180,14 +187,10 @@ bool NTRIPClient::beginClient()
char positionUpdate[this->bufferSizePushGPGGA];
snprintf(static_cast<char *>(positionUpdate),
this->bufferSizePushGPGGA,
static_cast<const char *>("Ntrip-GGA: %s"),
static_cast<const char *>("Ntrip-GGA: %s\r\n"),
data->nmea);
strncat(static_cast<char *>(serverRequest), static_cast<const char *>(positionUpdate), this->bufferSize);
}
else
{
std::cout << "NTRIPClient::beginClient - No valid data to send position to caster." << std::endl;
}
delete data;
this->lastGPGGAPushTime = millis();
@@ -195,24 +198,24 @@ bool NTRIPClient::beginClient()
if (this->user && this->password)
{
// Credentials
const uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2;
auto *userCredentials = new char[userCredentialsLength];
snprintf(static_cast<char *>(userCredentials), userCredentialsLength, static_cast<const char *>("%s:%s"), this->user, this->password);
// Credentials
const uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2;
auto *userCredentials = new char[userCredentialsLength];
snprintf(static_cast<char *>(userCredentials), userCredentialsLength, static_cast<const char *>("%s:%s"), this->user, this->password);
std::cout << "Sending credentials: " << userCredentials << std::endl;
std::cout << "Sending credentials: " << userCredentials << std::endl;
// Encode
const base64 base;
const String strEncodedCredentials = base64::encode(userCredentials);
delete userCredentials;
char encodedCredentials[strEncodedCredentials.length() + 1];
strEncodedCredentials.toCharArray(static_cast<char *>(encodedCredentials), sizeof(encodedCredentials));
// Encode
const base64 base;
const String strEncodedCredentials = base64::encode(userCredentials);
delete userCredentials;
char encodedCredentials[strEncodedCredentials.length() + 1];
strEncodedCredentials.toCharArray(static_cast<char *>(encodedCredentials), sizeof(encodedCredentials));
snprintf(credentials, sizeof(credentials), static_cast<const char *>("Authorization: Basic %s\r\n"), static_cast<const char *>(encodedCredentials));
snprintf(credentials, sizeof(credentials), static_cast<const char *>("Authorization: Basic %s\r\n"), static_cast<const char *>(encodedCredentials));
// Add the encoded credentials to the server request
strncat(static_cast<char *>(serverRequest), static_cast<const char *>(credentials), this->bufferSize);
// Add the encoded credentials to the server request
strncat(static_cast<char *>(serverRequest), static_cast<const char *>(credentials), this->bufferSize);
}
strncat(static_cast<char *>(serverRequest), static_cast<const char *>("\r\n"), this->bufferSize);
@@ -364,7 +367,7 @@ void NTRIPClient::checkAutoReconnect()
void NTRIPClient::pushGPGGA()
{
if ((!this->transmitLocation || !this->activated) || !this->ntripClient->connected())
if (!this->transmitLocation && !this->activated)
{
return;
}
@@ -375,22 +378,23 @@ void NTRIPClient::pushGPGGA()
}
this->lastGPGGAPushTime = millis();
if (!this->ntripClient->connected())
{
std::cout << "Failed to pushing GGA to server: " << std::endl;
}
auto *data = new NMEA_GGA_data_t;
const uint8_t res = this->gnss->getLatestNMEAGPGGA(data);
if (res > 0) // 2 means fresh data
if (res == 2) // 2 means fresh data
{
char positionUpdate[this->bufferSizePushGPGGA];
snprintf(static_cast<char *>(positionUpdate),
this->bufferSizePushGPGGA,
static_cast<const char *>("%s"),
static_cast<const char *>("%s\r\n"),
data->nmea);
this->ntripClient->write(positionUpdate, strlen(positionUpdate));
std::cout << "Position update: " << positionUpdate << std::endl;
}
else
{
std::cout << "NTRIPClient::pushGPGGA - No valid data to send position to caster." << std::endl;
}
delete data;
}
+1 -1
View File
@@ -130,7 +130,7 @@ private:
const uint16_t timeOut = 10000;
const uint16_t bufferSize = 512;
const uint16_t bufferSizePushGPGGA = 128;
const uint16_t pushGPGGATime = 5000;
const uint16_t pushGPGGATime = 10000;
static constexpr uint8_t loopDelay = 20;
};
+2 -3
View File
@@ -25,12 +25,11 @@ SensorData::~SensorData()
delete this->ntripClient;
}
void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password, bool sendOwnPosition)
void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password)
{
this->ntripClient = new NTRIPClient(this->gnss, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str());
this->ntripClient->gnssConfiguration();
this->ntripClient->loop();
this->ntripClient->setTransmitLocation(sendOwnPosition);
this->ntripClient->setActivated(false);
this->isNtripInit = true;
this->addChildComponent(this->ntripClient);
@@ -265,7 +264,7 @@ void SensorData::initGnss()
std::cout << "u-blox protocol version: " << static_cast<int>(versionHigh) << "." << static_cast<int>(versionLow) << std::endl;
this->gnss->setSPIOutput(COM_TYPE_UBX);
this->gnss->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI);
this->gnss->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10);
this->gnss->setUSBOutput(COM_TYPE_UBX | COM_TYPE_NMEA);
this->gnss->setAutoPVTcallbackPtr(&(SensorData::savePVTdata));
// SensorData::setOutputStatusPrintPVTdata(true);
+1 -1
View File
@@ -38,7 +38,7 @@ public:
SensorData();
~SensorData();
void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password, bool sendOwnPosition = false);
void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password);
/**
* @brief Enable the gnss module over spi
@@ -150,28 +150,3 @@ void MenuSensorData::printPage() const
this->print(lineOne, lineTwo);
}
void MenuSensorData::runCommand()
{
switch (this->getCurrentPage())
{
case 5:
{
NTRIPClient* client = this->sensorData->getNtripClient();
NTRIPClientStates state = client->getClientState();
if (state == NTRIPClientStates::pushingData)
{
client->deactivate();
}
else if (state == NTRIPClientStates::waiting)
{
client->activate();
}
}
break;
default:
break;
}
}
@@ -30,7 +30,6 @@ public:
private:
void printPage() const override;
void runCommand() override;
SensorData *sensorData;
};
@@ -47,7 +47,7 @@ void ManualControl::analogControl()
void ManualControl::digitalControl()
{
static constexpr uint8_t deadzone = 120;
static constexpr uint8_t deadzone = 110;
const int16_t yAxis = this->input->x - 127;
const int16_t xAxis = this->input->y - 127;
+1 -2
View File
@@ -129,8 +129,7 @@ void setup()
NtripConfig::port,
static_cast<const char *>(NtripConfig::mountPoint),
static_cast<const char *>(NtripConfig::user),
static_cast<const char *>(NtripConfig::password),
NtripConfig::sendOwnPosition);
static_cast<const char *>(NtripConfig::password));
sensorData->enableGyroscope();
driveManager = new DriveManager(&moveController, sensorData, controlPad->getControlPadDataPtr());