0
$\begingroup$

Rosanswers logo

I created a package called pkg_ros_basics. Then inside that, I created a folder called scripts and inside which i made a folder called config inside which I created a file using touch config_my.yaml and gedit config_my.yaml

then inside this i wrote #inside config_my.yaml

details:
          name:
                  first: "Hisenberg"
                  last: "White"
          contact:
                  address: "Random Street"
                  phone: 77777

Then when i do rosparam load config_my.yaml, It is expected that these 4 paramters from config_my.yaml is also visible but instead i get a huge error Traceback (most recent call last): File "/opt/ros/melodic/bin/rosparam", line 35, in rosparam.yamlmain() File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 622, in yamlmain _rosparam_cmd_set_load(command, argv) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 541, in _rosparam_cmd_set_load paramlist = load_file(arg, default_namespace=script_resolve_name(NAME, arg2), verbose=options.verbose) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 175, in load_file return load_str(f.read(), filename, default_namespace=default_namespace, verbose=verbose) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 189, in load_str for doc in yaml.safe_load_all(str): File "/usr/lib/python2.7/dist-packages/yaml/init.py", line 83, in load_all yield loader.get_data() File "/usr/lib/python2.7/dist-packages/yaml/constructor.py", line 33, in get_data return self.construct_document(self.get_node()) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 27, in get_node return self.compose_document() File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 55, in compose_document node = self.compose_node(None, None) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 133, in compose_mapping_node item_value = self.compose_node(node, item_key) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 64, in compose_node if self.check_event(AliasEvent): File "/usr/lib/python2.7/dist-packages/yaml/parser.py", line 98, in check_event self.current_event = self.state() File "/usr/lib/python2.7/dist-packages/yaml/parser.py", line 449, in parse_block_mapping_value if not self.check_token(KeyToken, ValueToken, BlockEndToken): File "/usr/lib/python2.7/dist-packages/yaml/scanner.py", line 116, in check_token self.fetch_more_tokens() File "/usr/lib/python2.7/dist-packages/yaml/scanner.py", line 257, in fetch_more_tokens % ch.encode('utf-8'), self.get_mark()) yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token in "", line 4, column 1: name: ^

#I request you all to help me solve this problem as i am a beginner in ROS. ThankYou!

I have created a package called pkg_ros_basics. Inside the package, I have a folder called scripts where I made another folder called config where I typed in some name-value pairs as the following

#inside config_my.yaml

   details:
   
              name:
                      first: "hisenberg"
                      last: "white"
   

               contact:
                          address: "Random street"
                          phone: 77777

Then I closed this and put rosparam load config_my.yaml and got this huge error, I would like you to guide me to solve this and help me as i am a beginner in ROS : Traceback (most recent call last): File "/opt/ros/melodic/bin/rosparam", line 35, in rosparam.yamlmain() File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 622, in yamlmain _rosparam_cmd_set_load(command, argv) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 541, in _rosparam_cmd_set_load paramlist = load_file(arg, default_namespace=script_resolve_name(NAME, arg2), verbose=options.verbose) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 175, in load_file return load_str(f.read(), filename, default_namespace=default_namespace, verbose=verbose) File "/opt/ros/melodic/lib/python2.7/dist-packages/rosparam/init.py", line 189, in load_str for doc in yaml.safe_load_all(str): File "/usr/lib/python2.7/dist-packages/yaml/init.py", line 83, in load_all yield loader.get_data() File "/usr/lib/python2.7/dist-packages/yaml/constructor.py", line 33, in get_data return self.construct_document(self.get_node()) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 27, in get_node return self.compose_document() File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 55, in compose_document node = self.compose_node(None, None) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 84, in compose_node node = self.compose_mapping_node(anchor) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 133, in compose_mapping_node item_value = self.compose_node(node, item_key) File "/usr/lib/python2.7/dist-packages/yaml/composer.py", line 64, in compose_node if self.check_event(AliasEvent): File "/usr/lib/python2.7/dist-packages/yaml/parser.py", line 98, in check_event self.current_event = self.state() File "/usr/lib/python2.7/dist-packages/yaml/parser.py", line 449, in parse_block_mapping_value if not self.check_token(KeyToken, ValueToken, BlockEndToken): File "/usr/lib/python2.7/dist-packages/yaml/scanner.py", line 116, in check_token self.fetch_more_tokens() File "/usr/lib/python2.7/dist-packages/yaml/scanner.py", line 257, in fetch_more_tokens % ch.encode('utf-8'), self.get_mark()) yaml.scanner.ScannerError: while scanning for the next token found character '\t' that cannot start any token in "", line 4, column 1: name: ^

Thank You


Originally posted by Naufal_Abubacker on ROS Answers with karma: 3 on 2021-07-04

Post score: 0


Original comments

Comment by electrophod on 2021-07-05:
PLEASE modify your question into a precise format, it's difficult to read everything. Also please format your error into inline code format by adding ``` before and after the error

Comment by Mike Scheutzow on 2021-07-05:
Are you using tabs? The tab character is not valid in the yaml syntax.

Comment by Mike Scheutzow on 2021-07-05:
P.S. Storing a phone number as an integer is going to cause you huge problems in the future.

Comment by electrophod on 2021-07-08:
@Mike Scheutzow What's the right way? Storing it as a string? Yeah I guess String makes more sense

Comment by Mike Scheutzow on 2021-07-08:
@electrophod Yes, a string is much better.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The tab character is not valid in the yaml syntax.


Originally posted by Mike Scheutzow with karma: 4903 on 2021-07-08

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by Naufal_Abubacker on 2021-07-08:
Yes sir, thank You so much for this, when i tried with space keys it worked Perfectly!!!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.