Skip to content

Commit

Permalink
Merge branch 'tempo' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed May 3, 2024
2 parents d938078 + 1000684 commit 613896c
Show file tree
Hide file tree
Showing 88 changed files with 1,187 additions and 330 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ tests_files/*

# mementar intern files
/file_intern/*
settings.json
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Limux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-gcc-x64",
"compileCommands": "${workspaceFolder}/../../build/compile_commands.json"
}
],
"version": 4
}
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 2.8.3)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
project(mementar)

add_compile_options(-std=c++1z -Wall)
Expand All @@ -23,7 +24,7 @@ find_package(cmake_modules REQUIRED)
find_package(pluginlib REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Widgets PrintSupport)
find_package(OpenCV REQUIRED)

find_package(ontologenius 0.4.0 REQUIRED)

################################################
## Declare ROS messages, services and actions ##
Expand All @@ -36,6 +37,7 @@ find_package(OpenCV REQUIRED)
MementarExplanation.msg
MementarOccasion.msg
StampedString.msg
StampedFact.msg
)

## Generate services in the 'srv' folder
Expand All @@ -62,7 +64,7 @@ find_package(OpenCV REQUIRED)
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
INCLUDE_DIRS include include/mementar/API
LIBRARIES mementar_lib
CATKIN_DEPENDS roscpp rospy std_msgs ontologenius
DEPENDS OpenCV
Expand All @@ -75,7 +77,8 @@ catkin_package(
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
include include/mementar/API
include
include/mementar/API
${catkin_INCLUDE_DIRS}
)

Expand Down Expand Up @@ -167,14 +170,16 @@ target_link_libraries(mementar_drawer_lib
##############################

add_library(mementar_lib
src/API/ActionsPublisher.cpp
src/API/ActionsSubscriber.cpp
src/API/TimelineManipulator.cpp
src/API/TimelinesManipulator.cpp
src/API/clients/ManagerClient.cpp
src/API/clients/ClientBase.cpp
src/API/OccasionsPublisher.cpp
src/API/OccasionsSubscriber.cpp
src/API/mementar/ActionsPublisher.cpp
src/API/mementar/ActionsSubscriber.cpp
src/API/mementar/TimelineManipulator.cpp
src/API/mementar/TimelinesManipulator.cpp
src/API/mementar/clients/ManagerClient.cpp
src/API/mementar/clients/ActionClient.cpp
src/API/mementar/clients/ClientBase.cpp
src/API/mementar/clients/FactClient.cpp
src/API/mementar/OccasionsPublisher.cpp
src/API/mementar/OccasionsSubscriber.cpp
)
target_link_libraries(mementar_lib ${catkin_LIBRARIES})
add_dependencies(mementar_lib ${catkin_EXPORTED_TARGETS} mementar_gencpp)
Expand All @@ -185,6 +190,7 @@ add_dependencies(mementar_lib ${catkin_EXPORTED_TARGETS} mementar_gencpp)

add_library(mementar_interface
src/RosInterface.cpp
src/graphical/timeline/CsvSaver.cpp
)
target_link_libraries(mementar_interface mementar_core_lib mementar_events_lib mementar_drawer_lib)
target_link_libraries(mementar_interface ${catkin_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/ClientBase.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1 class="title">ClientBase Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/clients/ClientBase.h&quot;</span></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/clients/ClientBase.h&quot;</span></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <a href="ManagerClient.html">ManagerClient</a></td></tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/Fact.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1 class="title">Fact Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/Fact.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/Fact.h&quot;</span>
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/ManagerClient.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h1 class="title">ManagerClient Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/clients/ManagerClient.h&quot;</span></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/clients/ManagerClient.h&quot;</span></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="ClientBase.html">ClientBase</a></td></tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/OccasionsPublisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1 class="title">OccasionsPublisher Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/OccasionsPublisher.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/OccasionsPublisher.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <a href="OntologiesManipulator.html">OntologiesManipulator</a></td></tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/OccasionsSubscriber.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1 class="title">OccasionsPublisher Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/OccasionsSubscriber.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/OccasionsSubscriber.h&quot;</span>
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/TimelineManipulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1 class="title">TimelineManipulator Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/TimelineManipulator.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/TimelineManipulator.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="OccasionsPublisher.html">OccasionsPublisher</a></td></tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion docs/cpp_API/TimelinesManipulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h1 class="title">TimelinesManipulator Class</h1>
<div class="table">
<table class="alignedsummary">
<tbody>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/API/TimelinesManipulator.h&quot;</span>
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include &quot;mementar/TimelinesManipulator.h&quot;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="ManagerClient.html">ManagerClient</a></td></tr></tbody></table>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ class ActionsPublisher
ActionsPublisher(ros::NodeHandle* n, const std::string& name = "");

void insert(const std::string& name, time_t start_stamp = time(0), time_t end_stamp = 0);
void insert(const std::string& name, ros::Time start_stamp = ros::Time::now(), ros::Time end_stamp = ros::Time(0));

void insertEnd(const std::string& name, time_t end_stamp = time(0));
void insertEnd(const std::string& name, ros::Time end_stamp = ros::Time::now());

private:
ros::NodeHandle* n_;
ros::Publisher pub_;

void publish(const std::string& name, time_t start_stamp, time_t end_stamp);
void publish(const std::string& name, ros::Time start_stamp, ros::Time end_stamp);
};

} // namespace mementar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#include <ros/callback_queue.h>

#include "mementar/MementarOccasion.h"
#include "mementar/API/Fact.h"
#include "mementar/API/OccasionsSubscriber.h"
#include "mementar/API/mementar/Fact.h"
#include "mementar/API/mementar/OccasionsSubscriber.h"

namespace mementar
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <ros/ros.h>

#include "mementar/API/Fact.h"
#include "mementar/API/mementar/Fact.h"

namespace mementar
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <ros/callback_queue.h>

#include "mementar/MementarOccasion.h"
#include "mementar/API/Fact.h"
#include "mementar/API/mementar/Fact.h"

namespace mementar
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

#include <ros/ros.h>

#include "mementar/API/ActionsPublisher.h"
#include "mementar/API/OccasionsPublisher.h"
#include "mementar/API/clients/ClientBase.h"
#include "mementar/API/mementar/ActionsPublisher.h"
#include "mementar/API/mementar/OccasionsPublisher.h"
#include "mementar/API/mementar/clients/ClientBase.h"
#include "mementar/API/mementar/clients/ActionClient.h"
#include "mementar/API/mementar/clients/FactClient.h"

namespace mementar
{
Expand All @@ -26,6 +28,8 @@ class TimelineManipulator

OccasionsPublisher fact_feeder;
ActionsPublisher action_feeder;
ActionClient actions;
FactClient facts;

private:
ros::NodeHandle* n_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#include <ros/ros.h>

#include "mementar/API/clients/ManagerClient.h"
#include "mementar/API/TimelineManipulator.h"
#include "mementar/API/mementar/clients/ManagerClient.h"
#include "mementar/API/mementar/TimelineManipulator.h"

namespace mementar
{
Expand Down
28 changes: 28 additions & 0 deletions include/mementar/API/mementar/clients/ActionClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef MEMENTAR_ACTIONCLIENT_H
#define MEMENTAR_ACTIONCLIENT_H

#include "mementar/API/mementar/clients/ClientBase.h"

namespace mementar
{

class ActionClient : public ClientBase
{
public:
ActionClient(ros::NodeHandle* n, const std::string& name) : ClientBase(n, (name == "") ? "action" : "action/" + name) {}

bool exist(const std::string& action_name);
std::vector<std::string> getPending();
bool isPending(const std::string& action_name);
ros::Time getStartStamp(const std::string& action_name);
ros::Time getEndStamp(const std::string& action_name);
ros::Time getDuration(const std::string& action_name);
std::string getStartFact(const std::string& action_name);
std::string getEndFact(const std::string& action_name);
std::vector<std::string> getFactsDuring(const std::string& action_name);
private:
};

} // namespace mementar

#endif // MEMENTAR_ACTIONCLIENT_H
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,41 @@ class ClientBase
}
}

inline ros::Time callStamp(mementar::MementarService& srv)
{
ros::Time res;
cpt++;

if(client.call(srv))
{
if(srv.response.values.size())
return srv.response.time_value;
else
return res;
}
else
{
if(verbose_)
std::cout << COLOR_ORANGE << "Failure to call mementar/" << name_ << COLOR_OFF << std::endl;
client = n_->serviceClient<mementar::MementarService>("mementar/" + name_, true);
if(client.call(srv))
{
if(verbose_)
std::cout << COLOR_GREEN << "Restored mementar/" << name_ << COLOR_OFF << std::endl;
if(srv.response.values.size())
return srv.response.time_value;
else
return res;
}
else
{
if(verbose_)
std::cout << COLOR_RED << "Failure of service restoration" << COLOR_OFF << std::endl;
return res;
}
}
}

inline bool callNR(mementar::MementarService& srv)
{
cpt++;
Expand Down
24 changes: 24 additions & 0 deletions include/mementar/API/mementar/clients/FactClient.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef MEMENTAR_FACTCLIENT_H
#define MEMENTAR_FACTCLIENT_H

#include "mementar/API/mementar/clients/ClientBase.h"

namespace mementar
{

class FactClient : public ClientBase
{
public:
FactClient(ros::NodeHandle* n, const std::string& name) : ClientBase(n, (name == "") ? "fact" : "fact/" + name) {}

bool exist(const std::string& fact_id);
bool isActionPart(const std::string& fact_id);
std::string getActionPart(const std::string& fact_id);
std::string getData(const std::string& fact_id);
ros::Time getStamp(const std::string& fact_id);
private:
};

} // namespace mementar

#endif // MEMENTAR_FACTCLIENT_H
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef MEMENTAR_MANAGERCLIENT_H
#define MEMENTAR_MANAGERCLIENT_H

#include "mementar/API/clients/ClientBase.h"
#include "mementar/API/mementar/clients/ClientBase.h"

namespace mementar
{
Expand Down
13 changes: 10 additions & 3 deletions include/mementar/RosInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
#include "mementar/MementarService.h"
#include "mementar/StampedString.h"

#include "ontologenius/OntologeniusStampedString.h"
#include "ontologenius/OntologeniusExplanation.h"

//#include "mementar/core/LtManagement/EpisodicTree/ArchivedLeafNode.h"
#include "mementar/core/feeder/Feeder.h"
#include "mementar/core/feeder/FeederEcho.h"
#include "mementar/core/memGraphs/Timeline.h"
#include "mementar/core/Occasions/OccasionsManager.h"
#include "mementar/core/Parametrization/Configuration.h"
Expand Down Expand Up @@ -48,10 +52,11 @@ class RosInterface
std::string directory_;
Configuration configuration_;
size_t order_;
OntologyManipulator onto_;
onto::OntologyManipulator onto_;

Timeline* timeline_;
Feeder feeder_;
FeederEcho feeder_echo_;
OccasionsManager occasions_;

std::string name_;
Expand All @@ -65,8 +70,8 @@ class RosInterface
void stampedKnowledgeCallback(const StampedString::ConstPtr& msg);
void explanationKnowledgeCallback(const MementarExplanation::ConstPtr& msg);
void actionKnowledgeCallback(const MementarAction::ConstPtr& msg);
void ontoStampedKnowledgeCallback(const StampedString::ConstPtr& msg);
void ontoExplanationKnowledgeCallback(const MementarExplanation::ConstPtr& msg);
void ontoStampedKnowledgeCallback(const ontologenius::OntologeniusStampedString::ConstPtr& msg);
void ontoExplanationKnowledgeCallback(const ontologenius::OntologeniusExplanation::ConstPtr& msg);

bool managerInstanceHandle(mementar::MementarService::Request &req,
mementar::MementarService::Response &res);
Expand Down Expand Up @@ -101,6 +106,8 @@ class RosInterface
{
return (onto_name == "") ? "/ontologenius/" + topic_name : "/ontologenius/" + topic_name + "/" + onto_name;
}

double rosTime2Float(double s, int ns);
};

} // namespace mementar
Expand Down
Loading

0 comments on commit 613896c

Please sign in to comment.