-
Notifications
You must be signed in to change notification settings - Fork 11
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
Search and Grouping Feature #39
base: noetic-devel
Are you sure you want to change the base?
Changes from all commits
b5d3c9a
87bc527
e55c56e
40ef38f
2e2d275
904fabe
82c41b0
5fdde70
8130de6
e114d8b
9ae8bea
5a71d73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice idea! But there is no UI (yet) to set the group, right? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,17 +379,17 @@ def __init__(self, editor, element, style): | |
self.old_element = element | ||
|
||
if style == "plane": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 169 potentially should copy the group, too? (+duplicate button) |
||
self.new_element = Object_Plane(element.name, element.position, element.orientation, element.parent) | ||
self.new_element = Object_Plane(element.name, element.position, element.orientation, element.parent, group=element.group) | ||
elif style == "cube": | ||
self.new_element = Object_Cube(element.name, element.position, element.orientation, element.parent) | ||
self.new_element = Object_Cube(element.name, element.position, element.orientation, element.parent, group=element.group) | ||
elif style == "sphere": | ||
self.new_element = Object_Sphere(element.name, element.position, element.orientation, element.parent) | ||
self.new_element = Object_Sphere(element.name, element.position, element.orientation, element.parent, group=element.group) | ||
elif style == "axis": | ||
self.new_element = Object_Axis(element.name, element.position, element.orientation, element.parent) | ||
self.new_element = Object_Axis(element.name, element.position, element.orientation, element.parent, group=element.group) | ||
elif style == "mesh": | ||
self.new_element = Object_Mesh(element.name, element.position, element.orientation, element.parent) | ||
self.new_element = Object_Mesh(element.name, element.position, element.orientation, element.parent, group=element.group) | ||
else: | ||
self.new_element = Frame(element.name, element.position, element.orientation, element.parent) | ||
self.new_element = Frame(element.name, element.position, element.orientation, element.parent, group=element.group) | ||
|
||
if editor.active_frame is element: | ||
self.was_active = True | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ def __init__(self): | |
self.namespace = "frame_editor" | ||
self.full_file_path = None | ||
self.hz = 200 | ||
self.filter_style = "hide" | ||
|
||
|
||
def get_file_name(self): | ||
|
@@ -98,7 +99,7 @@ def tf_dict(): | |
if isinstance(d, dict): | ||
return d | ||
else: | ||
rospy.logwarn('Got invalid yaml from tf2: '+y) | ||
rospy.logwarn('Got invalid yaml from tf2: {}'.format(y)) | ||
return {} | ||
|
||
@staticmethod | ||
|
@@ -119,7 +120,7 @@ def iter_frames(self, include_temp=True): | |
## PRINT ## | ||
## | ||
def print_all(self): | ||
print("> Printing all frames") | ||
rospy.loginfo("> Printing all frames") | ||
|
||
for frame in self.frames: | ||
frame.print_all() | ||
|
@@ -129,7 +130,7 @@ def print_all(self): | |
## | ||
def load_file(self, file_name): | ||
if file_name: | ||
print("> Loading file") | ||
rospy.loginfo("> Loading file") | ||
data = rosparam.load_file(file_name, self.namespace)[0][0] | ||
self.load_data(data) | ||
else: | ||
|
@@ -143,7 +144,7 @@ def load_file(self, file_name): | |
|
||
def load_params(self, namespace): | ||
if not rosparam.list_params(namespace): | ||
print("> No data to load") | ||
rospy.logwarn("> No data to load") | ||
else: | ||
data = rosparam.get_param(namespace) | ||
self.load_data(data) | ||
|
@@ -161,6 +162,11 @@ def load_data(self, data): | |
style = frame["style"] | ||
else: | ||
style = "none" | ||
|
||
if "group" in frame: | ||
group = frame["group"] | ||
else: | ||
group = "" | ||
|
||
if "data" in frame: | ||
dat = frame["data"] | ||
|
@@ -190,13 +196,13 @@ def load_data(self, data): | |
f = Object_Mesh(name, position, orientation, frame["parent"], dat["package"], dat["path"], dat["scale"]) | ||
f.set_color(color) | ||
else: | ||
f = Frame(name, position, orientation, frame["parent"]) | ||
f = Frame(name, position, orientation, frame["parent"], group=group) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should also add group to the SetFrame Service, shouldn't we? |
||
|
||
self.command(Command_AddElement(self, f)) | ||
|
||
self.undo_stack.endMacro() | ||
|
||
print("> Loading done") | ||
rospy.loginfo("> Loading done") | ||
|
||
def save_file(self, filename): | ||
|
||
|
@@ -222,6 +228,7 @@ def save_file(self, filename): | |
f["orientation"] = o | ||
|
||
f["style"] = frame.style | ||
f["group"] = frame.group | ||
|
||
if frame.style == "plane": | ||
f["data"] = { "length": frame.length, "width":frame.width, "color": frame.color } | ||
|
@@ -245,14 +252,14 @@ def save_file(self, filename): | |
|
||
## To parameter server | ||
rospy.set_param(self.namespace, data) | ||
print(rospy.get_param(self.namespace)) | ||
rospy.loginfo(rospy.get_param(self.namespace)) | ||
|
||
## Dump param to file | ||
if filename == '': | ||
filename = self.full_file_path | ||
print("Saving to file {}".format(filename)) | ||
rospy.loginfo("Saving to file {}".format(filename)) | ||
rosparam.dump_params(filename, self.namespace) | ||
print("Saving done") | ||
rospy.loginfo("Saving done") | ||
|
||
self.full_file_path = filename | ||
return True | ||
|
@@ -277,7 +284,7 @@ def update_file_format(self, frame): | |
QtWidgets.QMessageBox.Yes) | ||
|
||
if reply == QtWidgets.QMessageBox.Yes: | ||
print("Saving: package: {} + relative path: {}".format(rospackage, rel_path)) | ||
rospy.loginfo("Saving: package: {} + relative path: {}".format(rospackage, rel_path)) | ||
frame.package = rospackage | ||
frame.path = rel_path | ||
return | ||
|
@@ -289,7 +296,7 @@ def update_file_format(self, frame): | |
pass | ||
|
||
def run(self): | ||
print("> Going for some spins") | ||
rospy.loginfo("> Going for some spins") | ||
rate = rospy.Rate(self.hz) # hz | ||
while not rospy.is_shutdown(): | ||
self.broadcast() | ||
|
@@ -309,39 +316,51 @@ def parse_args(self, argv): | |
dest="file", | ||
help="Load a file at startup. [rospack filepath/file]") | ||
parser.add_argument("-r", "--rate", type=int) | ||
|
||
parser.add_argument( | ||
"--filter_style", | ||
type=str, | ||
choices=["grey", "hide"], | ||
help="Choose the filter style: 'grey' or 'hide' (default: 'hide')", | ||
default="hide", | ||
) | ||
|
||
args, unknowns = parser.parse_known_args(argv) | ||
print('arguments: {}'.format(args)) | ||
rospy.loginfo('arguments: {}'.format(args)) | ||
if unknowns: | ||
print('unknown parameters found: {}'.format(unknowns)) | ||
rospy.logwarn('unknown parameters found: {}'.format(unknowns)) | ||
|
||
if args.rate: | ||
self.hz = args.rate | ||
else: | ||
self.hz = 100 | ||
|
||
if args.filter_style: | ||
self.filter_style = args.filter_style | ||
|
||
## Load file ## | ||
if args.file: | ||
arg_path = args.file[0].split() | ||
if len(arg_path) == 1: | ||
#load file | ||
filename = arg_path[0] | ||
print("Loading {}".format(filename)) | ||
rospy.loginfo("Loading {}".format(filename)) | ||
success = self.load_file(str(filename)) | ||
elif len(arg_path) == 2: | ||
#load rospack | ||
rospack = rospkg.RosPack() | ||
filename = os.path.join(rospack.get_path(arg_path[0]), arg_path[1]) | ||
print("Loading {}".format(filename)) | ||
rospy.loginfo("Loading {}".format(filename)) | ||
success = self.load_file(str(filename)) | ||
else: | ||
print("Load argument not understood! --load {}".format(arg_path)) | ||
print("Please use --load 'myRosPackage pathInMyPackage/myYaml.yaml'") | ||
print("or use --load 'fullPathToMyYaml.yaml'") | ||
rospy.logwarn("Load argument not understood! --load {}".format(arg_path)) | ||
rospy.logwarn("Please use --load 'myRosPackage pathInMyPackage/myYaml.yaml'") | ||
rospy.logwarn("or use --load 'fullPathToMyYaml.yaml'") | ||
success = None | ||
|
||
if success: | ||
return filename | ||
elif success == False: | ||
print("ERROR LOADING FILE") | ||
rospy.logerr("ERROR LOADING FILE") | ||
return '' | ||
|
||
def init_views(self): | ||
|
@@ -361,7 +380,7 @@ def init_views(self): | |
editor.parse_args(sys.argv[1:]) | ||
editor.init_views() | ||
|
||
print("Frame editor ready!") | ||
rospy.loginfo("Frame editor ready!") | ||
editor.run() | ||
|
||
# eof |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! The grouping feature could also be mentioned, what do you think?