Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All labels/overall bounding box / overall timeinterval in project #287

Merged
merged 9 commits into from
Jun 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
protobuf implementation
104H committed Jun 2, 2023
commit e0973c31d6c6de374244f2245bcfd2e3cd4c7c6f
1 change: 0 additions & 1 deletion examples/python/ROS/ROS_publishSimplePointcloud.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@

import rospy
from sensor_msgs import point_cloud2

# PointCloud2 color cube
# https://answers.ros.org/question/289576/understanding-the-bytes-in-a-pcl2-message/
from sensor_msgs.msg import PointCloud2, PointField
6 changes: 3 additions & 3 deletions examples/python/gRPC/images/gRPC_pb_sendLabeledImage.py
Original file line number Diff line number Diff line change
@@ -16,9 +16,9 @@
from seerep.pb import image_pb2 as image
from seerep.pb import image_service_pb2_grpc as imageService
from seerep.pb import label_with_instance_pb2 as labelWithInstance
from seerep.pb import (
labels_with_instance_with_category_pb2 as labels_with_instance_with_category,
)
from seerep.pb import \
labels_with_instance_with_category_pb2 as \
labels_with_instance_with_category
from seerep.pb import meta_operations_pb2_grpc as metaOperations
from seerep.pb import projectCreation_pb2 as projectCreation
from seerep.pb import tf_service_pb2_grpc as tfService
12 changes: 6 additions & 6 deletions examples/python/gRPC/images/gRPC_pb_sendLabeledImageGrid.py
Original file line number Diff line number Diff line change
@@ -5,15 +5,15 @@

import numpy as np
from seerep.pb import boundingbox2d_labeled_pb2 as boundingbox2d_labeled
from seerep.pb import (
boundingbox2d_labeled_with_category_pb2 as boundingbox2d_labeled_with_category,
)
from seerep.pb import \
boundingbox2d_labeled_with_category_pb2 as \
boundingbox2d_labeled_with_category
from seerep.pb import image_pb2 as image
from seerep.pb import image_service_pb2_grpc as imageService
from seerep.pb import label_with_instance_pb2 as labelWithInstance
from seerep.pb import (
labels_with_instance_with_category_pb2 as labels_with_instance_with_category,
)
from seerep.pb import \
labels_with_instance_with_category_pb2 as \
labels_with_instance_with_category
from seerep.pb import meta_operations_pb2_grpc as metaOperations
from seerep.pb import projectCreation_pb2 as projectCreation
from seerep.pb import tf_service_pb2_grpc as tfService
9 changes: 1 addition & 8 deletions examples/python/gRPC/meta/gRPC_fb_getOverallBoundingBox.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import sys

import flatbuffers
from fb import Boundingbox, Datatype, TimeInterval
from fb import Boundingbox, Datatype
from fb import meta_operations_grpc_fb as metaOperations

# importing util functions. Assuming that these files are in the parent dir
@@ -56,10 +56,3 @@
+ " , "
+ str(response.PointMax().Z())
)

responseBuf = stub.GetOverallTimeInterval(bytes(buf))
response = TimeInterval.TimeInterval.GetRootAs(responseBuf)

print("Min Time (Seconds, Nanoseconds): " + str(response.TimeMin().Seconds()) + " ," + str(response.TimeMin().Nanos()))

print("Max Time (Seconds, Nanoseconds): " + str(response.TimeMax().Seconds()) + " ," + str(response.TimeMax().Nanos()))
9 changes: 5 additions & 4 deletions examples/python/gRPC/meta/gRPC_fb_getOverallTime.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
import sys

import flatbuffers
from fb import TimeInterval
from fb import Datatype, TimeInterval
from fb import meta_operations_grpc_fb as metaOperations

# importing util functions. Assuming that these files are in the parent dir
@@ -22,7 +22,7 @@


# 1. Get all projects from the server
projectuuid = util_fb.getProject(builder, channel, 'geodeticProject')
projectuuid = util_fb.getProject(builder, channel, 'LabeledImagesInGrid')

# 2. Check if the defined project exist; if not exit
if not projectuuid:
@@ -32,8 +32,9 @@
# 3. Get gRPC service object
stub = metaOperations.MetaOperationsStub(channel)

projectInfo = util_fb.createProjectInfo(builder, "name", projectuuid)
builder.Finish(projectInfo)
UuidDatatypePair = util_fb.createUuidDatatypePair(builder, projectuuid, Datatype.Datatype().Image)

builder.Finish(UuidDatatypePair)
buf = builder.Output()

responseBuf = stub.GetOverallTimeInterval(bytes(buf))
35 changes: 35 additions & 0 deletions examples/python/gRPC/meta/gRPC_pb_getOverallBound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3

import os
import sys

import datatype_pb2 as datatype
import meta_operations_pb2_grpc as metaOperations
import uuid_datatype_pair_pb2 as uuid_datatype_pair
from google.protobuf import empty_pb2

script_dir = os.path.dirname(__file__)
util_dir = os.path.join(script_dir, '..')
sys.path.append(util_dir)
import util

channel = util.get_gRPC_channel()

stub = metaOperations.MetaOperationsStub(channel)

response = stub.GetProjects(empty_pb2.Empty())

# 3. Check if we have an existing test project, if not, we stop here
projectuuid = ""
for project in response.projects:
print(project.name + " " + project.uuid + "\n")
if project.name == "LabeledImagesInGrid":
projectuuid = project.uuid

uuiddt = uuid_datatype_pair.UuidDatatypePair()
uuiddt.projectuuid = projectuuid
uuiddt.datatype = datatype.image

response = stub.GetOverallTimeInterval(uuiddt)

print(response)
1 change: 0 additions & 1 deletion examples/python/gRPC/meta/gRPC_pb_getProjects.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@

response = stub.GetProjects(empty_pb2.Empty())


print("The server has the following projects (name/uuid):")
for projectinfo in response.projects:
print("\t" + projectinfo.name + " " + projectinfo.uuid)
Original file line number Diff line number Diff line change
@@ -5,23 +5,11 @@
import numpy as np
import quaternion
import yaml
from seerep.fb import (
Boundingbox2D,
BoundingBox2DLabeled,
BoundingBox2DLabeledWithCategory,
Header,
Image,
LabelsWithCategory,
LabelWithInstance,
Point,
Point2D,
PointStamped,
Quaternion,
Timestamp,
Transform,
TransformStamped,
Vector3,
)
from seerep.fb import (Boundingbox2D, BoundingBox2DLabeled,
BoundingBox2DLabeledWithCategory, Header, Image,
LabelsWithCategory, LabelWithInstance, Point, Point2D,
PointStamped, Quaternion, Timestamp, Transform,
TransformStamped, Vector3)
from seerep.fb import image_service_grpc_fb as imageService
from seerep.fb import point_service_grpc_fb as pointService
from seerep.fb import tf_service_grpc_fb as tfService
2 changes: 1 addition & 1 deletion examples/python/gRPC/util/fb_helper.py
Original file line number Diff line number Diff line change
@@ -528,7 +528,7 @@ def createUuidDatatypePair(builder, uuid, datatype):

UuidDatatypePair.Start(builder)
UuidDatatypePair.AddProjectuuid(builder, uuidStr)
UuidDatatypePair.AddDatatypes(builder, datatype)
UuidDatatypePair.AddDatatype(builder, datatype)
return UuidDatatypePair.End(builder)


2 changes: 1 addition & 1 deletion seerep-msgs/fbs/uuid_datatype_pair.fbs
Original file line number Diff line number Diff line change
@@ -5,5 +5,5 @@ namespace seerep.fb;

table UuidDatatypePair {
projectuuid:string;
datatypes:Datatype;
datatype:Datatype;
}
11 changes: 11 additions & 0 deletions seerep-msgs/protos/datatype.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package seerep;

enum datatype
{
unknown = 0;
image = 1;
pointcloud = 2;
point = 3;
}
11 changes: 11 additions & 0 deletions seerep-msgs/protos/uuid_datatype_pair.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package seerep;

import "datatype.proto";

message UuidDatatypePair
{
string projectuuid = 1;
datatype datatype = 2;
}
1 change: 0 additions & 1 deletion seerep_com/fbs/meta_operations.fbs
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ include "project_infos.fbs";
include "projectCreation.fbs";
include "empty.fbs";
include "boundingbox.fbs";
include "datatype.fbs";
include "time_interval.fbs";
include "uuid_datatype_pair.fbs";

5 changes: 5 additions & 0 deletions seerep_com/protos/meta_operations.proto
Original file line number Diff line number Diff line change
@@ -7,9 +7,14 @@ import "google/protobuf/empty.proto";
import "project_info.proto";
import "project_infos.proto";
import "projectCreation.proto";
import "uuid_datatype_pair.proto";
import "time_interval.proto";
import "boundingbox.proto";

service MetaOperations
{
rpc CreateProject(ProjectCreation) returns (ProjectInfo);
rpc GetProjects(google.protobuf.Empty) returns (ProjectInfos);
rpc GetOverallTimeInterval(UuidDatatypePair) returns (TimeInterval);
rpc GetOverallBoundingBox(UuidDatatypePair) returns (Boundingbox);
}
2 changes: 2 additions & 0 deletions seerep_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ set(MY_PROTO_FILES
protos/boundingbox2d.proto
protos/camera_intrinsics.proto
protos/camera_intrinsics_query.proto
protos/datatype.proto
protos/frame_infos.proto
protos/frame_query.proto
protos/geodetic_coordinates.proto
@@ -60,6 +61,7 @@ set(MY_PROTO_FILES
protos/twist_with_covariance_stamped.proto
protos/twist_with_covariance.proto
protos/twist.proto
protos/uuid_datatype_pair.proto
protos/vector3_stamped.proto
protos/vector3.proto
)
13 changes: 13 additions & 0 deletions seerep_srv/seerep_core/include/seerep_core/core.h
Original file line number Diff line number Diff line change
@@ -158,8 +158,21 @@ class Core
*/
void deleteProject(boost::uuids::uuid uuid);

/**
* @brief Get the minimum and maximum time interval for a dataset
* @param uuid UUID of a dataset
* @param datatypes A vector of datatypes for which the time bound has to be computed
* @return seerep_core_msgs::AabbTime
*/
seerep_core_msgs::AabbTime getOverallTimeInterval(boost::uuids::uuid uuid,
std::vector<seerep_core_msgs::Datatype> datatypes);

/**
* @brief Get the minimum and maximum spatial bound for a dataset
* @param uuid UUID of a dataset
* @param datatypes A vector of datatypes for which the spatial bound has to be computed
* @return seerep_core_msgs::AABB
*/
seerep_core_msgs::AABB getOverallBound(boost::uuids::uuid uuid, std::vector<seerep_core_msgs::Datatype> datatypes);

private:
12 changes: 9 additions & 3 deletions seerep_srv/seerep_core/include/seerep_core/core_dataset.h
Original file line number Diff line number Diff line change
@@ -120,11 +120,17 @@ class CoreDataset
const boost::uuids::uuid& msgUuid);

/**
* @brief Get the Time Bounds object
*
* @return seerep_core_msgs::AABB
* @brief Get the minimum and maximum time interval for a dataset
* @param datatypes A vector of datatypes for which the time bound has to be computed
* @return seerep_core_msgs::AabbTime
*/
seerep_core_msgs::AabbTime getTimeBounds(std::vector<seerep_core_msgs::Datatype> datatypes);

/**
* @brief Get the minimum and maximum spatial bound for a dataset
* @param datatypes A vector of datatypes for which the spatial bound has to be computed
* @return seerep_core_msgs::AABB
*/
seerep_core_msgs::AABB getSpatialBounds(std::vector<seerep_core_msgs::Datatype> datatypes);

private:
Original file line number Diff line number Diff line change
@@ -22,6 +22,10 @@ class PbMetaOperations final : public seerep::pb::MetaOperations::Service
seerep::pb::ProjectInfo* response);
grpc::Status GetProjects(grpc::ServerContext* context, const google::protobuf::Empty* request,
seerep::pb::ProjectInfos* response);
grpc::Status GetOverallTimeInterval(grpc::ServerContext* context, const seerep::UuidDatatypePair* request,
seerep::TimeInterval* response);
grpc::Status GetOverallBoundingBox(grpc::ServerContext* context, const seerep::UuidDatatypePair* request,
seerep::Boundingbox* response);

private:
std::shared_ptr<seerep_core::Core> seerepCore;
Loading