Skip to content

Feature request: expose current robot pose in Simple Commander API #5412

@Arseni1919

Description

@Arseni1919

🚀 Feature description

It would be awesome to add a current_pose method or property to Simple Commander API that returns the robot’s current (x, y, yaw) pose from /amcl_pose or localization source. Right now, you have to subscribe or parse topic output manually, which is a bit annoying.

Having a simple function like nav.current_pose would make scripting, debugging, and Jupyter notebooks way easier and cleaner! 🎉

💡 Implementation considerations

A straightforward way is to grab one message from /amcl_pose using something like:

import subprocess, yaml, math

def get_amcl_pose():
    output = subprocess.check_output(["ros2", "topic", "echo", "--once", "/amcl_pose"], text=True)
    msg = list(yaml.safe_load_all(output))[0]
    p = msg['pose']['pose']['position']
    o = msg['pose']['pose']['orientation']
    yaw = math.atan2(2*(o['w']*o['z'] + o['x']*o['y']), 1 - 2*(o['y']**2 + o['z']**2))
    return p['x'], p['y'], yaw

Pros:

Super useful for quick checks and interactive use.

Easy to add, low overhead.

Could optionally support config for topic or TF fallback.

Thanks for considering! 🙌
And thanks chatgpt for helping me writing this request with my broken English.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions