Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request FrameAligned view, as in ROS1 #1320

Open
jowaibel opened this issue Jan 1, 2025 · 3 comments
Open

Request FrameAligned view, as in ROS1 #1320

jowaibel opened this issue Jan 1, 2025 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@jowaibel
Copy link

jowaibel commented Jan 1, 2025

In ROS1's rviz, there used to be a FrameAligned view that allowed to align the view exactly with a target frame. This is crucial for, e.g., a flight simulator where the user wants to see the view of the aircraft moving in 6 degrees of freedom. (In this case, the target frame would be the body frame.)

ThirdPersonFollower would work for a robot that moves on the horizontal plane only but not for an aircraft moving and rotating in 3 dimensions.

I cannot understand why this feature has not been ported and nobody asked for it since rviz2 came out. It would highly appreciate if it could be added to rviz2. Thank you very much!

@christophebedard christophebedard added the help wanted Extra attention is needed label Jan 9, 2025
@christophebedard
Copy link
Member

It was simply never ported. PRs are welcome 😄

@jowaibel
Copy link
Author

Hi @christophebedard, I have not worked with the rviz source code before. If you could sketch what needs to be done to do the work and point me to the right fields, I will see what I can do.

@christophebedard
Copy link
Member

I've only looked at the RViz source code once myself, but any time is a good time to learn!

The plugin is defined in an XML file:

  • In ROS 1, the rviz/FrameAligned plugin is defined here: https://github.com/ros-visualization/rviz/blob/250c0c2875758953f98f3b1982d11b55f527b295/plugin_description.xml#L294-L298
  • In ROS 2, it would be added somewhere here:
    <!-- View Controller plugins -->
    <class
    name="rviz_default_plugins/FPS"
    type="rviz_default_plugins::view_controllers::FPSViewController"
    base_class_type="rviz_common::ViewController"
    >
    <description>
    Control the camera like in a First Person Shooter game: drag left to look left, etc.
    </description>
    </class>
    <class
    name="rviz_default_plugins/Orbit"
    type="rviz_default_plugins::view_controllers::OrbitViewController"
    base_class_type="rviz_common::ViewController"
    >
    <description>
    Makes it easy to move around a given point in space, looking at it from any angle.
    </description>
    </class>
    <class
    name="rviz_default_plugins/TopDownOrtho"
    type="rviz_default_plugins::view_controllers::FixedOrientationOrthoViewController"
    base_class_type="rviz_common::ViewController"
    >
    <description>
    Orthographic projection, seen from the top.
    </description>
    </class>
    <class
    name="rviz_default_plugins/XYOrbit"
    type="rviz_default_plugins::view_controllers::XYOrbitViewController"
    base_class_type="rviz_common::ViewController"
    >
    <description>
    Makes it easy to move around a given point on the XY plane, looking at it from any angle.
    </description>
    </class>
    <class
    name="rviz_default_plugins/ThirdPersonFollower"
    type="rviz_default_plugins::view_controllers::ThirdPersonFollowerViewController"
    base_class_type="rviz_common::ViewController">
    <description>
    Follow a target frame and turn the viewing direction with the yaw of the target frame.
    </description>
    </class>

You can see that each plugin definition in the XML file has a type, which is essentially a class name. Each plugin class is registered in its .cpp file:

Now, you can see that the ROS 1 FrameViewController class extends the FPSViewController class: https://github.com/ros-visualization/rviz/blob/250c0c2875758953f98f3b1982d11b55f527b295/src/rviz/default_plugin/view_controllers/frame_view_controller.h#L42. This FPSViewController class is itself a plugin, and it also exists in ROS 2, which I linked to above.

Therefore, I believe you just need to create a FrameViewController class that extends the existing FPSViewController class and essentially copy the logic from the ROS 1 implementation of FrameViewController. Looking at the ROS 1 FPSViewController class and the ROS 2 FPSViewController class, there are some differences, so you'll most likely have to adapt some things when porting FrameViewController to ROS 2.

Let me know if something isn't clear or if you have any questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants