Added comments

This commit is contained in:
2024-11-24 16:42:34 +01:00
parent 8a5b349040
commit 0bfba0bffe
4 changed files with 11 additions and 1 deletions

View File

@@ -535,6 +535,8 @@ void CKobuki::goToXy(long double xx, long double yy) {
return; return;
} }
/// @brief Makes the robot move forward for 3 seconds
/// @param speedvalue How fast it will drive forward from 0 - 1024
void CKobuki::forward(int speedvalue) { void CKobuki::forward(int speedvalue) {
// Use the goStraight logic to determine the speed and distance // Use the goStraight logic to determine the speed and distance
@@ -588,6 +590,10 @@ void CKobuki::Rotate(int degrees) {
setRotationSpeed(0); setRotationSpeed(0);
} }
/// @brief Robot safety function to be ran in another thread. Makes sure the robot does not throw inteself from the table. Only use this when the speed is lower than 350
/// @param pointerToMessage Set this pointer to the control message and then it attempts to reset it when it bumps into something so it doesnt keep trying to do the past commant
// TODO: make this return bool so it can be used in the control part
void CKobuki::robotSafety(std::string *pointerToMessage) { void CKobuki::robotSafety(std::string *pointerToMessage) {
while (true) { while (true) {
@@ -602,6 +608,7 @@ void CKobuki::robotSafety(std::string *pointerToMessage) {
} }
} }
/// @brief Robot safety function to be ran in another thread. Makes sure the robot does not throw inteself from the table. Only use this when the speed is lower than 350
void CKobuki::robotSafety() { void CKobuki::robotSafety() {
while (true) { while (true) {
@@ -614,6 +621,7 @@ void CKobuki::robotSafety() {
} }
} }
/// @brief When called the robot gets a control message to stop whatever its doing
void CKobuki::sendNullMessage() { void CKobuki::sendNullMessage() {
unsigned char message[11] = { unsigned char message[11] = {

View File

@@ -2,6 +2,7 @@
MqttClient::MqttClient(const std::string& address, const std::string& clientId, const std::string& username, const std::string& password) MqttClient::MqttClient(const std::string& address, const std::string& clientId, const std::string& username, const std::string& password)
//client_ is the connection //client_ is the connection
//here all the @PARAMS are getting set for the connection
: client_(address, clientId), username_(username), password_(password), callback_(*this) { : client_(address, clientId), username_(username), password_(password), callback_(*this) {
client_.set_callback(callback_); client_.set_callback(callback_);
options.set_clean_session(true); options.set_clean_session(true);

View File

@@ -1,5 +1,5 @@
#include "MqttClient.h" #include "MqttClient.h"
//example file for testing
int main(){ int main(){
MqttClient client("mqtt://localhost:1883", "raspberry_pi_client", "ishak", "kobuki"); MqttClient client("mqtt://localhost:1883", "raspberry_pi_client", "ishak", "kobuki");
client.connect(); client.connect();

View File

@@ -19,6 +19,7 @@ void setup()
{ {
unsigned char *null_ptr(0); unsigned char *null_ptr(0);
robot.startCommunication("/dev/ttyUSB0", true, null_ptr); robot.startCommunication("/dev/ttyUSB0", true, null_ptr);
//connect mqtt server and sub to commands
client.connect(); client.connect();
client.subscribe("home/commands"); client.subscribe("home/commands");
} }