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

Overall information about a project #278

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
108 changes: 108 additions & 0 deletions examples/python/gRPC/meta/gRPC_fb_getOverallBound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#!/usr/bin/env python3

import os
import sys

import flatbuffers
from seerep.fb import Boundingbox, Categories, Datatype, Labels, TimeInterval
from seerep.fb import meta_operations_grpc_fb as metaOperations

# importing util functions. Assuming that these files are in the parent dir
# examples/python/gRPC/util.py
# examples/python/gRPC/util_fb.py
script_dir = os.path.dirname(__file__)
util_dir = os.path.join(script_dir, '..')
sys.path.append(util_dir)
import util
import util_fb

builder = flatbuffers.Builder(1024)
# Default server is localhost !
channel = util.get_gRPC_channel()


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

# 2. Check if the defined project exist; if not exit
if not projectuuid:
print("Project Not Found")
exit()

# 3. Get gRPC service object
stub = metaOperations.MetaOperationsStub(channel)

UuidDatatypePair = util_fb.createUuidDatatypePair(builder, projectuuid, Datatype.Datatype().All)

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

###
# Fetching overall spatial bound

responseBuf = stub.GetOverallBoundingBox(bytes(buf))
response = Boundingbox.Boundingbox.GetRootAs(responseBuf)

print(
"Center Point (X, Y, Z): "
+ str(response.CenterPoint().X())
+ " , "
+ str(response.CenterPoint().Y())
+ " , "
+ str(response.CenterPoint().Z())
)

print(
"Spatial Things Point (X, Y, Z): "
+ str(response.SpatialExtent().X())
+ " , "
+ str(response.SpatialExtent().Y())
+ " , "
+ str(response.SpatialExtent().Z())
)

###
# Fetching overall temporal bound

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

print(
" Minimum Time "
+ str(response.TimeMin().Seconds())
+ "s and "
+ str(response.TimeMin().Nanos())
+ "ms\n"
+ " Maximum Time "
+ str(response.TimeMax().Seconds())
+ "s and "
+ str(response.TimeMax().Nanos())
+ "ms"
)

###
# Fetching all category names

responseBuf = stub.GetAllCategories(bytes(buf))
response = Categories.Categories.GetRootAs(responseBuf)

print("Saved Category names are:")
for idx in range(response.CategoriesLength()):
print(response.Categories(idx).decode())

###
# Fetching all label names for a given category

builder = flatbuffers.Builder(1024)

UuidDatatypeWithCategory = util_fb.createUuidDatatypeWithCategory(builder, projectuuid, Datatype.Datatype().Image, "3")

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

responseBuf = stub.GetAllLabels(bytes(buf))
response = Labels.Labels.GetRootAs(responseBuf)

print("Saved Label names are:")
for idx in range(response.LabelsLength()):
print(response.Labels(idx).decode())
49 changes: 49 additions & 0 deletions examples/python/gRPC/meta/gRPC_pb_getOverallBound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3

import os
import sys

import seerep.pb.datatype_pb2 as datatype
import seerep.pb.meta_operations_pb2_grpc as metaOperations
import seerep.pb.uuid_datatype_pair_pb2 as uuid_datatype_pair
import seerep.pb.uuid_datatype_with_category_pb2 as uuid_datatype_with_category
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 == "testproject":
projectuuid = project.uuid

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

response = stub.GetOverallTimeInterval(uuiddt)
print(response)

response = stub.GetOverallBoundingBox(uuiddt)
print(response)

response = stub.GetAllCategories(uuiddt)
print(response)

uuiddt_category = uuid_datatype_with_category.UuidDatatypeWithCategory()
uuiddt_category.category = "3"
uuiddt_category.uuid_with_datatype.projectuuid = projectuuid
uuiddt_category.uuid_with_datatype.datatype = datatype.all

response = stub.GetAllLabels(uuiddt_category)
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
Expand Up @@ -17,7 +17,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)
32 changes: 32 additions & 0 deletions examples/python/gRPC/util_fb.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
TimeInterval,
Timestamp,
TransformStampedQuery,
UuidDatatypePair,
UuidDatatypeWithCategory,
)
from seerep.fb import meta_operations_grpc_fb as metaOperations

Expand Down Expand Up @@ -521,3 +523,33 @@ def createCameraIntrinsicsQuery(builder, ci_uuid, project_uuid):
CameraIntrinsicsQuery.AddUuidProject(builder, project_uuid_str)

return CameraIntrinsicsQuery.End(builder)


def createUuidDatatypePair(builder, uuid, datatype):
uuidStr = builder.CreateString(uuid)

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


def createUuidDatatypeWithCategory(builder, uuid, datatype, category):
categoryStr = builder.CreateString(category)

UuidDatatypePair = createUuidDatatypePair(builder, uuid, datatype)

UuidDatatypeWithCategory.Start(builder)
UuidDatatypeWithCategory.AddCategory(builder, categoryStr)
UuidDatatypeWithCategory.AddUuidAndDatatype(builder, UuidDatatypePair)
return UuidDatatypeWithCategory.End(builder)


def createProjectInfo(builder, name, uuid):
nameStr = builder.CreateString(name)
uuidStr = builder.CreateString(uuid)

ProjectInfo.Start(builder)
ProjectInfo.AddName(builder, nameStr)
ProjectInfo.AddUuid(builder, uuidStr)
return ProjectInfo.End(builder)
10 changes: 10 additions & 0 deletions seerep_com/fbs/meta_operations.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ include "project_info.fbs";
include "project_infos.fbs";
include "projectCreation.fbs";
include "empty.fbs";
include "boundingbox.fbs";
include "time_interval.fbs";
include "uuid_datatype_pair.fbs";
include "uuid_datatype_with_category.fbs";
include "labels.fbs";
include "categories.fbs";

namespace seerep.fb;

Expand All @@ -11,4 +17,8 @@ rpc_service MetaOperations {
GetProjects(seerep.fb.Empty):seerep.fb.ProjectInfos;
LoadProjects(seerep.fb.Empty):seerep.fb.Empty;
DeleteProject(seerep.fb.ProjectInfo):seerep.fb.Empty;
GetOverallTimeInterval(seerep.fb.UuidDatatypePair):seerep.fb.TimeInterval;
GetOverallBoundingBox(seerep.fb.UuidDatatypePair):seerep.fb.Boundingbox;
GetAllCategories(seerep.fb.UuidDatatypePair):seerep.fb.Categories;
GetAllLabels(seerep.fb.UuidDatatypeWithCategory):seerep.fb.Labels;
}
10 changes: 10 additions & 0 deletions seerep_com/protos/meta_operations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ 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";
import "labels.proto";
import "categories.proto";
import "uuid_datatype_with_category.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);
rpc GetAllCategories(UuidDatatypePair) returns (Categories);
rpc GetAllLabels(UuidDatatypeWithCategory) returns (Labels);
}
9 changes: 9 additions & 0 deletions seerep_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ set(MY_PROTO_FILES
protos/boundingbox2d_labeled_with_category.proto
protos/boundingbox2d_stamped.proto
protos/boundingbox2d.proto
protos/categories.proto
protos/datatype.proto
protos/frame_infos.proto
protos/frame_query.proto
protos/geodetic_coordinates.proto
protos/header.proto
protos/image.proto
protos/label_with_instance.proto
protos/label.proto
protos/labels.proto
protos/labels_with_category.proto
protos/labels_with_instance_with_category.proto
protos/point_cloud_2.proto
Expand Down Expand Up @@ -57,6 +60,8 @@ set(MY_PROTO_FILES
protos/twist_with_covariance_stamped.proto
protos/twist_with_covariance.proto
protos/twist.proto
protos/uuid_datatype_with_category.proto
protos/uuid_datatype_pair.proto
protos/vector3_stamped.proto
protos/vector3.proto
)
Expand All @@ -74,6 +79,7 @@ set(MY_FBS_FILES
fbs/boundingboxes2d_labeled_stamped.fbs
fbs/camera_intrinsics.fbs
fbs/camera_intrinsics_query.fbs
fbs/categories.fbs
fbs/datatype.fbs
fbs/empty.fbs
fbs/frame_infos.fbs
Expand All @@ -83,6 +89,7 @@ set(MY_FBS_FILES
fbs/image.fbs
fbs/label_with_instance.fbs
fbs/label.fbs
fbs/labels.fbs
fbs/labels_with_category.fbs
fbs/labels_with_instance_with_category.fbs
fbs/point_cloud_2.fbs
Expand Down Expand Up @@ -115,6 +122,8 @@ set(MY_FBS_FILES
fbs/union_map_entry.fbs
fbs/uuids_per_project.fbs
fbs/uuids_project_pair.fbs
fbs/uuid_datatype_with_category.fbs
fbs/uuid_datatype_pair.fbs
fbs/vector3_stamped.fbs
fbs/vector3.fbs
)
Expand Down
3 changes: 2 additions & 1 deletion seerep_msgs/core/datatype.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ enum class Datatype
Unknown, // default value
Image,
PointCloud,
Point
Point,
All
};

} /* namespace seerep_core_msgs */
Expand Down
6 changes: 6 additions & 0 deletions seerep_msgs/fbs/categories.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

namespace seerep.fb;

table Categories {
categories:[string];
}
4 changes: 2 additions & 2 deletions seerep_msgs/fbs/datatype.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace seerep.fb;

enum Datatype:byte {
Unknown=0,
Image,
PointCloud,
Point
Point,
All
}
6 changes: 6 additions & 0 deletions seerep_msgs/fbs/labels.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

namespace seerep.fb;

table Labels {
labels:[string];
}
9 changes: 9 additions & 0 deletions seerep_msgs/fbs/uuid_datatype_pair.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

include "datatype.fbs";

namespace seerep.fb;

table UuidDatatypePair {
projectuuid:string;
datatype:Datatype;
}
9 changes: 9 additions & 0 deletions seerep_msgs/fbs/uuid_datatype_with_category.fbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

include "uuid_datatype_pair.fbs";

namespace seerep.fb;

table UuidDatatypeWithCategory {
category:string;
UuidAndDatatype:UuidDatatypePair;
}
8 changes: 8 additions & 0 deletions seerep_msgs/protos/categories.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

package seerep.pb;

message Categories
{
repeated string categories = 1;
}
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
{
image = 0;
pointcloud = 1;
point = 2;
all = 3;
}
8 changes: 8 additions & 0 deletions seerep_msgs/protos/labels.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

package seerep.pb;

message Labels
{
repeated string labels = 1;
}
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.pb;

import "datatype.proto";

message UuidDatatypePair
{
string projectuuid = 1;
datatype datatype = 2;
}
Loading