3 from ros
import rosparam
6 from resource_retriever
import get
14 return "roslaunch all of the nodes" 18 cmd = os.path.relpath(sys.argv[0], os.getcwd())
if cmd
is None else cmd
19 return "{0} [-h|--help] [--version]".format(cmd)
28 self.
data = yaml.load(base_file)
32 f.write(yaml.dump(self.
data, default_flow_style=
False))
34 def add_display(self, name, class_name, topic=None, color=None, fields={}, enabled=True):
35 d = {
'Name': name,
'Class': class_name,
'Enabled': enabled}
39 d[
'Color'] =
'%d; %d; %d' % color
41 self.
data[
'Visualization Manager'][
'Displays'].append(d)
43 def add_model(self, parameter='robot_description', tf_prefix=None):
44 fields = {
'Robot Description': parameter}
46 fields[
'TF Prefix'] = tf_prefix
47 self.
add_display(tf_prefix[1:],
'rviz/RobotModel', fields=fields)
50 if __name__==
"__main__":
55 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
57 parser.add_argument(
'-o',
'--option', type=str, default=
'eof', help=
'dont care')
58 parsed_known_args, unknown_args = parser.parse_known_args(sys.argv[1:])
59 print(parsed_known_args)
62 l = rosparam.list_params(
'')
65 v = rosparam.get_param(p)
66 if type(v)
is str
and len(v) > 10000:
70 r.add_model(m, m[0:-18])
71 temp = tempfile.NamedTemporaryFile()
74 args = [
'rosrun',
'rviz',
'rviz',
'-d', temp.name]
75 usp = subprocess.call(args)
77 except KeyboardInterrupt:
78 print(
"Interrupted by user, shutting down...")
def add_display(self, name, class_name, topic=None, color=None, fields={}, enabled=True)
def __init__(self, base_file=None)
def add_model(self, parameter='robot_description', tf_prefix=None)