Problems with render tags:Cannot load command parameter [tags]: no such command

69 views
Skip to first unread message

vamy wu

unread,
Oct 22, 2022, 3:02:09 AM10/22/22
to tagslam
Hi Dr. Bernd Pfrommer,

When I tried to render the tags in rviz, I ran the launch file as you recommended
"roslaunch tagslam_viz visualize_tags.launch tag_id_file:=$HOME/.ros/poses.yaml", 

but unfortunately I got the following error. 
Snipaste_2022-10-22_14-51-54.pngFor this launch file, my understanding is to execute make_tags.py to complete the urdf conversion.

 I know it's probably a silly little problem, I'm a beginner in ros and slam and I've looked up a lot of information but can't solve it, so I'm sorry to bother you.The corresponding log file is below.
Thanks in advance!!!
roslaunch-wut-15641.log
roslaunch-wut-15415.log

Bernd Pfrommer

unread,
Oct 22, 2022, 6:17:56 AM10/22/22
to tagslam
From the error message it looks like it cannot find the file to make the tags:

/home/wut/tagslam_root/src/tagslam_viz/src/make_tags.py

Can you check that the file is there? It should be, it is part of the source tree.
Have you moved your workspace after compiling it? If yes then removing the "build" and "devel" folders and recompiling usually helps.

vamy wu

unread,
Oct 23, 2022, 3:03:25 AM10/23/22
to tagslam
Hi Dr. Bernd Pfrommer,

Thanks for the reply. I first consulted my path where the make_tags file exists, as shown in pic1, and just in case, I changed its permissions to 777.
Secondly, I first removed the original compilation results ("build" and "level") using catkin clear. The tagslam_root workspace was recompiled. The result is shown in Pic2.
Thirdly, I checked the environment variables of the ros package and the results are shown in Pic3.
Finally, I reran the launch file for tagslam's visual tags, but badly the results remained the same, as in Pic4.
I have attached the log file and the corresponding launch file and the make_tags file. In fact, I just cloned it from your repository without changing it.

Best wishes,
Vamy
attachment.zip

Bernd Pfrommer

unread,
Oct 23, 2022, 4:10:12 AM10/23/22
to tagslam
Can you run this command:

ls -la /home/wut/tagslam_root/src/tagslam_viz/src/make_tags.py

What does it say? Does this file exist? Because the error message says very clearly that this file does not exist. It could also be that you have no read permissions to that directory.
I tested launching the script in my workspace and it works.

It may also be a good idea to remove the opencv installation in /usr/local/ from your path before compiling. Not sure what the consequences of these warning messages will be. They should not cause the problem with the launch though, so that's a separate issue.

vamy wu

unread,
Oct 23, 2022, 5:18:31 AM10/23/22
to tagslam
Hi Dr. Bernd Pfrommer,

I ran the command you mentioned and got the following result.
ls_result.png
I actually changed the permissions of this py file to 777 before that, and I just did sudo again. But unfortunately the result is still the same as the first two times.This is a really strange problem.

Ismael Gimenez

unread,
Oct 26, 2022, 7:05:14 AM10/26/22
to tagslam
Hi, i had the same problem and i think i managed to solve it by editing the make_tags.py. I only had to add a 3 to first line so it calls python3 that i have installed instead of the other and it executes.
Before:
#!/usr/bin/python
#
# script to generate tag urdf from yaml file

import yaml
import argparse


def tags_to_urdf(tags, mesh_dir='package://tagslam_viz/tags', tag_fam='36_11', global_link='map', robot_name='tags', tag_thick=0.005):
    print "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
    print "<robot name=\"%s\">" % robot_name
    print "<link name=\"%s\"/>" % global_link
    for t in tags:
        sz = float(t['size'])
        tid = int(t['id'])
        print " <link name=\"tag_%d\">" % tid
        print "  <visual>"
        print "   <origin rpy=\"0 0 0\" xyz=\"0 0 -%f\"/>" % (sz * tag_thick)
        print "     <geometry>"
        print "       <mesh filename=\"%s/tag%s_%05d.dae\" scale=\"%f %f %f\"/>" % (
            mesh_dir, tag_fam, int(t['id']), sz, sz, sz)
        print "     </geometry>"
        print "  </visual>"
        print " </link>"
        print " <joint name=\"tag_%d_to_world\" type=\"fixed\">" % tid
        print "   <parent link=\"%s\"/>" % global_link
        print "   <child link=\"tag_%d\"/>" % tid
        print "   <origin xyz=\"0 0 0\" rpy=\"0 0 0\"/>"
        print "   </joint>"
    print "</robot>"


def find_tags(d):
    all = []
    if type(d) is list:  # it's a list (maybe bodies, must dig deeper)
        for l in d:
            all = all + find_tags(l)  # recursion!
    elif type(d) is dict:  # for dictionary, search for 'tags' field
        for k, v in d.items():
            if k == 'tags' and type(v) is list:
                for t in v:  # found what we are looking for!
                    all = all + [{'id': t['id'], 'size': t['size']}]
            else:
                all = all + find_tags(v)  # recursion!
    return all


def read_yaml(filename):
    with open(filename, 'r') as y:
        try:
            return yaml.load(y)
        except yaml.YAMLError as e:
            print(e)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='make tag urdf from yaml file.')
    parser.add_argument('--file',  action='store',
                        required=True, help='yaml input file')
    parser.add_argument('--mesh_dir', action='store',
                        required=True, help='location of mesh files')
    parser.add_argument('--family', action='store', default="36_11",
                        help='tag family, e.g. 36_11')
    args = parser.parse_args()
    y = read_yaml(args.file)
    tags = find_tags(y)
    tags_to_urdf(tags, mesh_dir=args.mesh_dir, tag_fam=args.family)

After: 
#!/usr/bin/python3
#
# script to generate tag urdf from yaml file

import yaml
import argparse


def tags_to_urdf(tags, mesh_dir='package://tagslam_viz/tags', tag_fam='36_11', global_link='map', robot_name='tags', tag_thick=0.005):
    print("<?xml version=\"1.0\" encoding=\"utf-8\"?>")
    print("<robot name=\"%s\">" % robot_name)
    print("<link name=\"%s\"/>" % global_link)
    for t in tags:
        sz = float(t['size'])
        tid = int(t['id'])
        print(" <link name=\"tag_%d\">" % tid)
        print("  <visual>")
        print("   <origin rpy=\"0 0 0\" xyz=\"0 0 -%f\"/>" % (sz * tag_thick))
        print("     <geometry>")
        print("       <mesh filename=\"%s/tag%s_%05d.dae\" scale=\"%f %f %f\"/>" % (
            mesh_dir, tag_fam, int(t['id']), sz, sz, sz))
        print("     </geometry>")
        print("  </visual>")
        print(" </link>")
        print(" <joint name=\"tag_%d_to_world\" type=\"fixed\">" % tid)
        print("   <parent link=\"%s\"/>" % global_link)
        print("   <child link=\"tag_%d\"/>" % tid)
        print("   <origin xyz=\"0 0 0\" rpy=\"0 0 0\"/>")
        print("   </joint>")
    print("</robot>")


def find_tags(d):
    all = []
    if type(d) is list:  # it's a list (maybe bodies, must dig deeper)
        for l in d:
            all = all + find_tags(l)  # recursion!
    elif type(d) is dict:  # for dictionary, search for 'tags' field
        for k, v in d.items():
            if k == 'tags' and type(v) is list:
                for t in v:  # found what we are looking for!
                    all = all + [{'id': t['id'], 'size': t['size']}]
            else:
                all = all + find_tags(v)  # recursion!
    return all


def read_yaml(filename):
    with open(filename, 'r') as y:
        try:
            return yaml.load(y)
        except yaml.YAMLError as e:
            print(e)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='make tag urdf from yaml file.')
    parser.add_argument('--file',  action='store',
                        required=True, help='yaml input file')
    parser.add_argument('--mesh_dir', action='store',
                        required=True, help='location of mesh files')
    parser.add_argument('--family', action='store', default="36_11",
                        help='tag family, e.g. 36_11')
    args = parser.parse_args()
    y = read_yaml(args.file)
    tags = find_tags(y)
    tags_to_urdf(tags, mesh_dir=args.mesh_dir, tag_fam=args.family)

Ismael Gimenez

unread,
Oct 26, 2022, 7:09:43 AM10/26/22
to tagslam
I forgot to say i had to add parentheses to the prints too.
But to confirm if it is executing correctly i would need to know if the next output on console is correct, i dont have a robot or camera connected yet, i am trying to follow the documentation tutorials first:
... logging to /.ros/log/f364d90c-5451-11ed-95bb-1f248f389e4f/logname.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

/tagslam_root/src/tagslam_viz/src/make_tags.py:51: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  return yaml.load(y)
started roslaunch server http://VirtualBox:35687/

SUMMARY
========

PARAMETERS
 * /rosdistro: noetic
 * /rosversion: 1.15.14
 * /tags: <?xml version="1....

NODES

ROS_MASTER_URI=http://localhost:11311

No processes to monitor
shutting down processing monitor...
... shutting down processing monitor complete

Thank you in advance Bernd.

Bernd Pfrommer

unread,
Oct 27, 2022, 9:46:45 AM10/27/22
to tagslam
OK, thanks for pitching in here. It works for me, wonder why. Will look into it.

The error message about the yaml loader being deprecated can be ignored. The rest of the output looks good.
 I'll try to fix the python3 and yaml loader messages...

vamy wu

unread,
Nov 14, 2022, 2:26:29 AM11/14/22
to tagslam
Thank you all for your replies, I have put this on hold for the last month for some reason. After reading igime's description I have solved the problem accordingly. As I have python 2.7 and anaconda environment in my ubuntu by default. So I first switched python versions and then installed the appropriate yaml module to solve the problem. As a reminder, the name of the yaml module in python 2.7 is PyYAML, but if you switch to conda first and install the yaml module in conda, you will have no problem.
Reply all
Reply to author
Forward
0 new messages