Skip to content

Commit

Permalink
Fix bugs (#178)
Browse files Browse the repository at this point in the history
* changes to how RSProcessManage is constructed (no more init function)

* a bit of cleanup in the code

* fix #169 and #135
  • Loading branch information
bbferka committed Jul 3, 2019
1 parent 28403c2 commit ff6ca75
Show file tree
Hide file tree
Showing 20 changed files with 214 additions and 199 deletions.
2 changes: 1 addition & 1 deletion robosherlock/config/config_data_loader_utest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ width=640
height=480
matrix=525,0,319.75,0,525,239.75,0,0,1
; k1, k2, p1, p2, k3
distortion=0, 0, 0, 0, 0
distortion=0,0,0,0,0
depth_scaling_factor = 1

[tf]
Expand Down
2 changes: 1 addition & 1 deletion robosherlock/descriptors/analysis_engines/u_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fixedflow:
- PCLDescriptorExtractor
- StorageWriter
ae:
name : u_test
name: u_test
CollectionReader:
camera_config_files : ['config_data_loader_utest.ini']
StorageWriter:
Expand Down
51 changes: 26 additions & 25 deletions robosherlock/src/core/src/conversion/ros_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* limitations under the License.
*/


// ROS
#include <sensor_msgs/CameraInfo.h>
#include <std_msgs/Header.h>
Expand All @@ -30,9 +29,8 @@ namespace rs
{
namespace conversion
{

template<>
void from(const uima::FeatureStructure &fs, std_msgs::Header &output)
template <>
void from(const uima::FeatureStructure& fs, std_msgs::Header& output)
{
rs::Header h(fs);

Expand All @@ -41,8 +39,8 @@ void from(const uima::FeatureStructure &fs, std_msgs::Header &output)
output.seq = h.seq();
}

template<>
uima::FeatureStructure to(uima::CAS &cas, const std_msgs::Header &input)
template <>
uima::FeatureStructure to(uima::CAS& cas, const std_msgs::Header& input)
{
rs::Header h = rs::create<rs::Header>(cas);

Expand All @@ -53,8 +51,8 @@ uima::FeatureStructure to(uima::CAS &cas, const std_msgs::Header &input)
return h;
}

template<>
void from(const uima::FeatureStructure &fs, sensor_msgs::CameraInfo::_roi_type &output)
template <>
void from(const uima::FeatureStructure& fs, sensor_msgs::CameraInfo::_roi_type& output)
{
rs::ROI roi(fs);

Expand All @@ -65,8 +63,8 @@ void from(const uima::FeatureStructure &fs, sensor_msgs::CameraInfo::_roi_type &
output.do_rectify = (uint8_t)roi.do_rectify.get();
}

template<>
uima::FeatureStructure to(uima::CAS &cas, const sensor_msgs::CameraInfo::_roi_type &input)
template <>
uima::FeatureStructure to(uima::CAS& cas, const sensor_msgs::CameraInfo::_roi_type& input)
{
rs::ROI roi = rs::create<rs::ROI>(cas);

Expand All @@ -79,8 +77,8 @@ uima::FeatureStructure to(uima::CAS &cas, const sensor_msgs::CameraInfo::_roi_ty
return roi;
}

template<>
void from(const uima::FeatureStructure &fs, sensor_msgs::CameraInfo &output)
template <>
void from(const uima::FeatureStructure& fs, sensor_msgs::CameraInfo& output)
{
std::vector<double> vec;
std::string tmp;
Expand All @@ -91,30 +89,33 @@ void from(const uima::FeatureStructure &fs, sensor_msgs::CameraInfo &output)

tmp = cam.distortion_model.get();
output.distortion_model.resize(tmp.size());
for(int i = 0; i < tmp.size(); ++i)
for (int i = 0; i < tmp.size(); ++i)
{
output.distortion_model[i] = tmp[i];
}

output.height = (uint32_t)cam.height.get();
output.width = (uint32_t)cam.width.get();

output.D = cam.d();
if (cam.d.has())
{
output.D = cam.d();
}

vec = cam.r.get();
for(int i = 0; i < output.R.size() && i < vec.size(); ++i)
for (int i = 0; i < output.R.size() && i < vec.size(); ++i)
{
output.R[i] = vec[i];
}

vec = cam.p.get();
for(int i = 0; i < output.P.size() && i < vec.size(); ++i)
for (int i = 0; i < output.P.size() && i < vec.size(); ++i)
{
output.P[i] = vec[i];
}

vec = cam.k.get();
for(int i = 0; i < output.K.size() && i < vec.size(); ++i)
for (int i = 0; i < output.K.size() && i < vec.size(); ++i)
{
output.K[i] = vec[i];
}
Expand All @@ -125,8 +126,8 @@ void from(const uima::FeatureStructure &fs, sensor_msgs::CameraInfo &output)
from(cam.roi.get(), output.roi);
}

template<>
uima::FeatureStructure to(uima::CAS &cas, const sensor_msgs::CameraInfo &input)
template <>
uima::FeatureStructure to(uima::CAS& cas, const sensor_msgs::CameraInfo& input)
{
std::vector<double> vec;
std::string tmp;
Expand All @@ -136,7 +137,7 @@ uima::FeatureStructure to(uima::CAS &cas, const sensor_msgs::CameraInfo &input)
cam.header.set(to(cas, input.header));

tmp.resize(input.distortion_model.size());
for(int i = 0; i < tmp.size(); ++i)
for (int i = 0; i < tmp.size(); ++i)
{
tmp[i] = input.distortion_model[i];
}
Expand All @@ -148,21 +149,21 @@ uima::FeatureStructure to(uima::CAS &cas, const sensor_msgs::CameraInfo &input)
cam.d.set(input.D);

vec.resize(input.R.size());
for(int i = 0; i < input.R.size(); ++i)
for (int i = 0; i < input.R.size(); ++i)
{
vec[i] = input.R[i];
}
cam.r.set(vec);

vec.resize(input.P.size());
for(int i = 0; i < input.P.size(); ++i)
for (int i = 0; i < input.P.size(); ++i)
{
vec[i] = input.P[i];
}
cam.p.set(vec);

vec.resize(input.K.size());
for(int i = 0; i < input.K.size(); ++i)
for (int i = 0; i < input.K.size(); ++i)
{
vec[i] = input.K[i];
}
Expand All @@ -176,5 +177,5 @@ uima::FeatureStructure to(uima::CAS &cas, const sensor_msgs::CameraInfo &input)
return cam;
}

}
}
} // namespace conversion
} // namespace rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,15 @@ class RSAggregateAnalysisEngine : public uima::internal::AggregateEngine

/**
* @brief setParallel
* @param[in] f flag for parallel execution or not
* @param[in] f flag for parallel execution or not; if set to true initialize the pipeline planner
*/
inline void setParallel(bool f)
{
if(f)
{
initParallelPipelineManager();
parallelPlanner.print();
}
parallel_ = f;
}

Expand All @@ -205,26 +210,28 @@ class RSAggregateAnalysisEngine : public uima::internal::AggregateEngine
delegate_annotators_ = this->iv_annotatorMgr.iv_vecEntries;
}

/**
* @brief setUseIdentityResolutio set true if you want identity resolution
* to be asserted at the end of every flow
* @param useIDres
*/
void setUseIdentityResolution(const bool useIDres)
{
use_identity_resolution_ = useIDres;
}

/**
* @brief getAAEName
* @return return the name of the AAE
*/
std::string getAAEName()
{
return name_;
}

/*set the next order of AEs to be executed*/
/**
* @brief setNextPipeline
* @param l
* @brief resetCas reset the CAS deleting everything stored in it;
*/
void setNextPipeline(std::vector<std::string> next_pipeline_order)
{
this->next_pipeline_order = next_pipeline_order;
}

inline void resetCas()
{
cas_->reset();
Expand All @@ -237,58 +244,85 @@ class RSAggregateAnalysisEngine : public uima::internal::AggregateEngine
currentOrderingIndices = orderingIndices;
}


/**
* @brief getCas
* @return returns a pointer to the CAS;
*/
uima::CAS *getCas()
{
return cas_;
}

inline bool isInDelegateList(std::string d)
/**
* @brief isInDelegateList
* @param delegate_name name of the delegate AE as defined in the meta file
* @return true if found
*/
inline bool isInDelegateList(std::string delegate_name)
{
if(std::find(delegates_.begin(), delegates_.end(), d) != std::end(delegates_))
if(std::find(delegates_.begin(), delegates_.end(), delegate_name) != std::end(delegates_))
return true;
else
return false;
}

/**
* @brief overwriteParam overwrite a parameter defined in the descriptor of an AE.
* @param ae_name The name of the ae
* @param param_name name of the parameter
* @param param the new value for the parameter
*/
template < class T >
void overwriteParam(const std::string &annotName, const std::string &paramName, T const &param)
void overwriteParam(const std::string &ae_name, const std::string &param_name, T const &param)
{
uima::AnnotatorContext &annotContext = getAnnotatorContext();
UnicodeString ucs_delegate(annotName.c_str());
UnicodeString ucs_delegate(ae_name.c_str());
uima::AnnotatorContext *cr_context = annotContext.getDelegate(ucs_delegate);
cr_context->assignValue(UnicodeString(paramName.c_str()), param);
cr_context->assignValue(UnicodeString(param_name.c_str()), param);
}

/**
* @brief overwriteParam overwrite an array parameter defined in the descriptor of an AE.
* @param ae_name The name of the ae
* @param param_name name of the parameter
* @param param the new value for the parameter
*/
template < class T >
void overwriteParam(const std::string &annotName, const std::string &paramName, const std::vector<T> &param)
void overwriteParam(const std::string &ae_name, const std::string &param_name, const std::vector<T> &param)
{
uima::AnnotatorContext &annotContext = getAnnotatorContext();
UnicodeString ucs_delegate(annotName.c_str());
UnicodeString ucs_delegate(ae_name.c_str());
uima::AnnotatorContext *cr_context = annotContext.getDelegate(ucs_delegate);
cr_context->assignValue(UnicodeString(paramName.c_str()), param);
cr_context->assignValue(UnicodeString(param_name.c_str()), param);
}

//Ease case for the user
void overwriteParam(const std::string &annotName, const std::string &paramName, std::string const &param)
/**
* @brief overwriteParam specific case for strings because of uima working with UnicodeStrings
* @param ae_ame
* @param param_name
* @param param
*/
void overwriteParam(const std::string &ae_name, const std::string &param_name, std::string const &param)
{
uima::AnnotatorContext &annotContext = getAnnotatorContext();
UnicodeString ucs_delegate(annotName.c_str());
UnicodeString ucs_delegate(ae_name.c_str());
uima::AnnotatorContext *cr_context = annotContext.getDelegate(ucs_delegate);
cr_context->assignValue(UnicodeString(paramName.c_str()), (UnicodeString) param.c_str());
cr_context->assignValue(UnicodeString(param_name.c_str()), (UnicodeString) param.c_str());
}

void overwriteParam(const std::string &annotName, const std::string &paramName, const std::vector<std::string> &param)
void overwriteParam(const std::string &ae_name, const std::string &param_name, const std::vector<std::string> &param)
{
uima::AnnotatorContext &annotContext = getAnnotatorContext();
UnicodeString ucs_delegate(annotName.c_str());
UnicodeString ucs_delegate(ae_name.c_str());
//Convert the std::string vector into UnicodeString and then overwrite with that variable
std::vector<UnicodeString> conversionString;
for(std::string i : param)
{
conversionString.push_back(UnicodeString(i.c_str()));
}
uima::AnnotatorContext *cr_context = annotContext.getDelegate(ucs_delegate);
cr_context->assignValue(UnicodeString(paramName.c_str()), conversionString);
cr_context->assignValue(UnicodeString(param_name.c_str()), conversionString);
}

// this variable is for fail safe mechanism to fall back to linear execution if query orderings fail
Expand All @@ -313,7 +347,7 @@ class RSAggregateAnalysisEngine : public uima::internal::AggregateEngine
//store different AE orders
std::vector<std::string> default_pipeline_annotators_;
std::vector<std::string> delegates_;
std::vector<std::string> next_pipeline_order;


uima::internal::AnnotatorManager::TyAnnotatorEntries delegate_annotators_;

Expand All @@ -334,8 +368,7 @@ namespace rs

std::string convertAnnotatorYamlToXML(std::string annotatorName, std::map<std::string, rs::AnnotatorCapabilities> &delegate_capabilities);

RSAggregateAnalysisEngine *createRSAggregateAnalysisEngine(const std::string &file, bool parallel = false,
bool pervasive = false, std::vector<std::string> contPipeline = {});
RSAggregateAnalysisEngine *createRSAggregateAnalysisEngine(const std::string &file, bool parallel = false);

//RSAggregateAnalysisEngine *createParallelAnalysisEngine(icu::UnicodeString const &aeFile,
// uima::ErrorInfo errInfo);
Expand Down
Loading

0 comments on commit ff6ca75

Please sign in to comment.