-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All libraries tested I'm happy with the way the CMakeLists.txt file is All libraries used in Sheldrake without issues
- Loading branch information
Showing
11 changed files
with
165 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
#include "Serializer.hpp" | ||
#include "Serializer.hpp" | ||
|
||
namespace serializer{ | ||
|
||
|
||
uint8_t create_unique_id(){ | ||
static uint8_t id = 1; | ||
return id++; | ||
#ifdef USING_STANDARD_LIBRARY | ||
if(id == 0){ | ||
throw std::runtime_error("Too many objects have been serialized. The maximum number of unique objects is 255."); | ||
} | ||
#endif | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include "TinyMatrixMath.hpp" | ||
#include "TCP_utils.hpp" | ||
|
||
namespace tcp{ | ||
|
||
template<tmm::Size num_inputs, typename Scalar = float> | ||
class States{ | ||
public: | ||
tmm::Matrix<num_inputs, 1, Scalar> states; | ||
|
||
// Timekeeping | ||
|
||
/// @brief Get the time since the last call to update() in milliseconds | ||
/// @return unsigned long | ||
unsigned long time_since_last_update_milliseconds(){ | ||
return millis()-_timestamp; | ||
} | ||
|
||
/// @brief Get the time between the last two update() calls in milliseconds | ||
/// @return unsigned long | ||
unsigned long instantaneous_update_period_milliseconds(){return _instantaneous_update_period;} | ||
|
||
/// @brief Get the time since the last call to update() in seconds | ||
/// @return float | ||
float time_since_last_update_seconds(){ | ||
return (float)time_since_last_update_seconds() / 1000.f; | ||
} | ||
|
||
/// @brief Get the time between the last two update() calls in seconds | ||
/// @return float | ||
float instantaneous_update_period_seconds(){ | ||
return (float)instantaneous_update_period_milliseconds() / 1000.f; | ||
} | ||
|
||
/// @brief Call this at the end of your update() function to update the timekeeping variables | ||
void update_timestamp(){ | ||
unsigned long now = millis(); | ||
_instantaneous_update_period = now-_timestamp; | ||
_timestamp = now; | ||
} | ||
|
||
private: | ||
/// @brief The value of millis() during the last time update() was called | ||
unsigned long _timestamp = 0; | ||
/// @brief The time between the last two update() calls in milliseconds | ||
unsigned long _instantaneous_update_period = 0; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "TCP_utils.hpp" | ||
|
||
#ifdef USING_STANDARD_LIBRARY | ||
|
||
#include <chrono> // for emulating millis() | ||
|
||
namespace tcp{ | ||
|
||
// Subroutines to emulate the Arduino library with the Standard Library | ||
// Replicates Arduino's "millis()" if using the Standard Library | ||
unsigned long millis(){ | ||
namespace sc = std::chrono; | ||
auto time = sc::system_clock::now(); | ||
auto since_epoch = time.time_since_epoch(); | ||
auto millis = sc::duration_cast<sc::milliseconds>(since_epoch); | ||
long now = millis.count(); | ||
return now; | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#if USING_STANDARD_LIBRARY | ||
|
||
namespace tcp{ | ||
|
||
// Subroutines to emulate the Arduino library with the Standard Library | ||
// Replicates Arduino's "millis()" if using the Standard Library | ||
unsigned long millis(); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters