Rename hcore=>smocore
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#ifndef _ASSOCIATION_H
|
||||
#define _ASSOCIATION_H
|
||||
|
||||
#include <chronomenon.h>
|
||||
#include <existent.h>
|
||||
|
||||
class Association
|
||||
{
|
||||
public:
|
||||
Association(Quale quale, Chronomenon chron);
|
||||
Association(Quale quale, Existent ex);
|
||||
Association(Quale quale, Existent ex);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef _ATTENTION_GRABBER_H
|
||||
#define _ATTENTION_GRABBER_H
|
||||
|
||||
#include <cstdbool>
|
||||
#include <attentionTrigger.h>
|
||||
#include <chronomenon.h>
|
||||
|
||||
class AttentionGrabber
|
||||
{
|
||||
public:
|
||||
AttentionGrabber(AttentionTrigger cause, Chronomenon chron)
|
||||
: isNull(false)
|
||||
{
|
||||
}
|
||||
|
||||
void setNull(void) { isNull = true; }
|
||||
int operator!(void) { return isNull; }
|
||||
|
||||
public:
|
||||
AttentionTrigger cause;
|
||||
Chronomenon chron;
|
||||
bool isNull;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef _ATTENTION_TRIGGER_H
|
||||
#define _ATTENTION_TRIGGER_H
|
||||
|
||||
class AttentionTrigger
|
||||
{};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef _CHRONOMENON_H
|
||||
#define _CHRONOMENON_H
|
||||
|
||||
#include <vector>
|
||||
#include <qualeBundle.h>
|
||||
#include <mentalEntity.h>
|
||||
|
||||
class Chronomenon
|
||||
: public MentalEntity
|
||||
{
|
||||
public:
|
||||
class Timestamp
|
||||
{
|
||||
uintptr_t value;
|
||||
};
|
||||
|
||||
class Duration
|
||||
{
|
||||
uintptr_t value;
|
||||
};
|
||||
|
||||
public:
|
||||
Chronomenon extract(Timestamp start, Duration len);
|
||||
|
||||
public:
|
||||
std::vector<QualeBundle> qualia;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef COMPONENT_THREAD_H
|
||||
#define COMPONENT_THREAD_H
|
||||
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <condition_variable>
|
||||
#include <boost/asio.hpp>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace hk {
|
||||
|
||||
class ComponentThread
|
||||
{
|
||||
public:
|
||||
ComponentThread()
|
||||
: work(io_service), startupSync(),
|
||||
thread(ComponentThread::main, std::ref(*this))
|
||||
{}
|
||||
|
||||
boost::asio::io_service& getIoService(void) { return io_service; }
|
||||
|
||||
static boost::asio::io_service& getEventLoop(
|
||||
std::thread::id id = std::this_thread::get_id())
|
||||
{
|
||||
auto it = componentThreads.find(id);
|
||||
if (it == componentThreads.end())
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__)
|
||||
+ ": Thread ID not found in componentThreads map");
|
||||
}
|
||||
|
||||
return it->second.getIoService();
|
||||
}
|
||||
|
||||
static void main(ComponentThread &self);
|
||||
static void signalThread(std::thread::id id);
|
||||
static void validateThreadIds(void);
|
||||
|
||||
public:
|
||||
boost::asio::io_service io_service;
|
||||
boost::asio::io_service::work work;
|
||||
struct StartupSync {
|
||||
std::mutex mutex;
|
||||
std::condition_variable cv;
|
||||
bool ready;
|
||||
|
||||
StartupSync() : ready(false) {}
|
||||
} startupSync;
|
||||
|
||||
/* Always ensure that this is last so that the thread is spawned after
|
||||
* everything else.
|
||||
*/
|
||||
std::thread thread;
|
||||
static std::unordered_map<std::thread::id, ComponentThread&> componentThreads;
|
||||
};
|
||||
|
||||
namespace director {
|
||||
extern ComponentThread director;
|
||||
}
|
||||
namespace simulator {
|
||||
extern ComponentThread canvas;
|
||||
}
|
||||
namespace subconscious {
|
||||
extern ComponentThread subconscious;
|
||||
}
|
||||
|
||||
} // namespace hk
|
||||
|
||||
#endif // COMPONENT_THREAD_H
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef _CONCEPT_H
|
||||
#define _CONCEPT_H
|
||||
|
||||
#include <mentalEntity.h>
|
||||
|
||||
class Concept
|
||||
: public MentalEntity
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef DEVICEMANAGER_H
|
||||
#define DEVICEMANAGER_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <opts.h>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <user/senseDeviceSpec.h>
|
||||
|
||||
namespace hk {
|
||||
namespace device {
|
||||
|
||||
class DeviceManager
|
||||
{
|
||||
public:
|
||||
static DeviceManager& getInstance()
|
||||
{
|
||||
static DeviceManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::string readDeviceFile(const std::string& filename);
|
||||
void collateAllDeviceSpecs(void);
|
||||
void parseAllDeviceSpecs(void);
|
||||
static const std::string stringifyDeviceSpecs(void);
|
||||
|
||||
private:
|
||||
DeviceManager() = default;
|
||||
~DeviceManager() = default;
|
||||
DeviceManager(const DeviceManager&) = delete;
|
||||
DeviceManager& operator=(const DeviceManager&) = delete;
|
||||
|
||||
public:
|
||||
std::string allDeviceSpecs;
|
||||
static std::vector<std::shared_ptr<InteroceptorDeviceSpec>>
|
||||
interoceptorDeviceSpecs;
|
||||
static std::vector<std::shared_ptr<ExtrospectorDeviceSpec>>
|
||||
extrospectorDeviceSpecs;
|
||||
static std::vector<std::shared_ptr<SenseDeviceSpec>>
|
||||
senseDeviceSpecs;
|
||||
};
|
||||
|
||||
} // namespace device
|
||||
} // namespace hk
|
||||
|
||||
#endif // DEVICEMANAGER_H
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef DIRECTOR_COMMANDLIST_H
|
||||
#define DIRECTOR_COMMANDLIST_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <mentalEntity.h>
|
||||
|
||||
namespace hk {
|
||||
namespace director {
|
||||
|
||||
/**
|
||||
* @brief Base class for all commands, storing a reference to a mental entity ID.
|
||||
*
|
||||
* Derived classes can extend this to include additional command-specific
|
||||
* data and behavior.
|
||||
*/
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
Command(const MentalEntity::Id menty) : menty(menty) {}
|
||||
|
||||
public:
|
||||
const MentalEntity::Id menty;
|
||||
};
|
||||
|
||||
class CommandList
|
||||
{
|
||||
public:
|
||||
CommandList() = default;
|
||||
|
||||
/**
|
||||
* @brief Used by Director to point to the currently executing command.
|
||||
*
|
||||
* director::Director maintains an internal cursor. As it executes commands
|
||||
* from its internal command list, it advances the cursor to the current
|
||||
* command before executing it.
|
||||
*/
|
||||
class Cursor
|
||||
{
|
||||
public:
|
||||
Cursor(CommandList& commandList)
|
||||
: commandList(commandList), iter(commandList.commands.begin())
|
||||
{}
|
||||
|
||||
void reset() { iter = commandList.commands.begin(); }
|
||||
bool hasNext() const { return iter != commandList.commands.end(); }
|
||||
Cursor next() { return ++(*this); }
|
||||
|
||||
Cursor& operator++() {
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Cursor(
|
||||
CommandList& commandList,
|
||||
std::vector<Command>::iterator iter)
|
||||
: commandList(commandList), iter(iter)
|
||||
{}
|
||||
|
||||
public:
|
||||
CommandList& commandList;
|
||||
std::vector<Command>::iterator iter;
|
||||
};
|
||||
|
||||
Cursor getCursor() { return Cursor(*this); }
|
||||
void addCommand(const Command& command)
|
||||
{
|
||||
commands.push_back(command);
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Command> commands;
|
||||
};
|
||||
|
||||
} // namespace director
|
||||
} // namespace hk
|
||||
|
||||
#endif // DIRECTOR_COMMANDLIST_H
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef DIRECTOR_H
|
||||
#define DIRECTOR_H
|
||||
|
||||
#include <config.h>
|
||||
#include <goal.h>
|
||||
|
||||
namespace hk {
|
||||
namespace director {
|
||||
|
||||
class Director {
|
||||
public:
|
||||
Director() = default;
|
||||
~Director() = default;
|
||||
|
||||
Goal purpose;
|
||||
};
|
||||
|
||||
} // namespace director
|
||||
} // namespace hk
|
||||
|
||||
#endif // DIRECTOR_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _GOAL_H
|
||||
#define _GOAL_H
|
||||
|
||||
#include <simulator/scene.h>
|
||||
|
||||
namespace hk {
|
||||
|
||||
class Goal
|
||||
: public simulator::Scene {
|
||||
public:
|
||||
Goal() = default;
|
||||
~Goal() = default;
|
||||
};
|
||||
|
||||
} // namespace hk
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef IMPLIX_H
|
||||
#define IMPLIX_H
|
||||
|
||||
namespace hk {
|
||||
namespace implix {
|
||||
|
||||
class Implix
|
||||
{
|
||||
public:
|
||||
Implix() = default;
|
||||
~Implix() = default;
|
||||
};
|
||||
|
||||
} // namespace implix
|
||||
} // namespace hk
|
||||
|
||||
#endif // IMPLIX_H
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef _BODY_H
|
||||
#define _BODY_H
|
||||
|
||||
namespace mrntt {
|
||||
namespace body {
|
||||
|
||||
class Body
|
||||
{
|
||||
public:
|
||||
Body() = default;
|
||||
~Body() = default;
|
||||
};
|
||||
|
||||
} // namespace body
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // _BODY_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef MRNTT_BODY_BODYMAP_H
|
||||
#define MRNTT_BODY_BODYMAP_H
|
||||
|
||||
#include <set>
|
||||
#include <cstdint>
|
||||
#include <body/limb.h>
|
||||
|
||||
namespace mrntt {
|
||||
namespace body {
|
||||
|
||||
class BodyMap {
|
||||
public:
|
||||
BodyMap() = default;
|
||||
~BodyMap() = default;
|
||||
|
||||
public:
|
||||
std::set<uint32_t, Limb> limbs;
|
||||
};
|
||||
|
||||
} // namespace body
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // MRNTT_BODY_BODYMAP_H
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef MRNTT_BODY_BODYMESSAGE_H
|
||||
#define MRNTT_BODY_BODYMESSAGE_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#include <body/limb.h>
|
||||
#include <body/part.h>
|
||||
|
||||
namespace mrntt {
|
||||
namespace body {
|
||||
|
||||
class BodyMessage
|
||||
{
|
||||
public:
|
||||
BodyMessage() = default;
|
||||
~BodyMessage() = default;
|
||||
};
|
||||
|
||||
class SpotImpactEntry
|
||||
{
|
||||
public:
|
||||
enum class ReportType
|
||||
{
|
||||
PRESSURE,
|
||||
PAIN,
|
||||
PLEASURE,
|
||||
HEAT,
|
||||
COLD
|
||||
};
|
||||
|
||||
SpotImpactEntry(uint32_t _spot, ReportType _type, uint32_t _value)
|
||||
: spot(_spot), type(_type), value(_value)
|
||||
{}
|
||||
~SpotImpactEntry() = default;
|
||||
|
||||
public:
|
||||
uint32_t spot;
|
||||
ReportType type;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
class SpotImpactInd : public BodyMessage
|
||||
{
|
||||
public:
|
||||
SpotImpactInd(Part &_part) : part(_part) {}
|
||||
~SpotImpactInd() = default;
|
||||
|
||||
public:
|
||||
Part ∂
|
||||
std::vector<SpotImpactEntry> entries;
|
||||
};
|
||||
|
||||
class PartMsg : public BodyMessage
|
||||
{
|
||||
public:
|
||||
PartMsg(const Part& _part) : part(_part) {}
|
||||
|
||||
public:
|
||||
const Part& part;
|
||||
};
|
||||
|
||||
} // namespace body
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // MRNTT_BODY_BODYMESSAGE_H
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef MRNTT_BODY_LIMB_H
|
||||
#define MRNTT_BODY_LIMB_H
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <cstdint>
|
||||
|
||||
#include <body/part.h>
|
||||
|
||||
namespace mrntt {
|
||||
namespace body {
|
||||
|
||||
class Limb
|
||||
{
|
||||
public:
|
||||
Limb(uint32_t _id) : id(_id) {}
|
||||
Limb(uint32_t _id,
|
||||
const std::string& _name, const std::string& _desc,
|
||||
const std::string& _loc)
|
||||
: id(_id), name(_name), description(_desc), location(_loc)
|
||||
{}
|
||||
|
||||
~Limb() = default;
|
||||
|
||||
public:
|
||||
uint32_t id;
|
||||
std::string name, description, location;
|
||||
std::set<uint32_t, Part> parts;
|
||||
};
|
||||
|
||||
} // namespace body
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // MRNTT_BODY_LIMB_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _BODY_MAP_H
|
||||
#define _BODY_MAP_H
|
||||
|
||||
#include <set>
|
||||
#include <cstdint>
|
||||
|
||||
#include <body/limb.h>
|
||||
|
||||
namespace mrntt {
|
||||
namespace body {
|
||||
|
||||
class BodyMap {
|
||||
public:
|
||||
BodyMap() = default;
|
||||
~BodyMap() = default;
|
||||
|
||||
std::set<uint32_t, Limb> limbs;
|
||||
};
|
||||
|
||||
} // namespace body
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // _BODY_MAP_H
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef BODYPART_H
|
||||
#define BODYPART_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include <sensors/interoceptor.h>
|
||||
|
||||
namespace mrntt {
|
||||
namespace body {
|
||||
|
||||
class Spot
|
||||
{
|
||||
public:
|
||||
Spot(uint32_t _id, std::string _description)
|
||||
: id(_id), description(_description)
|
||||
{}
|
||||
|
||||
~Spot() = default;
|
||||
|
||||
public:
|
||||
uint32_t id;
|
||||
std::string description;
|
||||
std::set<uint32_t, Interoceptor> interoceptors;
|
||||
};
|
||||
|
||||
class Part
|
||||
{
|
||||
public:
|
||||
Part(uint32_t _partId, std::string _partName,
|
||||
std::string _partDesc, std::string _partLoc)
|
||||
: id(_partId), name(_partName),
|
||||
description(_partDesc), location(_partLoc)
|
||||
{}
|
||||
|
||||
~Part() = default;
|
||||
|
||||
public:
|
||||
const uint32_t id;
|
||||
std::string name, description, location;
|
||||
std::set<uint32_t, Spot> spots;
|
||||
};
|
||||
|
||||
} // namespace body
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // BODYPART_H
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _MARIONETTE_H
|
||||
#define _MARIONETTE_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mrntt {
|
||||
|
||||
class Marionette
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace mrntt
|
||||
|
||||
#endif // _MARIONETTE_H
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef _MENTAL_ENTITY_H
|
||||
#define _MENTAL_ENTITY_H
|
||||
|
||||
namespace hk {
|
||||
|
||||
class MentalEntity
|
||||
{
|
||||
public:
|
||||
using Id = uint32_t;
|
||||
};
|
||||
|
||||
} // namespace hk
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef _MIND_H
|
||||
#define _MIND_H
|
||||
|
||||
#include <config.h>
|
||||
#include <thread>
|
||||
|
||||
#include <director/director.h>
|
||||
#include <simulator/simulator.h>
|
||||
|
||||
namespace hk {
|
||||
|
||||
class Mind
|
||||
{
|
||||
public:
|
||||
void execute(void);
|
||||
|
||||
public:
|
||||
std::thread directorThread;
|
||||
std::thread simulatorThread;
|
||||
std::thread subconsciousThread;
|
||||
|
||||
director::Director director;
|
||||
simulator::Simulator canvas;
|
||||
};
|
||||
|
||||
} // namespace hk
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef _NON_NEUTRAL_QUALIA_H
|
||||
#define _NON_NEUTRAL_QUALIA_H
|
||||
|
||||
#include <quale.h>
|
||||
|
||||
class PleasurableQuale
|
||||
: public NonNeutralQuale
|
||||
{
|
||||
public:
|
||||
virtual void eventInd(void);
|
||||
};
|
||||
|
||||
class PainfulQuale
|
||||
: public NonNeutralQuale
|
||||
{
|
||||
public:
|
||||
virtual void eventInd(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef OPTS_H
|
||||
#define OPTS_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <getopt.h>
|
||||
|
||||
// Define a class to hold the options and parse arguments
|
||||
class OptionParser
|
||||
{
|
||||
public:
|
||||
OptionParser() : verbose(false), printUsage(false) {}
|
||||
~OptionParser() = default;
|
||||
|
||||
void parseArguments(int argc, char *argv[], char **envp);
|
||||
std::string stringifyOptions(void) const;
|
||||
std::string getUsage() const;
|
||||
|
||||
static OptionParser &getOptions(void)
|
||||
{
|
||||
static OptionParser options;
|
||||
return options;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string argv0;
|
||||
std::string senseApiLibPath;
|
||||
std::vector<std::string> senseApiLibs;
|
||||
std::string deviceSpecs;
|
||||
std::vector<std::string> deviceSpecFiles;
|
||||
bool verbose, printUsage;
|
||||
|
||||
static struct option longOptions[];
|
||||
};
|
||||
|
||||
#endif // OPTS_H
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef _QUALE_H
|
||||
#define _QUALE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <attentionTrigger.h>
|
||||
|
||||
class Quale
|
||||
{
|
||||
public:
|
||||
enum class Type
|
||||
{
|
||||
NEUTRAL,
|
||||
/* Bounding refers to qualia such as tactile pressure which
|
||||
* are mostly neutral but disclose information about the limits
|
||||
* of the body.
|
||||
**/
|
||||
BOUNDING,
|
||||
PAINFUL,
|
||||
PLEASURABLE
|
||||
} type;
|
||||
|
||||
int32_t intensity;
|
||||
};
|
||||
|
||||
class NeutralQuale
|
||||
: public Quale
|
||||
{
|
||||
};
|
||||
|
||||
class NonNeutralQuale
|
||||
: public Quale, public AttentionTrigger
|
||||
{
|
||||
public:
|
||||
virtual void eventInd(void);
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef _QUALE_BUNDLE_H
|
||||
#define _QUALE_BUNDLE_H
|
||||
|
||||
#include <config.h>
|
||||
#include <array>
|
||||
#include <quale.h>
|
||||
|
||||
#define CONFIG_NUM_SENSORS 5
|
||||
|
||||
typedef std::array<Quale, CONFIG_NUM_SENSORS> QualeBundle_t;
|
||||
class QualeBundle
|
||||
{
|
||||
QualeBundle_t qualia;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
#ifndef SENSE_API_PROVIDER_DESC_H
|
||||
#define SENSE_API_PROVIDER_DESC_H
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <dlfcn.h>
|
||||
#include <functional>
|
||||
#include <user/senseApiDesc.h>
|
||||
|
||||
namespace hk {
|
||||
namespace sense_api {
|
||||
|
||||
class SenseApiLib
|
||||
{
|
||||
private:
|
||||
friend class SenseApiManager;
|
||||
struct DlCloser
|
||||
{
|
||||
void operator()(void* handle) const
|
||||
{
|
||||
if (handle) {
|
||||
dlclose(handle);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public:
|
||||
SenseApiLib(
|
||||
const std::string& path, void *_dlopen_handle,
|
||||
HK_GET_SENSE_API_DESC_FN_TYPEDEF *descFn)
|
||||
: libraryPath(path),
|
||||
dlopen_handle(_dlopen_handle, DlCloser()),
|
||||
HK_GET_SENSE_API_DESC_FN_NAME(descFn)
|
||||
{}
|
||||
|
||||
void setSenseApiDesc(const SenseApiDesc &desc)
|
||||
{
|
||||
if (!SenseApiDesc::sanityCheck(desc))
|
||||
{
|
||||
throw std::runtime_error(
|
||||
std::string(__func__) + ": Sanity check failed for sense API "
|
||||
"descriptor in library '" + libraryPath + "'");
|
||||
}
|
||||
|
||||
senseApiDesc = desc;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string libraryPath;
|
||||
std::unique_ptr<void, DlCloser> dlopen_handle;
|
||||
/* UNIMPLEMENTED: API-specific cmdline options. These affect this specific
|
||||
* sense api lib's behaviour globally.
|
||||
*/
|
||||
std::vector<std::string> options;
|
||||
|
||||
/**
|
||||
* @brief Every sense API lib is required to provide a function that returns
|
||||
* a SenseApiDesc struct. This struct states which API the lib uses to
|
||||
* connect Harikoff to the sense provider it supports.
|
||||
*
|
||||
* This getter function should be visible to dlsym() so that Harikoff can
|
||||
* find it in the lib after loading it, and call it.
|
||||
*/
|
||||
std::function<HK_GET_SENSE_API_DESC_FN_TYPEDEF>
|
||||
HK_GET_SENSE_API_DESC_FN_NAME;
|
||||
|
||||
/**
|
||||
* @brief Harikoff will call the `HK_GET_SENSE_API_DESC_FN_NAME` getter
|
||||
* function and use the data it provides in order to fill out this
|
||||
* descriptor.
|
||||
*/
|
||||
SenseApiDesc senseApiDesc;
|
||||
|
||||
std::string stringify() const {
|
||||
std::string result = "Library Path: " + libraryPath + "\n";
|
||||
result += "Sense API Descriptor: " + senseApiDesc.stringify() + "\n";
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sense_api
|
||||
} // namespace hk
|
||||
|
||||
#endif // SENSE_API_PROVIDER_DESC_H
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef SENSE_API_MANAGER_H
|
||||
#define SENSE_API_MANAGER_H
|
||||
|
||||
#include <config.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <senseApis/senseApiLib.h>
|
||||
#include <user/senseDeviceSpec.h>
|
||||
|
||||
namespace hk {
|
||||
namespace sense_api {
|
||||
|
||||
class SenseApiManager
|
||||
{
|
||||
public:
|
||||
static SenseApiManager& getInstance()
|
||||
{
|
||||
static SenseApiManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
SenseApiLib& loadSenseApiLib(const std::string& libraryPath);
|
||||
std::optional<std::reference_wrapper<SenseApiLib>> getSenseApiLib(
|
||||
const std::string& libraryPath);
|
||||
std::optional<std::reference_wrapper<SenseApiLib>> getSenseApiLibByApiName(
|
||||
const std::string& apiName);
|
||||
void unloadSenseApiLib(const std::string& libraryPath);
|
||||
|
||||
void initializeSenseApiLib(SenseApiLib& lib);
|
||||
void finalizeSenseApiLib(SenseApiLib& lib);
|
||||
|
||||
void loadAllSenseApiLibsFromOptions(void);
|
||||
void unloadAllSenseApiLibs(void);
|
||||
void initializeAllSenseApiLibs(void);
|
||||
void finalizeAllSenseApiLibs(void);
|
||||
|
||||
void attachAllSenseDevicesFromSpecs(void);
|
||||
void attachSenseDevice(const device::SenseDeviceSpec& spec);
|
||||
void detachSenseDevice(const device::SenseDeviceSpec& spec);
|
||||
void detachAllSenseDevices(void);
|
||||
|
||||
std::string stringifyLibs() const;
|
||||
|
||||
private:
|
||||
SenseApiManager() = default;
|
||||
~SenseApiManager() = default;
|
||||
|
||||
SenseApiManager(const SenseApiManager&) = delete;
|
||||
SenseApiManager& operator=(const SenseApiManager&) = delete;
|
||||
|
||||
std::vector<std::unique_ptr<SenseApiLib>> senseApiLibs;
|
||||
};
|
||||
|
||||
} // namespace sense_api
|
||||
} // namespace hk
|
||||
|
||||
#endif // SENSE_API_MANAGER_H
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _EXTROSPECTOR_H
|
||||
#define _EXTROSPECTOR_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <sensors/sensor.h>
|
||||
|
||||
namespace hk {
|
||||
namespace sensors {
|
||||
|
||||
class Extrospector
|
||||
: public Sensor
|
||||
{
|
||||
public:
|
||||
Extrospector(void) = default;
|
||||
~Extrospector() = default;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace sensors
|
||||
} // namespace hk
|
||||
|
||||
#endif // _EXTROSPECTOR_H
|
||||
@@ -0,0 +1,109 @@
|
||||
#ifndef _INTEROCEPTOR_H
|
||||
#define _INTEROCEPTOR_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <sensors/sensor.h>
|
||||
|
||||
namespace hk {
|
||||
namespace sensors {
|
||||
|
||||
class Interoceptor
|
||||
: public Sensor
|
||||
{
|
||||
public:
|
||||
Interoceptor(uint32_t _id, uint32_t _value = 0)
|
||||
: id(_id), value(_value)
|
||||
{}
|
||||
~Interoceptor() = default;
|
||||
|
||||
public:
|
||||
uint32_t id;
|
||||
uint64_t value;
|
||||
};
|
||||
|
||||
class NeutrinTeroceptor
|
||||
: public Interoceptor
|
||||
{
|
||||
public:
|
||||
NeutrinTeroceptor(uint32_t _id, uint32_t _value = 0)
|
||||
: Interoceptor(_id, _value)
|
||||
{}
|
||||
};
|
||||
|
||||
class IntrinTeroceptor
|
||||
: public Interoceptor
|
||||
{
|
||||
public:
|
||||
static constexpr uint32_t DEFAULT_INDICATION_THRESHOLD = 1;
|
||||
static constexpr uint32_t DEFAULT_ALERT_THRESHOLD = 5;
|
||||
static constexpr uint32_t DEFAULT_OVERLOAD_THRESHOLD = 9;
|
||||
|
||||
IntrinTeroceptor(
|
||||
uint32_t _id,
|
||||
uint32_t _value = 0,
|
||||
uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD,
|
||||
uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD,
|
||||
uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD)
|
||||
: Interoceptor(_id, _value),
|
||||
indicationThreshold(_indicationThreshold),
|
||||
alertThreshold(_alertThreshold),
|
||||
overloadThreshold(_overloadThreshold)
|
||||
{}
|
||||
|
||||
~IntrinTeroceptor() = default;
|
||||
|
||||
public:
|
||||
uint32_t indicationThreshold;
|
||||
uint32_t alertThreshold;
|
||||
uint32_t overloadThreshold;
|
||||
};
|
||||
|
||||
/**
|
||||
* Negtrin and Postrin interoceptors are specialized intrinsic interoceptors
|
||||
* that, unlike neutral interoceptors, have activation thresholds for different
|
||||
* response levels (indication, alert, and overload). These thresholds allow
|
||||
* them to trigger graduated responses based on stimulus intensity.
|
||||
*
|
||||
* While neutral interoceptors simply record a binary state or basic value,
|
||||
* Negtrin and Postrin Interoceptors can model complex sensory responses with
|
||||
* multiple activation levels, similar to biological pain/pleasure responses.
|
||||
* Each threshold represents a different level of urgency or intensity in the
|
||||
* sensory input.
|
||||
*
|
||||
* @see IntrinTeroceptor for the threshold values and implementation details
|
||||
******************************************************************************/
|
||||
|
||||
class NegtrinTeroceptor
|
||||
: public IntrinTeroceptor
|
||||
{
|
||||
public:
|
||||
NegtrinTeroceptor(
|
||||
uint32_t _id,
|
||||
uint32_t _value = 0,
|
||||
uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD,
|
||||
uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD,
|
||||
uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD)
|
||||
: IntrinTeroceptor(_id, _value,
|
||||
_indicationThreshold, _alertThreshold, _overloadThreshold)
|
||||
{}
|
||||
};
|
||||
|
||||
class PostrinTeroceptor
|
||||
: public IntrinTeroceptor
|
||||
{
|
||||
public:
|
||||
PostrinTeroceptor(
|
||||
uint32_t _id,
|
||||
uint32_t _value = 0,
|
||||
uint32_t _indicationThreshold = DEFAULT_INDICATION_THRESHOLD,
|
||||
uint32_t _alertThreshold = DEFAULT_ALERT_THRESHOLD,
|
||||
uint32_t _overloadThreshold = DEFAULT_OVERLOAD_THRESHOLD)
|
||||
: IntrinTeroceptor(_id, _value,
|
||||
_indicationThreshold, _alertThreshold, _overloadThreshold)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace sensors
|
||||
} // namespace hk
|
||||
|
||||
#endif // _INTEROCEPTOR_H
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _SENSOR_H
|
||||
#define _SENSOR_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace hk {
|
||||
namespace sensors {
|
||||
|
||||
class Sensor
|
||||
{
|
||||
public:
|
||||
Sensor() = default;
|
||||
~Sensor() = default;
|
||||
|
||||
public:
|
||||
};
|
||||
|
||||
} // namespace sensors
|
||||
} // namespace hk
|
||||
|
||||
#endif // _SENSOR_H
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef SIMULATOR_COMMANDLIST_H
|
||||
#define SIMULATOR_COMMANDLIST_H
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <mentalEntity.h>
|
||||
|
||||
namespace hk {
|
||||
namespace simulator {
|
||||
|
||||
/**
|
||||
* @brief Base class for all commands, storing a reference to a mental entity ID.
|
||||
*
|
||||
* Derived classes can extend this to include additional command-specific
|
||||
* data and behavior.
|
||||
*/
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
Command(const MentalEntity::Id menty) : menty(menty) {}
|
||||
|
||||
public:
|
||||
const MentalEntity::Id menty;
|
||||
};
|
||||
|
||||
class CommandList
|
||||
{
|
||||
public:
|
||||
CommandList() = default;
|
||||
|
||||
/**
|
||||
* @brief Used by Scene to point to the currently executing command.
|
||||
*
|
||||
* simulator::Scene maintains an internal cursor. As it executes commands
|
||||
* from its internal command list, it advances the cursor to the current
|
||||
* command before executing it.
|
||||
*/
|
||||
class Cursor
|
||||
{
|
||||
public:
|
||||
Cursor(CommandList& commandList)
|
||||
: commandList(commandList), iter(commandList.commands.begin())
|
||||
{}
|
||||
|
||||
void reset() { iter = commandList.commands.begin(); }
|
||||
bool hasNext() const { return iter != commandList.commands.end(); }
|
||||
Cursor next() { return ++(*this); }
|
||||
|
||||
Cursor& operator++() {
|
||||
++iter;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Cursor(
|
||||
CommandList& commandList,
|
||||
std::vector<Command>::iterator iter)
|
||||
: commandList(commandList), iter(iter)
|
||||
{}
|
||||
|
||||
public:
|
||||
CommandList& commandList;
|
||||
std::vector<Command>::iterator iter;
|
||||
};
|
||||
|
||||
Cursor getCursor() { return Cursor(*this); }
|
||||
void addCommand(const Command& command)
|
||||
{
|
||||
commands.push_back(command);
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Command> commands;
|
||||
};
|
||||
|
||||
} // namespace simulator
|
||||
} // namespace hk
|
||||
|
||||
#endif // SIMULATOR_COMMANDLIST_H
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef _SCENE_H
|
||||
#define _SCENE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <mentalEntity.h>
|
||||
#include <simulator/commandList.h>
|
||||
|
||||
namespace hk {
|
||||
namespace simulator {
|
||||
|
||||
class Scene
|
||||
{
|
||||
public:
|
||||
using Id = uint32_t;
|
||||
|
||||
Scene(void) :
|
||||
cursor(commands)
|
||||
{}
|
||||
~Scene() = default;
|
||||
|
||||
bool hasMentalEntity(const MentalEntity::Id menty) const;
|
||||
MentalEntity::Id addMentalEntity(const MentalEntity& menty);
|
||||
void replaceMentalEntity(const MentalEntity::Id menty, const MentalEntity& newMenty);
|
||||
void removeMentalEntity(const MentalEntity::Id menty);
|
||||
|
||||
void executeInd(void);
|
||||
CommandList::Cursor haltInd(void);
|
||||
|
||||
private:
|
||||
std::map<MentalEntity::Id, MentalEntity &> menties;
|
||||
CommandList commands;
|
||||
CommandList::Cursor cursor;
|
||||
};
|
||||
|
||||
} // namespace simulator
|
||||
} // namespace hk
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef SIMULATOR_H
|
||||
#define SIMULATOR_H
|
||||
|
||||
#include <config.h>
|
||||
#include <simulator/scene.h>
|
||||
|
||||
namespace hk {
|
||||
namespace simulator {
|
||||
|
||||
class Simulator {
|
||||
public:
|
||||
Simulator() = default;
|
||||
~Simulator() = default;
|
||||
|
||||
void initialize();
|
||||
void loadScene(Scene::Id sceneId, Scene &scene);
|
||||
|
||||
private:
|
||||
Scene::Id sceneId;
|
||||
Scene scene;
|
||||
};
|
||||
|
||||
} // namespace simulator
|
||||
} // namespace hk
|
||||
|
||||
#endif // SIMULATOR_H
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef _SINGLECEPT_H
|
||||
#define _SINGLECEPT_H
|
||||
|
||||
#include <mentalEntity.h>
|
||||
#include <implix/implix.h>
|
||||
|
||||
class Singlecept
|
||||
: public MentalEntity
|
||||
{
|
||||
public:
|
||||
Singlecept() = default;
|
||||
~Singlecept() = default;
|
||||
|
||||
Singlecept(const implix::Implix&) {
|
||||
// Conversion logic from Implix to Singlecept
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef STUPEFIER_H
|
||||
#define STUPEFIER_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class Stupefier {
|
||||
public:
|
||||
Stupefier();
|
||||
~Stupefier();
|
||||
|
||||
void up(uint32_t);
|
||||
void down(uint32_t);
|
||||
|
||||
public:
|
||||
uint32_t focus;
|
||||
};
|
||||
|
||||
class SoftStupefier : public Stupefier {
|
||||
public:
|
||||
SoftStupefier();
|
||||
~SoftStupefier();
|
||||
};
|
||||
|
||||
class HardStupefier : public Stupefier {
|
||||
public:
|
||||
HardStupefier();
|
||||
~HardStupefier();
|
||||
};
|
||||
|
||||
#endif // STUPEFIER_H
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef _SUBCONSCIOUS_H
|
||||
#define _SUBCONSCIOUS_H
|
||||
|
||||
#include <thoughtContentSource.h>
|
||||
|
||||
class Subconscious
|
||||
: public ThoughtContentSource
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,60 @@
|
||||
#ifndef _THOUGHT_H
|
||||
#define _THOUGHT_H
|
||||
|
||||
#include <iostream>
|
||||
#include <scene.h>
|
||||
#include <attentionGrabber.h>
|
||||
#include <goal.h>
|
||||
|
||||
class Thought
|
||||
{
|
||||
public:
|
||||
Thought(void)
|
||||
{
|
||||
setGoal(thought::Goal::DRIFT);
|
||||
}
|
||||
|
||||
public:
|
||||
void walk(void)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
step();
|
||||
}
|
||||
};
|
||||
|
||||
void step(void) { std::cout <<"Step\n"; }
|
||||
void setGoal(thought::Goal g)
|
||||
{ goal = g; }
|
||||
|
||||
public:
|
||||
Scene scene;
|
||||
thought::Goal goal;
|
||||
};
|
||||
|
||||
class ActiveThought
|
||||
: public Thought
|
||||
{
|
||||
public:
|
||||
ActiveThought(AttentionGrabber ag)
|
||||
: currFocus(ag)
|
||||
{
|
||||
setGoal(thought::Goal
|
||||
::ASSOCIATE_CAUSAL_QUALE_WITH_INTRINSIC_MOTIVATORS);
|
||||
}
|
||||
|
||||
public:
|
||||
AttentionGrabber currFocus;
|
||||
};
|
||||
|
||||
class IdleThought
|
||||
: public Thought
|
||||
{
|
||||
public:
|
||||
IdleThought(void)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _THOUGHT_CONTENT_SOURCE_H
|
||||
#define _THOUGHT_CONTENT_SOURCE_H
|
||||
|
||||
class ThoughtContentSource
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef _VALUE_JUDGEMENT_H
|
||||
#define _VALUE_JUDGEMENT_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class ValueJdgmnt
|
||||
{
|
||||
uint32_t intensity;
|
||||
};
|
||||
|
||||
class PosValueJdgmnt
|
||||
: public ValueJdgmnt
|
||||
{
|
||||
};
|
||||
|
||||
class NegValueJdgmnt
|
||||
: public ValueJdgmnt
|
||||
{
|
||||
};
|
||||
|
||||
class NtrlValueJdgmnt
|
||||
: public ValueJdgmnt
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user