Tag Archives: ROS learning

TF Error: Error: TF_DENORMALIZED_QUATERNION [How to Solve]

1. Problem

HDL locationing Error:

Error: TF_DENORMALIZED_QUATERNION: Ignoring transform for
child_frame_id “odom” from authority “unknown_publisher” because of an
invalid quaternion in the transform (0.0 0.0 0.983641 0.122190)

2. Solution

From the error report can be seen, the tip is a quadratic number of problems, the key is to say that there is no normalization, the release of TF has strict requirements, the quadratic number must be normalized, that is, xyzw squared and equal to 1, if not equal to the error reported above, a simple calculation, the above error tip quadratic number is: (0.0 0.0 0.983641 0.122190), that is, 0.98364 1 2 + 0.12219 0 2 = 0.982480012981 0.983641^2 + 0.122190 ^2 = 0.9824800129810.983641^2 + 0.122190^2 = 0.982480012981, obviously not equal to 1, so there will be the above problem, the solution is also simple, before the output Do a normalization process can be.

         Eigen::Quaterniond quatern = {0.0 0.0 0.983641 0.122190}; // w x y z
         quatern.normalize();
         odom_trans.transform.rotation.x = quatern.x();
         odom_trans.transform.rotation.y = quatern.y();
         odom_trans.transform.rotation.z = quatern.z();
         odom_trans.transform.rotation.w = quatern.w();
         odom_trans.header.stamp = stamp;
         odom_trans.header.frame_id = "map";
         odom_trans.child_frame_id = odom_child_frame_id;
         tf_broadcaster.sendTransform(odom_trans);

[Solved] rqt_graph Skipped loading plugin with error & Format: “dot“ not recognized

rqt_graph run error:

[ERROR] [1637910144.803564743]: Skipped loading plugin with error: XML Document '/opt/ros/melodic/share/rqt_virtual_joy/plugin.xml' has no Root Element. This likely means the XML is malformed or missing..
RosPluginProvider._parse_plugin_xml() plugin file "/opt/ros/melodic/share/rqt_virtual_joy/plugin.xml" in package "rqt_virtual_joy" not found
RosPluginProvider._parse_plugin_xml() plugin file "/opt/ros/melodic/share/rqt_virtual_joy/plugin.xml" in package "rqt_virtual_joy" not found
['dot', '-Tdot', '/tmp/tmpVMQLCN'] return code: 1
stdout, stderr:

Format: "dot" not recognized. Use one of:
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_graph/ros_graph.py", line 289, in _refresh_rosgraph
self._update_graph_view(self._generate_dotcode())
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_graph/ros_graph.py", line 324, in _generate_dotcode
hide_dynamic_reconfigure=hide_dynamic_reconfigure)
File "/opt/ros/melodic/lib/python2.7/dist-packages/rqt_graph/dotcode.py", line 914, in generate_dotcode
dotcode = dotcode_factory.create_dot(dotgraph)
File "/opt/ros/melodic/lib/python2.7/dist-packages/qt_dotgraph/pydotfactory.py", line 175, in create_dot
dot = graph.create_dot()
File "/usr/lib/python2.7/dist-packages/pydot.py", line 1681, in <lambda>
self.create(format=f, prog=prog))
File "/usr/lib/python2.7/dist-packages/pydot.py", line 1900, in create
assert p.returncode == 0, p.returncode
AssertionError: 1
[1]    22100 abort (core dumped)  rqt_graph

The above message contains two errors.
One is that the plugin file is missing. Solution.
Create a new file plugin.xml in the /opt/ros/melodic/share/rqt_virtual_joy/ path and write the contents of the file.

<library path="src">
  <class name="My Plugin" type="rqt_virtual_joy.virtual_joy_module.MyPlugin" base_class_type="rqt_gui_py::Plugin">
    <description>
      An example Python GUI plugin to create a great user interface.
    </description>
    <qtgui>

      <group>
        <label>Robot Tools</label>
      </group>
      <!-- <group>
        <label>Subgroup</label>
      </group> -->

      <label>Virtual Joystick</label>
      <icon type="file">resource/input-gaming.png</icon>
      <statustip>Great user interface to provide real value.</statustip>
    </qtgui>
  </class>
</library>

Save and exit to fix problem 1;

The second problem is dot format recognition. Execute the command:

sudo dot -c

How to Solve Turtle_tf Error in ROS

Software configuration

Operating system: Ubuntu 16.04
ROS version: kinetic
Python version: python2.7, python3.5, python3.8

Function package and routine

Refer to “ROS robot development and practice” section 4.2.3 using turtle simulator routine turtle_ TF, execute the command:

roslaunch turtle_tf turtle_tf_demo.launch

report errors

Traceback (most recent call last):
   File "/opt/ros/kinetic/lib/turtle_tf/turtle_tf_broadcaster.py", line 37, in <module>
        import tf   
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
        from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>     
        from tf2_py import *   
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>     
        from ._tf2 import * ImportError: dynamic module does not define module export function (PyInit__tf2) Traceback (most recent call last):   
   File "/opt/ros/kinetic/lib/turtle_tf/turtle_tf_broadcaster.py", line 37, in <module>     
        import tf   
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>    
        from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException   
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>     
        from tf2_py import *  
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>     
        from ._tf2 import * ImportError: dynamic module does not define module export function (PyInit__tf2) 
Traceback (most recent call last):   
   File "/opt/ros/kinetic/lib/turtle_tf/turtle_tf_listener.py", line 37, in <module>     
        import tf   
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>     
        from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException  
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>     
        from tf2_py import *   
   File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>     
        from ._tf2 import * ImportError: dynamic module does not define module export function (PyInit__tf2) 

find by hard and thorough search

At the beginning, try the methods mentioned on the Internet, such as modifying the python version and soft link, and input on the terminal:

python --version

After getting python2.7, the running routine still reports an error, so I want to find the reason according to the error

Find the error report file from the first line of the error report:

/opt/ros/kinetic/lib/turtle_tf/turtle_tf_broadcaster.py

Turn on Turbo_ tf_ After editing the broadcast.py file, it is found that the first line of the file states:

#!/usr/bin/env python

Input in the terminal:

/usr/bin/env python

It shows the python version pointed by the python variable in the environment variable, which is different from the routine’s requirement of python2.7.

Problem solving: modify Python in environment variables

//Modify the priority of different python versions
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

//Manual priority selection
sudo update-alternatives --config python

*Remember to input “/ usr/bin/env Python” in the terminal to check whether the modification is successful.

After the modification is successful, run the routine again to see two little turtles. The little turtle at the bottom moves towards the little turtle at the center.

Solution: the solution to the wrong connection of rosdep init or rosdep update

If the prompt is error: unable to process source https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/xxxxx Such errors, while ensuring that their machine can be on the premise of Baidu, at this time may be due to raw.githubusercontent.com The website has been blocked.
The solution is to modify the hosts file and add the IP address of the website

#Open the hosts file
sudo gedit /etc/hosts
#Add at the end of the file
151.101.84.133 raw.githubusercontent.com
#Save and quit and try again

Try again

ROS problem: vidioc_ S_ FMT error 16, Device or resource busy

Problem description
When using the camera under ROS, input:

$ roslaunch usb_cam usb_cam-test.launch

This command is to turn on the camera, and the error is as follows:

Namely: [ERROR] [1574317261.767618042]: VIDIOC_S_FMT ERROR 16, Device or resource busy
Replug the camera, still report this error.
Analysis: First check all the camera equipment, the instructions are as follows:

$ ls /dev/video*
/dev/video1

As you can see, the result is /dev/video1, and the default installation on ROS is usB_CAM with /dev/video0 started, so it’s not hard to imagine changing the launch file that launches the camera.
Solution: Enter the following two instructions:

$ cd /opt/ros/kinetic/share/usb_cam/launch
$ sudo gedit usb_cam-test.launch

The launch file is shown in the figure below:

Change the /dev/video0 that appears in line 3 to /dev/video1 (the number after the video here depends on the result of the previous query), save and exit. So you can use the camera properly. Problem solved.
Supplementary place
1. There is a detail here. After the above steps are modified, $roslaunch USb_CAM USb_cam_test.launch is required to use the camera normally.
2. After restarting the computer, the need for /dev/video will generally revert to 0, so the usB_cam-test.launch file needs to be modified again. Change the part of /dev/video to /dev/video0.