How to write a listener that uses other frames positions?

asked 2021-11-14 18:13:15 -0500

jasr gravatar image

updated 2021-11-15 19:50:37 -0500

Hi,

I'm trying to calculate the center of mass of a robot, for this I added some frames representing the position of each link center of mass, for example, I did it like this in the launch file for each link:

def generate_launch_description():    return LaunchDescription([
      Node(
        package='tf2_ros',
        executable='static_transform_publisher',
        arguments = ['0', '0', '0.5', '0', '0', '0', 'robot-base', 'robot-base_CoM']
    ),   ])

Now I want to add another frame that represents the center of mass of the whole robot, I need to create a script that gets the coordinates of each link an multiply them by their respective mass to compute the total center of mass, so any idea on how to do this? I think it is something related to the writing a listener or adding a frame tutorials, but I don't understand completely how to do this. Anyhow, appreciate any kind of guidance.

Thanks.

edit retag flag offensive close merge delete