Skip to content

Commit

Permalink
added docs; corrected datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
104H committed Jun 5, 2023
1 parent 3d44135 commit 5c6e81f
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[settings]
known_third_party = cv2,flatbuffers,google,grpc,imageio,matplotlib,numpy,quaternion,rospy,seerep,sensor_msgs,setuptools,std_msgs,tf,yaml
known_third_party = cv2,flatbuffers,google,grpc,imageio,matplotlib,numpy,quaternion,rospy,seerep,sensor_msgs,setuptools,std_msgs,tf,util,util_fb,yaml
profile =black
3 changes: 3 additions & 0 deletions seerep_srv/seerep_core/include/seerep_core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ class Core
/**
* @brief Get the all labels saved in a project
*
* @param uuid of project
* @param datatypes A vector of datatypes
* @param category the category across which all labels have to be aggregated
* @return std::vector<std::string> uuid of project
*/
std::unordered_set<std::string> getAllLabels(boost::uuids::uuid uuid,
Expand Down
2 changes: 2 additions & 0 deletions seerep_srv/seerep_core/include/seerep_core/core_dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class CoreDataset
/**
* @brief Get the all labels saved in a project
*
* @param datatypes datatypes across which this is determined
* @param category the category across which all labels have to be aggregated
* @return std::vector<std::string> vector of labels
*/
std::unordered_set<std::string> getAllLabels(std::vector<seerep_core_msgs::Datatype> datatypes, std::string category);
Expand Down
2 changes: 2 additions & 0 deletions seerep_srv/seerep_core/include/seerep_core/core_project.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class CoreProject
/**
* @brief Get the all labels saved in a project
*
* @param datatypes datatypes across which this is determined
* @param category the category across which all labels have to be aggregated
* @return std::vector<std::string> vector of labels
*/
std::unordered_set<std::string> getAllLabels(std::vector<seerep_core_msgs::Datatype> datatypes, std::string category);
Expand Down
6 changes: 3 additions & 3 deletions seerep_srv/seerep_core/src/core_dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,9 @@ seerep_core_msgs::AABB CoreDataset::getSpatialBounds(std::vector<seerep_core_msg
seerep_core_msgs::AABB overallbb;

// set the minimum to minimum possible for the datatype
overallbb.max_corner().set<0>(std::numeric_limits<int64_t>::min());
overallbb.max_corner().set<1>(std::numeric_limits<int64_t>::min());
overallbb.max_corner().set<2>(std::numeric_limits<int64_t>::min());
overallbb.max_corner().set<0>(std::numeric_limits<float>::min());
overallbb.max_corner().set<1>(std::numeric_limits<float>::min());
overallbb.max_corner().set<2>(std::numeric_limits<float>::min());

// set the maximum for the maximum possible for the datatype
overallbb.min_corner().set<0>(std::numeric_limits<float>::max());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ class CoreFbCameraIntrinsics
*/
boost::uuids::uuid setData(const seerep::fb::CameraIntrinsics& cameraintrinsics);

/**
* @brief
*
* @param dt
* @return std::vector<seerep_core_msgs::Datatype>
*/

private:
/** @brief a shared pointer to the general core */
std::shared_ptr<seerep_core::Core> m_seerepCore;
Expand Down
39 changes: 16 additions & 23 deletions seerep_srv/seerep_core_fb/src/core_fb_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ flatbuffers::Offset<seerep::fb::Boundingbox> CoreFbConversion::toFb(flatbuffers:
seerep_core_msgs::AABB& aabb)
{
// center
int center_x = (aabb.min_corner().get<0>() + aabb.max_corner().get<0>()) / 2;
int center_y = (aabb.min_corner().get<1>() + aabb.max_corner().get<1>()) / 2;
int center_z = (aabb.min_corner().get<2>() + aabb.max_corner().get<2>()) / 2;
float center_x = (aabb.min_corner().get<0>() + aabb.max_corner().get<0>()) / 2;
float center_y = (aabb.min_corner().get<1>() + aabb.max_corner().get<1>()) / 2;
float center_z = (aabb.min_corner().get<2>() + aabb.max_corner().get<2>()) / 2;

// spatial extent
int se_x = (aabb.max_corner().get<0>() - aabb.min_corner().get<0>());
int se_y = (aabb.max_corner().get<1>() - aabb.min_corner().get<1>());
int se_z = (aabb.max_corner().get<2>() - aabb.min_corner().get<2>());
float se_x = (aabb.max_corner().get<0>() - aabb.min_corner().get<0>());
float se_y = (aabb.max_corner().get<1>() - aabb.min_corner().get<1>());
float se_z = (aabb.max_corner().get<2>() - aabb.min_corner().get<2>());

seerep::fb::PointBuilder centerPointBuilder(mb);
centerPointBuilder.add_x(center_x);
Expand All @@ -350,14 +350,14 @@ flatbuffers::Offset<seerep::fb::TimeInterval> CoreFbConversion::toFb(flatbuffers
seerep_core_msgs::AabbTime& timeinterval)
{
// isolate second and nano second bits from min time
uint64_t mintime = timeinterval.min_corner().get<0>();
uint32_t min_nanos = (uint32_t)mintime;
uint32_t min_seconds = (int32_t)(mintime >> 32);
int64_t mintime = timeinterval.min_corner().get<0>();
int32_t min_nanos = (uint32_t)mintime;
int32_t min_seconds = (int32_t)(mintime >> 32);

// isolate second and nano second bits from max time
uint64_t maxtime = timeinterval.max_corner().get<0>();
uint32_t max_nanos = (uint32_t)maxtime;
uint32_t max_seconds = (int32_t)(maxtime >> 32);
int64_t maxtime = timeinterval.max_corner().get<0>();
int32_t max_nanos = (uint32_t)maxtime;
int32_t max_seconds = (int32_t)(maxtime >> 32);

seerep::fb::TimestampBuilder minTimeStampBuilder(mb);
minTimeStampBuilder.add_seconds(min_seconds);
Expand Down Expand Up @@ -649,23 +649,16 @@ std::vector<seerep_core_msgs::Datatype> CoreFbConversion::fromFbDatatypeVector(c
{
std::vector<seerep_core_msgs::Datatype> dt_vector;

if (dt == seerep::fb::Datatype_Image)
if (dt == seerep::fb::Datatype_All)
{
dt_vector.push_back(seerep_core_msgs::Datatype::Image);
}
else if (dt == seerep::fb::Datatype_PointCloud)
{
dt_vector.push_back(seerep_core_msgs::Datatype::PointCloud);
}
else if (dt == seerep::fb::Datatype_Point)
{
dt_vector.push_back(seerep_core_msgs::Datatype::Point);
}
else if (dt == seerep::fb::Datatype_All)
else
{
dt_vector.push_back(seerep_core_msgs::Datatype::Image);
dt_vector.push_back(seerep_core_msgs::Datatype::PointCloud);
dt_vector.push_back(seerep_core_msgs::Datatype::Point);
seerep_core_msgs::Datatype dtCore = fromFb(dt);
dt_vector.push_back(dtCore);
}

return dt_vector;
Expand Down
24 changes: 12 additions & 12 deletions seerep_srv/seerep_core_pb/src/core_pb_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,14 @@ void CorePbConversion::toPb(const seerep_core_msgs::AabbTime& timeinterval, seer
// seerep::pb::TimeInterval ti_pb;

// isolate second and nano second bits from min time
uint64_t mintime = timeinterval.min_corner().get<0>();
uint32_t min_nanos = (uint32_t)mintime;
uint32_t min_seconds = (int32_t)(mintime >> 32);
int64_t mintime = timeinterval.min_corner().get<0>();
int32_t min_nanos = (uint32_t)mintime;
int32_t min_seconds = (int32_t)(mintime >> 32);

// isolate second and nano second bits from max time
uint64_t maxtime = timeinterval.max_corner().get<0>();
uint32_t max_nanos = (uint32_t)maxtime;
uint32_t max_seconds = (int32_t)(maxtime >> 32);
int64_t maxtime = timeinterval.max_corner().get<0>();
int32_t max_nanos = (uint32_t)maxtime;
int32_t max_seconds = (int32_t)(maxtime >> 32);

ti_pb->mutable_time_min()->set_nanos(min_nanos);
ti_pb->mutable_time_min()->set_seconds(min_seconds);
Expand All @@ -446,14 +446,14 @@ void CorePbConversion::toPb(const seerep_core_msgs::AabbTime& timeinterval, seer
void CorePbConversion::toPb(const seerep_core_msgs::AABB& aabb, seerep::pb::Boundingbox* bb_pb)
{
// center
int center_x = (aabb.min_corner().get<0>() + aabb.max_corner().get<0>()) / 2;
int center_y = (aabb.min_corner().get<1>() + aabb.max_corner().get<1>()) / 2;
int center_z = (aabb.min_corner().get<2>() + aabb.max_corner().get<2>()) / 2;
float center_x = (aabb.min_corner().get<0>() + aabb.max_corner().get<0>()) / 2;
float center_y = (aabb.min_corner().get<1>() + aabb.max_corner().get<1>()) / 2;
float center_z = (aabb.min_corner().get<2>() + aabb.max_corner().get<2>()) / 2;

// spatial extent
int se_x = (aabb.max_corner().get<0>() - aabb.min_corner().get<0>());
int se_y = (aabb.max_corner().get<1>() - aabb.min_corner().get<1>());
int se_z = (aabb.max_corner().get<2>() - aabb.min_corner().get<2>());
float se_x = (aabb.max_corner().get<0>() - aabb.min_corner().get<0>());
float se_y = (aabb.max_corner().get<1>() - aabb.min_corner().get<1>());
float se_z = (aabb.max_corner().get<2>() - aabb.min_corner().get<2>());

bb_pb->mutable_center_point()->set_x(center_x);
bb_pb->mutable_center_point()->set_y(center_y);
Expand Down
14 changes: 4 additions & 10 deletions seerep_srv/seerep_server/src/fb_meta_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ FbMetaOperations::GetOverallTimeInterval(grpc::ServerContext* context,
// levels.
std::vector<seerep_core_msgs::Datatype> dt_vector;

seerep::fb::Datatype casted_datatype = static_cast<seerep::fb::Datatype>(requestRoot->datatype());
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(casted_datatype);
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(requestRoot->datatype());

try
{
Expand Down Expand Up @@ -245,11 +244,8 @@ FbMetaOperations::GetOverallBoundingBox(grpc::ServerContext* context,
// levels.
std::vector<seerep_core_msgs::Datatype> dt_vector;

// flatbuffers::IsFieldPresent(requestRoot, seerep::fb::UuidDatatypePair::datatype);
// requestRoot->CheckField(seerep::fb::UuidDatatypePair::datatype);

seerep::fb::Datatype casted_datatype = static_cast<seerep::fb::Datatype>(requestRoot->datatype());
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(casted_datatype);
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(requestRoot->datatype());

try
{
Expand Down Expand Up @@ -307,8 +303,7 @@ grpc::Status FbMetaOperations::GetAllCategories(grpc::ServerContext* context,
// levels.
std::vector<seerep_core_msgs::Datatype> dt_vector;

seerep::fb::Datatype casted_datatype = static_cast<seerep::fb::Datatype>(requestRoot->datatype());
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(casted_datatype);
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(requestRoot->datatype());

try
{
Expand Down Expand Up @@ -378,8 +373,7 @@ FbMetaOperations::GetAllLabels(grpc::ServerContext* context,
// levels.
std::vector<seerep_core_msgs::Datatype> dt_vector;

seerep::fb::Datatype casted_datatype = static_cast<seerep::fb::Datatype>(requestRoot->UuidAndDatatype()->datatype());
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(casted_datatype);
dt_vector = seerep_core_fb::CoreFbConversion::fromFbDatatypeVector(requestRoot->UuidAndDatatype()->datatype());

try
{
Expand Down

0 comments on commit 5c6e81f

Please sign in to comment.