Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
c3a3b53
Merge branch 'navigation/dev' into navx/dev
argvrutter Feb 20, 2018
596c15f
merge navigation/dev into navx/dev
argvrutter Feb 20, 2018
393c746
Merge branch 'navigation/dev' into navx/dev
argvrutter Feb 20, 2018
0493e13
cppfs change
argvrutter Feb 20, 2018
a1f46a3
Merge branch 'navigation/dev' into navx/dev-integration1
argvrutter Feb 21, 2018
c633b93
[some large lines] -> [more],[small],[lines]
argvrutter Feb 22, 2018
5c60a10
turn to angle starts, navx and relative version
argvrutter Feb 22, 2018
122a072
minor doc & loggin
argvrutter Feb 22, 2018
5b47db8
added static makeNavX function
argvrutter Feb 22, 2018
78d7973
Merge branch 'navx/dev' into navigation/integr8
argvrutter Feb 22, 2018
923c98e
add encoder abstraction to drivetrain.hpp
argvrutter Feb 25, 2018
7c15d4b
added one roboclaw drive train
argvrutter Feb 25, 2018
594d734
added drive arc, among other things. compiles.
argvrutter Feb 26, 2018
f481336
drive arc can be tested now; resolving some warnings
argvrutter Feb 26, 2018
68bd45e
Merge branch 'dev' into navigation/dev
argvrutter Feb 26, 2018
e0b3d58
Merge branch 'dev' of github.com:utk-robotics-2017/rip into navigatio…
argvrutter Feb 26, 2018
8177429
makes navx a subsystem
argvrutter Feb 27, 2018
c6edea5
hotfix, fix navx getAngle
argvrutter Feb 28, 2018
8e1369e
changes to make turn action work
argvrutter Feb 28, 2018
11893c3
Merge branch 'navigation/dev' of github.com:utk-robotics-2017/rip int…
argvrutter Feb 28, 2018
1c8225e
Fix DriveArc contructor args
robobenklein Feb 28, 2018
875086c
Annddd the include
robobenklein Feb 28, 2018
3df2526
Merge remote-tracking branch 'origin/dev' into navigation/dev
robobenklein Feb 28, 2018
4d06d2f
Fix missing space in cxx flags
robobenklein Feb 28, 2018
849b010
cmake fixes, was having gcov linking issues on blu
argvrutter Feb 28, 2018
a9ec977
Merge branch 'navigation/dev' of github.com:utk-robotics-2017/rip int…
argvrutter Feb 28, 2018
021b977
debugging statements
argvrutter Feb 28, 2018
580baa2
continuous angle tracker forgets crossings on zeroYaw
argvrutter Feb 28, 2018
ab74454
Merge branch 'navigation/dev' of github.com:utk-robotics-2017/rip int…
argvrutter Feb 28, 2018
194c542
fixes
argvrutter Mar 1, 2018
28ddf9c
Merge branch 'navigation/dev' of github.com:utk-robotics-2017/rip int…
argvrutter Mar 1, 2018
0341391
some changes for hugo, sloppy does trick for now
argvrutter Mar 2, 2018
a9e663a
arc turn works
argvrutter Mar 2, 2018
12de229
minor changes suggested on PR'
argvrutter Mar 4, 2018
c44eeef
changes to drivearc, turntoangle
argvrutter Mar 4, 2018
e4de555
changes to turn to angle. should work now
argvrutter Mar 5, 2018
97242b5
camelCase vars -> snake_case
argvrutter Mar 5, 2018
5df6f97
simple json state storage + path correction
argvrutter Mar 7, 2018
895309b
dealt with zombie code
argvrutter Mar 8, 2018
aa3c83d
get appendages ready for dominate
Mar 9, 2018
9e58ae1
roboclaw reset added
argvrutter Mar 13, 2018
6f295aa
fix to parity
argvrutter Mar 14, 2018
c467e58
broken commit fix
argvrutter Mar 14, 2018
c2b1835
fixing merge
argvrutter Mar 14, 2018
56febf5
testing fix
argvrutter Mar 14, 2018
b6975e0
Minor fixes
argvrutter Mar 18, 2018
5bab4f4
fix
argvrutter Mar 18, 2018
9bf6073
testing quick fix for serial
jptech Mar 18, 2018
02c22d0
Merge branch 'robo/docker-cross-compile' of github.com:utk-robotics-2…
jptech Mar 18, 2018
639373f
more messing around with roboclaw
jptech Mar 18, 2018
3fad0dd
Added roboclaw xml and json
xxAtrain223 Mar 19, 2018
c8b5b0b
beginning of localization
Mar 20, 2018
cd4ae31
Added Roboclaw Header and Source
xxAtrain223 Mar 20, 2018
304470f
Enable build_rip_rpi
robobenklein Mar 20, 2018
c18640c
Merge remote-tracking branch 'origin/navigation/dev' into robo/integr…
robobenklein Mar 20, 2018
95738e5
Fix incomplete vtable in Roboclaw appendage
robobenklein Mar 25, 2018
26a118a
Add platformio to rip_deps for arduinogen
robobenklein Mar 25, 2018
d294177
Refactor go-docker +build_rip_rpi
robobenklein Mar 25, 2018
7282ff0
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 25, 2018
b5c1fd7
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 25, 2018
c619d0d
Fix open case
robobenklein Mar 25, 2018
3e9196c
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 25, 2018
1b7f380
Added check if code_template.txt exists.
xxAtrain223 Mar 25, 2018
111357a
Merge remote-tracking branch 'origin/arduino_gen/dev' into robo/integ…
robobenklein Mar 25, 2018
c908db7
Build separate dirs for armhf
robobenklein Mar 25, 2018
689c239
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 25, 2018
e9bc6b6
Be more explicit in deps
robobenklein Mar 25, 2018
54d7d21
Update before install again
robobenklein Mar 25, 2018
7a0885d
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 25, 2018
5d9c802
Added checks for directory and file creation.
xxAtrain223 Mar 25, 2018
1b8eb30
Merge remote-tracking branch 'origin/arduino_gen/dev' into robo/integ…
robobenklein Mar 26, 2018
11c230a
Add -p to non-testing version
robobenklein Mar 26, 2018
f7e560e
added a diag function
argvrutter Mar 26, 2018
102e230
WIP fixes for spine & diag
robobenklein Mar 27, 2018
31d5089
Working on spine fixes still
robobenklein Mar 27, 2018
1ed0d03
Perhaps we need to merge some exceptions
robobenklein Mar 27, 2018
69c8e5b
Working on Appendage Factory fixes
robobenklein Mar 27, 2018
74c6a0d
Words
robobenklein Mar 27, 2018
3c1e689
Need to figure arduino_gen to fix this
robobenklein Mar 27, 2018
80bfc19
Changing permissions settings in arduinogen
robobenklein Mar 27, 2018
ebb3759
Diag roboclaw fix logging
robobenklein Mar 27, 2018
c44096e
Fix rest of AG unit tests
robobenklein Mar 27, 2018
ade2ab4
Copy Ultrasonic and Servo
robobenklein Mar 27, 2018
1a2b2c6
Factory: check that appendage is available
robobenklein Mar 27, 2018
a4552d5
Ultrasonic diag
robobenklein Mar 27, 2018
5b5c638
Added core field to appendages
xxAtrain223 Mar 27, 2018
2508d7f
Merge branch 'arduino_gen/dev' into appendages/roboclaw
xxAtrain223 Mar 27, 2018
ff1271d
Added core field address to roboclaw
xxAtrain223 Mar 27, 2018
3494103
Merge remote-tracking branch 'origin/appendages/roboclaw' into robo/i…
robobenklein Mar 27, 2018
66309a8
pose
Mar 27, 2018
40bdeef
Changed the appendage cache to use a map of strings, json objects.
xxAtrain223 Mar 28, 2018
bf76f68
Merge remote-tracking branch 'origin/appendages/roboclaw' into robo/i…
robobenklein Mar 28, 2018
a1cf671
Arduino code is now crashing...
robobenklein Mar 28, 2018
f44b66a
set max response length
Mar 28, 2018
d7eb99e
Fix arduinogen tests
robobenklein Mar 28, 2018
fbddfda
Update docker things with stretch support
robobenklein Mar 29, 2018
04d653c
Ascii commandID headers support
robobenklein Mar 29, 2018
5edf146
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 29, 2018
8545293
Ping now pongs
Mar 29, 2018
f6bc66a
AG: perms, CM: kError case
robobenklein Mar 29, 2018
e7c18a2
Logger reasons
robobenklein Mar 29, 2018
9250ca7
Fixed a lot of issues
robobenklein Mar 29, 2018
422b947
Working on stretch support in build
robobenklein Mar 29, 2018
08b9390
Moving apt-key recv
robobenklein Mar 30, 2018
8570c04
Stretch builds should soon be the default?
Mar 30, 2018
7427d5d
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 30, 2018
e5b6ac6
Fix gcc 6.3 arm notes for JSON by adding compile flag
jptech Mar 30, 2018
3049f15
Add an option for image tag
robobenklein Mar 30, 2018
c9c37d2
Cleaning up the logging and couts
robobenklein Mar 30, 2018
db8ffc6
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 30, 2018
a19deae
Missed a shift
robobenklein Mar 30, 2018
74df81a
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 30, 2018
cbf8633
reload conf when changed
robobenklein Mar 30, 2018
6d96dc8
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Mar 30, 2018
c242112
Gosh darn envvars
robobenklein Mar 30, 2018
5059aa1
Gosh darn envvars
robobenklein Mar 30, 2018
9d5cdb2
Force enums to 16-bit
robobenklein Mar 30, 2018
ae109ae
Working on bad ultrasonic reads
robobenklein Mar 31, 2018
85aa538
Add initialValue to servo init
robobenklein Apr 3, 2018
c8f3adf
Make servos setup for .5s then detach
robobenklein Apr 3, 2018
86ab615
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Apr 3, 2018
a5bd132
Adding docs
robobenklein Apr 3, 2018
7162ffc
Merge branch 'robo/integration-39' into robo/docker-go-script
robobenklein Apr 3, 2018
156a412
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Apr 3, 2018
856488f
*case options
robobenklein Apr 6, 2018
173c741
Merge remote-tracking branch 'origin/robo/docker-go-script' into robo…
robobenklein Apr 6, 2018
6d5a355
path follower
Apr 7, 2018
c42f0dd
Use ping_median for US
robobenklein Apr 7, 2018
2fc19f9
gui
Apr 8, 2018
023b442
gui lines and arcs
Apr 9, 2018
54f7604
now in units
Apr 9, 2018
ea16fd6
Merge branch 'navigation/localization' of github.com:utk-robotics-201…
Apr 9, 2018
5634d38
Merge branch 'robo/integration-39' of github.com:utk-robotics-2017/ri…
Apr 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Thumbs.db
*.pyc

build/
build_armhf/
doc/
.idea/
cmake-build-debug/
Expand Down
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ endif()
# to correctly compile the codebase despite this line being in the
# downstream CMake files.
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")

option(GCC_DIAG_COLORS "Enable GCC Diagnostic Colors" ON)
if (GCC_DIAG_COLORS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()

LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)

Expand Down
10 changes: 6 additions & 4 deletions appendages/include/appendages/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* \$$ $$ | $$ | $$ \$$\ | $$ | $$| $$ \| $$
* \$$$$$$ \$$ \$$ \$$ \$$ \$$ \$$$$$$ \$$
*/
#ifndef EXCEPTIONS_HPP
#define EXCEPTIONS_HPP
#ifndef APPENDAGES_EXCEPTIONS_HPP
#define APPENDAGES_EXCEPTIONS_HPP
#include <misc/exception_base.hpp>

namespace rip
Expand All @@ -28,7 +28,9 @@ namespace rip
NEW_EX(CommandNotFound)
NEW_EX(AppendageWithoutType)
NEW_EX(AppendageWithoutLabel)
NEW_EX(AppendageWithId)
NEW_EX(AppendageWithoutId)
NEW_EX(AppendageMissingField)
NEW_EX(AppendageNotImplemented)
}
}
#endif // EXCEPTIONS_HPP
#endif // APPENDAGES_EXCEPTIONS_HPP
68 changes: 68 additions & 0 deletions appendages/include/appendages/roboclaw.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#ifndef ROBOCLAW_HPP
#define ROBOCLAW_HPP

#include <tuple>
#include <misc/logger.hpp>
#include <fmt/format.h>
#include <cmd_messenger/command.hpp>

#include "appendages/appendage.hpp"
#include "appendages/appendage_factory.hpp"

#include <json.hpp>

namespace rip
{
namespace appendages
{
class Roboclaw : public Appendage
{
public:
void SetSpeed(int32_t speed1, int32_t speed2);
void SetSpeedAccel(int32_t accel, int32_t speed1, int32_t speed2);
std::tuple<uint32_t, uint32_t> ReadEncoders();
void SetDuty(int16_t duty1, int16_t duty2);
void SetVelocityPID(uint8_t motor, float Kp, float Ki, float Kd, uint32_t qpps);

/**
* Stop
*/
virtual void stop() override;

virtual bool diagnostic() override;

protected:
friend class AppendageFactory;

/**
* Function wrapper for the constructor so it can be pointed to
*
* @param config The config from arduino gen
* @param command_map A map of the name of the commands to their enumerations
* @param device The connection to the device
*/
static std::shared_ptr<Appendage> create(const nlohmann::json& config, const std::map<std::string, int>& command_map, std::shared_ptr<cmdmessenger::Device> device);

private:
/**
* Constructor
*
* @param config The config from arduino gen
* @param command_map A map of the name of the commands to their enumerations
* @param device The connection to the device
*/
Roboclaw(const nlohmann::json& config, const std::map<std::string, int>& command_map, std::shared_ptr<cmdmessenger::Device> device);

uint8_t m_address;

std::shared_ptr<cmdmessenger::Command> m_set_speed;
std::shared_ptr<cmdmessenger::Command> m_set_speed_accel;
std::shared_ptr<cmdmessenger::Command> m_read_encoders;
std::shared_ptr<cmdmessenger::Command> m_read_encoders_result;
std::shared_ptr<cmdmessenger::Command> m_set_duty;
std::shared_ptr<cmdmessenger::Command> m_set_velocity_pid;
};
}
}

#endif // ROBOCLAW_HPP
3 changes: 3 additions & 0 deletions appendages/include/appendages/servo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace rip
*/
void write(int value);

void attach(bool state);

/**
* Stop
*/
Expand Down Expand Up @@ -55,6 +57,7 @@ namespace rip
Servo(const nlohmann::json& config, const std::map<std::string, int>& command_map, std::shared_ptr<cmdmessenger::Device> device);

std::shared_ptr<cmdmessenger::Command> m_write;
std::shared_ptr<cmdmessenger::Command> m_attach;
};
}
}
Expand Down
8 changes: 8 additions & 0 deletions appendages/json/roboclaw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"serial": "string",
"baudrate": "int",
"address": "int",
"core": [
"address"
]
}
4 changes: 4 additions & 0 deletions appendages/json/servo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"pin": "int",
"initialValue": "int"
}
5 changes: 5 additions & 0 deletions appendages/json/ultrasonic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"triggerPin": "int",
"echoPin": "int",
"minSleepMs": "int"
}
14 changes: 11 additions & 3 deletions appendages/src/appendage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,23 @@ namespace rip

if (config.find("label") == config.end())
{
throw AppendageWithoutLabel(fmt::format("appendage missing label"));
throw AppendageWithoutLabel(fmt::format("appendage of type {} is missing label", m_type));
}
m_label = config["label"];

if (config.find("id") == config.end() && config.find("index") == config.end())
{
throw AppendageWithoutId(fmt::format("appendage labeled {} is missing an id or index", m_label));
}

if (config.find("id") == config.end())
{
throw AppendageWithId(fmt::format("appendage missing id"));
m_id = config["index"];
}
else
{
m_id = config["id"];
}
m_id = config["id"];
}
}
}
16 changes: 14 additions & 2 deletions appendages/src/appendage_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
// Appendages
#include "appendages/digital_input.hpp"
#include "appendages/analog_input.hpp"
#include "appendages/roboclaw.hpp"
#include "appendages/servo.hpp"
#include "appendages/ultrasonic.hpp"

#include "appendages/exceptions.hpp"

Expand All @@ -29,8 +32,14 @@ namespace rip
{
throw AppendageWithoutType(fmt::format("appendage missing type"));
}

return m_constructors["type"](config, command_map, device);
std::string appendage_type = config["type"];
if (m_constructors.find(appendage_type) == m_constructors.end())
{
// we probably don't have this appendage type available to the factory
throw AppendageNotImplemented(fmt::format("Factory: no Constructor for appendage type {} !", appendage_type));
}
misc::Logger::getInstance()->debug(fmt::format("Factory: Constructing an appendage of type {} ...", appendage_type));
return m_constructors[appendage_type](config, command_map, device);
}

void AppendageFactory::registerAppendage(const std::string& type, std::function<std::shared_ptr<Appendage>(const nlohmann::json&,
Expand All @@ -45,6 +54,9 @@ namespace rip
{
registerAppendage("Digital Input", &DigitalInput::create);
registerAppendage("Analog Input", &AnalogInput::create);
registerAppendage("Roboclaw", &Roboclaw::create);
registerAppendage("Servo", &Servo::create);
registerAppendage("Ultrasonic", &Ultrasonic::create);
}
}
}
183 changes: 183 additions & 0 deletions appendages/src/roboclaw.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#include "appendages/roboclaw.hpp"
#include <ctime>
#include <utility>
#include <tuple>
#include <memory>
#include <chrono>
#include <thread>
#include <cmd_messenger/cmd_messenger.hpp>

#include "appendages/exceptions.hpp"

namespace rip
{
namespace appendages
{
Roboclaw::Roboclaw(const nlohmann::json& config, const std::map<std::string, int>& command_map, std::shared_ptr<cmdmessenger::Device> device)
: Appendage(config, device),
m_set_speed(
createCommand(
"kSetSpeed",
command_map,
cmdmessenger::ArduinoCmdMessenger::makeArgumentString<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType
>()
)
),
m_set_speed_accel(
createCommand(
"kSetSpeedAccel",
command_map,
cmdmessenger::ArduinoCmdMessenger::makeArgumentString<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType
>()
)
),
m_read_encoders(
createCommand(
"kReadEncoders",
command_map,
cmdmessenger::ArduinoCmdMessenger::makeArgumentString<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType
>()
)
),
m_read_encoders_result(createCommand(
"kReadEncodersResult",
command_map,
cmdmessenger::ArduinoCmdMessenger::makeArgumentString<
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType
>()
)
),
m_set_duty(
createCommand(
"kSetDuty",
command_map,
cmdmessenger::ArduinoCmdMessenger::makeArgumentString<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::UnsignedIntegerType,
cmdmessenger::ArduinoCmdMessenger::UnsignedIntegerType>()
)
),
m_set_velocity_pid(
createCommand(
"kSetVelocityPID",
command_map,
cmdmessenger::ArduinoCmdMessenger::makeArgumentString<
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::FloatType,
cmdmessenger::ArduinoCmdMessenger::FloatType,
cmdmessenger::ArduinoCmdMessenger::FloatType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType>()
)
)
{
if (config.find("address") == config.end())
{
throw AppendageMissingField(fmt::format("Roboclaw: missing config field 'address'"));
}
m_address = config["address"];
}

std::shared_ptr<Appendage> Roboclaw::create(const nlohmann::json& config, const std::map<std::string, int>& command_map, std::shared_ptr<cmdmessenger::Device> device)
{
return std::dynamic_pointer_cast<Appendage>(std::shared_ptr<Roboclaw>(new Roboclaw(config, command_map, device)));
}

void Roboclaw::SetSpeed(int32_t speed1, int32_t speed2)
{
cmdmessenger::ArduinoCmdMessenger messenger;
messenger.send<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType
>(m_device, m_set_speed, m_id, m_address, speed1, speed2);
}

void Roboclaw::SetSpeedAccel(int32_t accel, int32_t speed1, int32_t speed2)
{
cmdmessenger::ArduinoCmdMessenger messenger;
messenger.send<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType,
cmdmessenger::ArduinoCmdMessenger::UnsignedLongType
>(m_device, m_set_speed_accel, m_id, m_address, accel, speed1, speed2);
}

std::tuple<uint32_t, uint32_t> Roboclaw::ReadEncoders()
{
cmdmessenger::ArduinoCmdMessenger messenger;
messenger.send<
cmdmessenger::ArduinoCmdMessenger::IntegerType,
cmdmessenger::ArduinoCmdMessenger::CharType
>(
m_device,
m_read_encoders,
m_id,
m_address
);
return messenger.receive<cmdmessenger::ArduinoCmdMessenger::UnsignedLongType, cmdmessenger::ArduinoCmdMessenger::UnsignedLongType>(m_read_encoders_result);
}

void Roboclaw::SetDuty(int16_t duty1, int16_t duty2)
{
cmdmessenger::ArduinoCmdMessenger messenger;
messenger.send<cmdmessenger::ArduinoCmdMessenger::CharType, cmdmessenger::ArduinoCmdMessenger::UnsignedIntegerType, cmdmessenger::ArduinoCmdMessenger::UnsignedIntegerType>(m_device, m_set_duty, m_id, m_address, duty1, duty2);
}

void Roboclaw::SetVelocityPID(uint8_t motor, float Kp, float Ki, float Kd, uint32_t qpps)
{
cmdmessenger::ArduinoCmdMessenger messenger;
messenger.send<cmdmessenger::ArduinoCmdMessenger::CharType, cmdmessenger::ArduinoCmdMessenger::CharType, cmdmessenger::ArduinoCmdMessenger::FloatType, cmdmessenger::ArduinoCmdMessenger::FloatType, cmdmessenger::ArduinoCmdMessenger::FloatType, cmdmessenger::ArduinoCmdMessenger::UnsignedLongType>(m_device, m_set_velocity_pid, m_address, motor, Kp, Ki, Kd, qpps);
}

void Roboclaw::stop() {
misc::Logger::getInstance()->debug("Setting roboclaw duty to zero.");
SetDuty(0, 0);
}

bool Roboclaw::diagnostic()
{
std::chrono::time_point<std::chrono::system_clock> start_time = std::chrono::system_clock::now();
misc::Logger::getInstance()->debug("Roboclaw appendage diagnostics start");

misc::Logger::getInstance()->debug("Read encoders for 5s in a loop");
while(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start_time).count() < 5000)
{
misc::Logger::getInstance()->debug(fmt::format("Encoder 1 Ticks: {} | Encoder 2 Ticks: {}", std::get<0>(ReadEncoders()), std::get<1>(ReadEncoders())));
}
misc::Logger::getInstance()->debug("Setting Duty to ~1/2 Power, forward for 5 seconds");
misc::Logger::getInstance()->debug(fmt::format("Encoder 1 Ticks: {} | Encoder 2 Ticks: {}", std::get<0>(ReadEncoders()), std::get<1>(ReadEncoders())));
SetDuty(16000, 16000);
start_time = std::chrono::system_clock::now();
while(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start_time).count() < 5000)
{}
misc::Logger::getInstance()->debug(fmt::format("Encoder 1 Ticks: {} | Encoder 2 Ticks: {}", std::get<0>(ReadEncoders()), std::get<1>(ReadEncoders())));
stop();
misc::Logger::getInstance()->debug("Setting speed accel drive (5s)");
misc::Logger::getInstance()->debug(fmt::format("Encoder 1 Ticks: {} | Encoder 2 Ticks: {}", std::get<0>(ReadEncoders()), std::get<1>(ReadEncoders())));
SetSpeedAccel(12000, 12000, 12000);
start_time = std::chrono::system_clock::now();
while(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start_time).count() < 5000)
{}
misc::Logger::getInstance()->debug(fmt::format("Encoder 1 Ticks: {} | Encoder 2 Ticks: {}", std::get<0>(ReadEncoders()), std::get<1>(ReadEncoders())));
stop();
misc::Logger::getInstance()->debug(fmt::format("Encoder 1 Ticks: {} | Encoder 2 Ticks: {}", std::get<0>(ReadEncoders()), std::get<1>(ReadEncoders())));
}
}
}
Loading