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

Update rs_launch.py #2764

Conversation

hyunseok-yang
Copy link
Contributor

add namespace launch argument

@hyunseok-yang
Copy link
Contributor Author

I've edited a commit.
latest version of changes is working correctly

command

 ros2 launch realsense2_camera rs_launch.py namespace:=my_ns camera_name:=front_cam

topic list

/my_ns/front_cam/color/camera_info
/my_ns/front_cam/color/image_raw
/my_ns/front_cam/color/image_raw/compressed
/my_ns/front_cam/color/image_raw/compressedDepth
/my_ns/front_cam/color/image_raw/theora
/my_ns/front_cam/color/metadata
/my_ns/front_cam/depth/camera_info
/my_ns/front_cam/depth/image_rect_raw
/my_ns/front_cam/depth/image_rect_raw/compressed
/my_ns/front_cam/depth/image_rect_raw/compressedDepth
/my_ns/front_cam/depth/image_rect_raw/theora
/my_ns/front_cam/depth/metadata
/my_ns/front_cam/extrinsics/depth_to_color
/my_ns/front_cam/imu

command

 ros2 launch realsense2_camera rs_launch.py 

topic list

/camera/color/camera_info
/camera/color/image_raw
/camera/color/image_raw/compressed
/camera/color/image_raw/compressedDepth
/camera/color/image_raw/theora
/camera/color/metadata
/camera/depth/camera_info
/camera/depth/image_rect_raw
/camera/depth/image_rect_raw/compressed
/camera/depth/image_rect_raw/compressedDepth
/camera/depth/image_rect_raw/theora
/camera/depth/metadata
/camera/extrinsics/depth_to_color
/camera/imu

@SamerKhshiboun
Copy link
Collaborator

I also recommend adding this parameter to the Node parameters, so when run "ros2 param list" you will see this parameter along with all the nodes parameter, like camera_name.
Take a look on _camera_name parameter inside parameters.cpp and base_realsense_node.h, and define a "_camera_namespace" parameter to be linked with "camera_namespace" from the rs_launch.py file.

Copy link
Collaborator

@SamerKhshiboun SamerKhshiboun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, please fix and update the PR

@@ -22,6 +22,7 @@


configurable_parameters = [{'name': 'camera_name', 'default': 'camera', 'description': 'camera unique name'},
{'name': 'namespace', 'default': '', 'description': 'namespace for camera'},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to surprise current users if they pull from this branch and build again.
Most of them used to see /camera/camera when launching our node, so I would prefer to set the default value in the namespace to "camera", to keep this behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it is better to name this parameter camera_namespace to make it more clean for users that it defines a namespace for the camera.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure let's go with camera_namespace

@hyunseok-yang
Copy link
Contributor Author

@SamerKhshiboun
I rebased ros2-development branch, and fixed what you mentioned.
Please check latest one.
:)

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 1, 2023

So final one is right one I think

namespace should be (LaunchConfiguration("camera_namespace"), "/", LaunchConfiguration('camera_name' + param_name_suffix)),

`namespace does not suffix.

The format what I expected shall be this.

...
/<namespace>/<camera-name>/color/blahblah
/<namespace>/<camera-name>/depth/blahblah
...

or

...
/<namespace>/<camera-name><suffix:1>/color/blahblah
/<namespace>/<camera-name><suffix:1>/depth/blahblah
....
/<namespace>/<camera-name><suffix:2>/color/blahblah
/<namespace>/<camera-name><suffix:2>/depth/blahblah
...

@Arun-Prasad-V
Copy link
Contributor

So final one is right one I think

namespace should be (LaunchConfiguration("camera_namespace"), "/", LaunchConfiguration('camera_name' + param_name_suffix)),

`namespace does not suffix.

The format what I expected shall be this.

...
/<namespace>/<camera-name>/color/blahblah
/<namespace>/<camera-name>/depth/blahblah
...

or

...
/<namespace>/<camera-name><suffix:1>/color/blahblah
/<namespace>/<camera-name><suffix:1>/depth/blahblah
....
/<namespace>/<camera-name><suffix:2>/color/blahblah
/<namespace>/<camera-name><suffix:2>/depth/blahblah
...

Hi @hyunseok-yang ,
In case of multiple cameras connected, the param_name_suffix variable helps differentiating the launch params of each sensors.
When rs_muti_camera_launch.py is launched,

  • camera_namespace1 should be used for 1st camera's namespace
  • camera_namespace2 should be used for 2nd camera's namespace

So, could you update the namespace as follows?
(LaunchConfiguration("camera_namespace" + param_name_suffix), "/", LaunchConfiguration('camera_name' + param_name_suffix)),

@hyunseok-yang
Copy link
Contributor Author

So final one is right one I think
namespace should be (LaunchConfiguration("camera_namespace"), "/", LaunchConfiguration('camera_name' + param_name_suffix)),
`namespace does not suffix.
The format what I expected shall be this.

...
/<namespace>/<camera-name>/color/blahblah
/<namespace>/<camera-name>/depth/blahblah
...

or

...
/<namespace>/<camera-name><suffix:1>/color/blahblah
/<namespace>/<camera-name><suffix:1>/depth/blahblah
....
/<namespace>/<camera-name><suffix:2>/color/blahblah
/<namespace>/<camera-name><suffix:2>/depth/blahblah
...

Hi @hyunseok-yang , In case of multiple cameras connected, the param_name_suffix variable helps differentiating the launch params of each sensors. When rs_muti_camera_launch.py is launched,

  • camera_namespace1 should be used for 1st camera's namespace
  • camera_namespace2 should be used for 2nd camera's namespace

So, could you update the namespace as follows? (LaunchConfiguration("camera_namespace" + param_name_suffix), "/", LaunchConfiguration('camera_name' + param_name_suffix)),

Like you mentioned, in case of multiple cameras are connected, multiple camera could be separated by only param_name_suffix for camera_name.

I understood intention of param_name_suffic in rs_multi_camera_launch.py but just in camera name. Not for namespace.

As I told above, what I expected on topic list is like below.
For example, there is two robot with namespace robot1 and robot2 and each has two-d435 camera.
Topics would be like here

/robot1/cam1/color/blahblah
/robot1/cam1/depth/blahblah
/robot1/cam2/color/blahblah
/robot1/cam2/depth/blahblah

/robot2/cam1/color/blahblah
/robot2/cam1/depth/blahblah
/robot2/cam2/color/blahblah
/robot2/cam2/depth/blahblah

However if the suffix attached after namespace

/robot11/cam1/color/blahblah
/robot11/cam1/depth/blahblah
/robot12/cam2/color/blahblah
/robot12/cam2/depth/blahblah

How can I separate the multi-robot scenaro to distinguish cameras for each robot?

You mentioned that _param_name_suffixvariable helps differentiating_. And alreadyparam_name_suffix` after camera_name helped to differentiate each cameras.

Could you explain more specific scenario?

@SamerKhshiboun
Copy link
Collaborator

SamerKhshiboun commented Aug 1, 2023

Hi @hyunseok-yang

1- We agree we need our suffix to distinguish between two nodes parameters when using rs_multi_camera_launch.py
2- I tested this updated code, and still I see a bug, because I think I was right on my comments above, when I said we don't need to append "camera_namespace" to "camera_name" manually
ROS should do that in the launch mechanism, without our manual strings appending.
If you run your code, with this command:
ros2 launch realsense2_camera rs_launch.py camera_namespace:="camera_dummy_namespace" camera_name:="camera_dummy_name"

You will get this when listing the nodes in anther terminal:

~/ros2_humble $ ros2 node list
/camera_dummy_namespace/camera_dummy_name/camera_dummy_name

And this is wrong.

The solution for this is to do the following:

                namespace=(LaunchConfiguration('camera_namespace' + param_name_suffix)),
                name=(LaunchConfiguration('camera_name' + param_name_suffix)),

And ROS will append the namespace to the camera name, then we will get:

administrator@vtglnx54 ~/ros2_humble $ ros2 node list
/camera_dummy_namespace/camera_dummy_name

@SamerKhshiboun
Copy link
Collaborator

Hi @hyunseok-yang,
Sorry I did not noticed your comments, since I was writing my own.

Do you want both camera nodes to be under the same namespace ?

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 1, 2023

Hi @hyunseok-yang

1- We agree we need our suffix to distinguish between two nodes parameters when using rs_multi_camera_launch.py 2- I tested this updated code, and still I see a bug, because I think I was right on my comments above, when I said we don't need to append "camera_namespace" to "camera_name" manually ROS should do that in the launch mechanism, without our manual strings appending. If you run your code, with this command: ros2 launch realsense2_camera rs_launch.py camera_namespace:="camera_dummy_namespace" camera_name:="camera_dummy_name"

You will get this when listing the nodes in anther terminal:

~/ros2_humble $ ros2 node list
/camera_dummy_namespace/camera_dummy_name/camera_dummy_name

That's correct.

When I command this.

os2 launch realsense2_camera rs_launch.py align_depth.enable:=true rgb_camera.profile:=640x480x6 depth_module.profile:=640x480x6 camera_namespace:=test camera_name:=cam1

I got this.

/rosout
/test/cam1/aligned_depth_to_color/camera_info
/test/cam1/aligned_depth_to_color/image_raw
/test/cam1/aligned_depth_to_color/image_raw/compressed
/test/cam1/aligned_depth_to_color/image_raw/compressedDepth
/test/cam1/aligned_depth_to_color/image_raw/theora
/test/cam1/color/camera_info
/test/cam1/color/image_raw
/test/cam1/color/image_raw/compressed
/test/cam1/color/image_raw/compressedDepth
/test/cam1/color/image_raw/theora
/test/cam1/color/metadata
/test/cam1/depth/camera_info
/test/cam1/depth/image_rect_raw
/test/cam1/depth/image_rect_raw/compressed
/test/cam1/depth/image_rect_raw/compressedDepth
/test/cam1/depth/image_rect_raw/theora
/test/cam1/depth/metadata
/test/cam1/extrinsics/depth_to_color
/test/cam1/extrinsics/depth_to_depth
/test/cam1/imu

And this is wrong.

The solution for this is to do the following:

                namespace=(LaunchConfiguration('camera_namespace' + param_name_suffix)),
                name=(LaunchConfiguration('camera_name' + param_name_suffix)),

And ROS will append the namespace to the camera name, then we will get:

administrator@vtglnx54 ~/ros2_humble $ ros2 node list
/camera_dummy_namespace/camera_dummy_name

If I do this, only I got these topics without camera name.

/test/aligned_depth_to_color/camera_info
/test/aligned_depth_to_color/image_raw
/test/aligned_depth_to_color/image_raw/compressed
/test/aligned_depth_to_color/image_raw/compressedDepth
/test/aligned_depth_to_color/image_raw/theora
/test/color/camera_info
/test/color/image_raw
/test/color/image_raw/compressed
/test/color/image_raw/compressedDepth
/test/color/image_raw/theora
/test/color/metadata
/test/depth/camera_info
/test/depth/image_rect_raw
/test/depth/image_rect_raw/compressed
/test/depth/image_rect_raw/compressedDepth
/test/depth/image_rect_raw/theora
/test/depth/metadata
/test/extrinsics/depth_to_color
/test/extrinsics/depth_to_depth

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 1, 2023

Hi @hyunseok-yang, Sorry I did not noticed your comments, since I was writing my own.

No problem :)

Do you want both camera nodes to be under the same namespace ?

Yes
That what we expecting.

It's why I insisting this launch script.

return [
            launch_ros.actions.Node(
                package='realsense2_camera',
                namespace=(LaunchConfiguration("camera_namespace"), "/", LaunchConfiguration('camera_name' + param_name_suffix)),
                name=LaunchConfiguration('camera_name' + param_name_suffix),
                executable='realsense2_camera_node',
                parameters=[params
                            , params_from_file
                            ],
                output='screen',
                arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level' + param_name_suffix)],
                emulate_tty=True,
                )
        ]

@SamerKhshiboun
Copy link
Collaborator

SamerKhshiboun commented Aug 1, 2023

Hi @hyunseok-yang, Sorry I did not noticed your comments, since I was writing my own.

No problem :)

Do you want both camera nodes to be under the same namespace ?

Yes That what we expecting.

It's why I insisting this launch script.

return [
            launch_ros.actions.Node(
                package='realsense2_camera',
                namespace=(LaunchConfiguration("camera_namespace"), "/", LaunchConfiguration('camera_name' + param_name_suffix)),
                name=LaunchConfiguration('camera_name' + param_name_suffix),
                executable='realsense2_camera_node',
                parameters=[params
                            , params_from_file
                            ],
                output='screen',
                arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level' + param_name_suffix)],
                emulate_tty=True,
                )
        ]

do you run colcon build and ./install/local_setup.bash after each change in rs_launch.py ?
I agree with you that the namespace might be without any suffix.
but I still face a problem of /namespace/namespace/cameraname with your code.

can you please verify your changes with colcon build + running the ./install/local_setup.bash again?

@hyunseok-yang
Copy link
Contributor Author

Hi @hyunseok-yang, Sorry I did not noticed your comments, since I was writing my own.

No problem :)

Do you want both camera nodes to be under the same namespace ?

Yes That what we expecting.
It's why I insisting this launch script.

return [
            launch_ros.actions.Node(
                package='realsense2_camera',
                namespace=(LaunchConfiguration("camera_namespace"), "/", LaunchConfiguration('camera_name' + param_name_suffix)),
                name=LaunchConfiguration('camera_name' + param_name_suffix),
                executable='realsense2_camera_node',
                parameters=[params
                            , params_from_file
                            ],
                output='screen',
                arguments=['--ros-args', '--log-level', LaunchConfiguration('log_level' + param_name_suffix)],
                emulate_tty=True,
                )
        ]

do you run colcon build and ./install/local_setup.bash after each change in rs_launch.py ? I agree with you that the namespace might be without any suffix. but I still face a problem of /namespace/namespace/cameraname with your code.

Sure, after colcon build and setup.bash, I just run below command.
That's all I did.

colcon build --sym 
. ./install/setup.bash or local_setup.bash
ros2 launch realsense2_camera rs_launch.py align_depth.enable:=true rgb_camera.profile:=640x480x6 depth_module.profile:=640x480x6 camera_namespace:=test1 camera_name:=camera1

can you please verify your changes with colcon build + running the ./install/local_setup.bash again?

  • I'm working on humble version of ros2
  • I remove all build/install/log folder
  • did colcon build
  • did . ./install/local_setup.bash
  • run ros2 launch realsense2_camera rs_launch.py align_depth.enable:=true rgb_camera.profile:=640x480x6 depth_module.profile:=640x480x6 camera_namespace:=test1 camera_name:=camera1

and I got this

/test1/camera1/aligned_depth_to_color/camera_info
/test1/camera1/aligned_depth_to_color/image_raw
/test1/camera1/aligned_depth_to_color/image_raw/compressed
/test1/camera1/aligned_depth_to_color/image_raw/compressedDepth
/test1/camera1/aligned_depth_to_color/image_raw/theora
/test1/camera1/color/camera_info
/test1/camera1/color/image_raw
/test1/camera1/color/image_raw/compressed
/test1/camera1/color/image_raw/compressedDepth
/test1/camera1/color/image_raw/theora
/test1/camera1/color/metadata
/test1/camera1/depth/camera_info
/test1/camera1/depth/image_rect_raw
/test1/camera1/depth/image_rect_raw/compressed
/test1/camera1/depth/image_rect_raw/compressedDepth
/test1/camera1/depth/image_rect_raw/theora
/test1/camera1/depth/metadata
/test1/camera1/extrinsics/depth_to_color
/test1/camera1/extrinsics/depth_to_depth
/test1/camera1/imu

this branch

yg@YG-ROS:realsense-ros$ git status
On branch modifiable_namespace
Your branch is up to date with 'origin/modifiable_namespace'.

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 1, 2023

Oh Now I got it.

You did ros2 node list.

In case of me, I got this.

yg@YG-ROS:realsense-ros$ ros2 node list
/test1/camera1/camera1

It's a /namespace/camera_name/camera_name

But this is what this package expected since namespace is "namespace/camera_name"

@SamerKhshiboun
Copy link
Collaborator

If you get a node that is
/test1/camera1/camera1

all topics should be the node name and then a string
so I don't know how you are getting these topics without the camera1 twice
I expect you to get
/test1/camera1/camera1/depth/metadata

can you please run ros2 topic list again ?

@hyunseok-yang
Copy link
Contributor Author

If you get a node that is /test1/camera1/camera1

all topics should be the node name and then a string so I don't know how you are getting these topics without the camera1 twice I expect you to get /test1/camera1/camera1/depth/metadata

can you please run ros2 topic list again ?

Sure,

/test/camera/aligned_depth_to_color/camera_info
/test/camera/aligned_depth_to_color/image_raw
/test/camera/aligned_depth_to_color/image_raw/compressed
/test/camera/aligned_depth_to_color/image_raw/compressedDepth
/test/camera/aligned_depth_to_color/image_raw/theora
/test/camera/color/camera_info
/test/camera/color/image_raw
/test/camera/color/image_raw/compressed
/test/camera/color/image_raw/compressedDepth
/test/camera/color/image_raw/theora
/test/camera/color/metadata
/test/camera/depth/camera_info
/test/camera/depth/image_rect_raw
/test/camera/depth/image_rect_raw/compressed
/test/camera/depth/image_rect_raw/compressedDepth
/test/camera/depth/image_rect_raw/theora
/test/camera/depth/metadata
/test/camera/extrinsics/depth_to_color
/test/camera/extrinsics/depth_to_depth
/test/camera/imu

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 1, 2023

What did you get if run ros2 topic list currently?

@hyunseok-yang
Copy link
Contributor Author

Just in case, I removed binary package ros-humble-realsense2-camera then re-run the rs_launch.py

And still got same result.

@Arun-Prasad-V
Copy link
Contributor

As I told above, what I expected on topic list is like below. For example, there is two robot with namespace robot1 and robot2 and each has two-d435 camera. Topics would be like here

/robot1/cam1/color/blahblah
/robot1/cam1/depth/blahblah
/robot1/cam2/color/blahblah
/robot1/cam2/depth/blahblah

/robot2/cam1/color/blahblah
/robot2/cam1/depth/blahblah
/robot2/cam2/color/blahblah
/robot2/cam2/depth/blahblah

However if the suffix attached after namespace

/robot11/cam1/color/blahblah
/robot11/cam1/depth/blahblah
/robot12/cam2/color/blahblah
/robot12/cam2/depth/blahblah

Hi @hyunseok-yang , I need to clarify a bit more about param_name_suffix. This suffix will be appended to the param names listed in rs_launch.py, not for the values of those params.

The idea is to run the rs_multi_camera_launch.py as below:
ros2 launch realsense2_camera rs_multi_camera_launch.py camera_namespace1:='robot1' camera_namespace2:='robot2' camera_name1:='cam1' camera_name2:='cam2'

@hyunseok-yang
Copy link
Contributor Author

As I told above, what I expected on topic list is like below. For example, there is two robot with namespace robot1 and robot2 and each has two-d435 camera. Topics would be like here

/robot1/cam1/color/blahblah
/robot1/cam1/depth/blahblah
/robot1/cam2/color/blahblah
/robot1/cam2/depth/blahblah

/robot2/cam1/color/blahblah
/robot2/cam1/depth/blahblah
/robot2/cam2/color/blahblah
/robot2/cam2/depth/blahblah

However if the suffix attached after namespace

/robot11/cam1/color/blahblah
/robot11/cam1/depth/blahblah
/robot12/cam2/color/blahblah
/robot12/cam2/depth/blahblah

Hi @hyunseok-yang , I need to clarify a bit more about param_name_suffix. This suffix will be appended to the param names listed in rs_launch.py, not for the values of those params.

OK, Let me know if it is clarified to you.

The idea is to run the rs_multi_camera_launch.py as below: ros2 launch realsense2_camera rs_multi_camera_launch.py camera_namespace1:='robot1' camera_namespace2:='robot2' camera_name1:='cam1' camera_name2:='cam2'

My idea is like this. What do you think?
Bringup launch script should be launched every robot.

# for robot 1
ros2 launch realsense2_camera rs_multi_camera_launch.py camera_namespace:='robot1'  camera_name1:='cam1' camera_name2:='cam2'`

# for robot 2
ros2 launch realsense2_camera rs_multi_camera_launch.py camera_namespace:='robot2'  camera_name1:='cam1' camera_name2:='cam2'`

@SamerKhshiboun
Copy link
Collaborator

SamerKhshiboun commented Aug 1, 2023

To conclude everything:
About namespaces and names:
https://robots.nootrix.com/diy-tutos/ros-namespaces/

A namespace can include nodes, topics, etc..

Today, when launching with:
ros2 launch realsense2_camera rs_launch.py

We get this output, and we want to keep like this, because many users have assumption on node names and topic names

image

The first /camera is always the namespace

so the node name is
/<camera_namespace>/<camera_name>

and this should be like this always.

the topics are
/<camera_namespace>/<topic_name>
no camera_name (or node name) in the topic, and we should keep this behavior.

What I suggest is here:

in rs_launch.py edit namespace in both places:

namespace=LaunchConfiguration('camera_namespace' + param_name_suffix),

in rs_multi_camera_launch.py, edit local_parameters to be:

local_parameters = [{'name': 'camera_name1', 'default': 'camera1', 'description': 'camera1 unique name'},
                    {'name': 'camera_name2', 'default': 'camera2', 'description': 'camera2 unique name'},
                    {'name': 'camera_namespace1', 'default': 'camera1', 'description': 'camera1 namespace'},
                    {'name': 'camera_namespace2', 'default': 'camera2', 'description': 'camera2 namespace'},
                    ]

Then, you can run this example from your terminal: ( I have D455 and D435i cameras)

ros2 launch realsense2_camera rs_multi_camera_launch.py device_type1:='d455' camera_name1:='D455' device_type2:='d435i' camera_name2:='D435i' camera_namespace1:='robot1/d455' camera_namespace2:='robot1/d435i'

and then you will get two nodes (ros2 node list):

/robot1/d435i/D435i
/robot1/d455/D455

and you will get these topics:

/robot1/d435i/color/camera_info
/robot1/d435i/color/image_raw
/robot1/d435i/color/metadata
/robot1/d435i/depth/camera_info
/robot1/d435i/depth/image_rect_raw
/robot1/d435i/depth/metadata
/robot1/d435i/extrinsics/depth_to_color
/robot1/d435i/imu
/robot1/d455/color/camera_info
/robot1/d455/color/image_raw
/robot1/d455/color/metadata
/robot1/d455/depth/camera_info
/robot1/d455/depth/image_rect_raw
/robot1/d455/depth/metadata
/robot1/d455/extrinsics/depth_to_color
/robot1/d455/imu

If that good for you, please do the suggested changes and commit, and I will approve this PR and merge it.

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 2, 2023

As you mentioned this will NOT include camera name on topics.

namespace=LaunchConfiguration('camera_namespace' + param_name_suffix),

Is that your intention?

So whatever camera_name is passed on launcher, it will not affect topic name right?
camera_name:=

It it so, we have to append a camera_name on camera_namespace always..

for examples,
camera_namespace:=/robot1/cam1
camera_namespace:=/robot1/cam2
camera_namespace:=/robot1/cam3

I think it is little weired that the camera name is appended in namespace. Because literally namespace is namespace not a name.
(I know that is working solution)

@SamerKhshiboun
Copy link
Collaborator

I think it is little weired that the camera name is appended in namespace. Because literally namespace is namespace not a name.

I understand that this is weird, but your proposal is doing the same weirdness under the hood (in the code itself) when you append the camera_name to the camera_namespace.
We either do this in the code, or in the launch file/command.

Anyway, I think the best solution should be enhancing other places in the code, where we define the topic names.
We can add the camera_name to that places (see startPublishers() function in rs_node_setup.cpp)
This way we will keep the isolation concept of both camera_name and camera_namespace.

What do you think ?

@hyunseok-yang
Copy link
Contributor Author

hyunseok-yang commented Aug 4, 2023

I understand that this is weird, but your proposal is doing the same weirdness under the hood (in the code itself) when you append the camera_name to the camera_namespace. We either do this in the code, or in the launch file/command.

I didn't intend it. I appended it because code are written in this packges.
Just followed the rule of here.
I hope to launch the package with namespace and name intutively.

Anyway, I think the best solution should be enhancing other places in the code, where we define the topic names. We can add the camera_name to that places (see startPublishers() function in rs_node_setup.cpp) This way we will keep the isolation concept of both camera_name and camera_namespace.

What do you think ?

If you can edit the code as what we desired, I would be happy :).

So you mean, I will get below result, isn't it?

with this launch command
ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=cam1
ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=cam2

/robot1/cam1/color/blahblah
/robot1/cam1/depth/blahblah
/robot1/cam2/color/blahblah
/robot1/cam2/depth/blahblah

/robot2/cam1/color/blahblah
/robot2/cam1/depth/blahblah
/robot2/cam2/color/blahblah
/robot2/cam2/depth/blahblah

THEN I will follow your way.

After all of modifictaion, is it still required param_name_suffix in namespace?

@SamerKhshiboun
Copy link
Collaborator

I understand that this is weird, but your proposal is doing the same weirdness under the hood (in the code itself) when you append the camera_name to the camera_namespace. We either do this in the code, or in the launch file/command.

I didn't intend it. I appended it because code are written in this packges. Just followed the rule of here. I hope to launch the package with namespace and name intutively.

Anyway, I think the best solution should be enhancing other places in the code, where we define the topic names. We can add the camera_name to that places (see startPublishers() function in rs_node_setup.cpp) This way we will keep the isolation concept of both camera_name and camera_namespace.
What do you think ?

If you can edit the code as what we desired, I would be happy :).

So you mean, I will get below result, isn't it?

with this launch command ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=cam1 ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=cam2

/robot1/cam1/color/blahblah
/robot1/cam1/depth/blahblah
/robot1/cam2/color/blahblah
/robot1/cam2/depth/blahblah

/robot2/cam1/color/blahblah
/robot2/cam1/depth/blahblah
/robot2/cam2/color/blahblah
/robot2/cam2/depth/blahblah

THEN I will follow your way.

After all of modifictaion, is it still required param_name_suffix in namespace?

Lets start with your PR, and then I will continue in a separated PR (to add the camera name to the topic name)

Please fix two things::

in rs_launch.py edit namespace in both places:

namespace=LaunchConfiguration('camera_namespace' + param_name_suffix),

in rs_multi_camera_launch.py, edit local_parameters to be:

local_parameters = [{'name': 'camera_name1', 'default': 'camera1', 'description': 'camera1 unique name'},
                    {'name': 'camera_name2', 'default': 'camera2', 'description': 'camera2 unique name'},
                    {'name': 'camera_namespace1', 'default': 'camera1', 'description': 'camera1 namespace'},
                    {'name': 'camera_namespace2', 'default': 'camera2', 'description': 'camera2 namespace'},
                    ]

@hyunseok-yang
Copy link
Contributor Author

I understand that this is weird, but your proposal is doing the same weirdness under the hood (in the code itself) when you append the camera_name to the camera_namespace. We either do this in the code, or in the launch file/command.

I didn't intend it. I appended it because code are written in this packges. Just followed the rule of here. I hope to launch the package with namespace and name intutively.

Anyway, I think the best solution should be enhancing other places in the code, where we define the topic names. We can add the camera_name to that places (see startPublishers() function in rs_node_setup.cpp) This way we will keep the isolation concept of both camera_name and camera_namespace.
What do you think ?

If you can edit the code as what we desired, I would be happy :).
So you mean, I will get below result, isn't it?
with this launch command ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=cam1 ros2 launch realsense2_camera rs_launch.py camera_namespace:=robot1 camera_name:=cam2

/robot1/cam1/color/blahblah
/robot1/cam1/depth/blahblah
/robot1/cam2/color/blahblah
/robot1/cam2/depth/blahblah

/robot2/cam1/color/blahblah
/robot2/cam1/depth/blahblah
/robot2/cam2/color/blahblah
/robot2/cam2/depth/blahblah

THEN I will follow your way.
After all of modifictaion, is it still required param_name_suffix in namespace?

Lets start with your PR, and then I will continue in a separated PR (to add the camera name to the topic name)

Please fix two things::

in rs_launch.py edit namespace in both places:

namespace=LaunchConfiguration('camera_namespace' + param_name_suffix),

in rs_multi_camera_launch.py, edit local_parameters to be:

local_parameters = [{'name': 'camera_name1', 'default': 'camera1', 'description': 'camera1 unique name'},
                    {'name': 'camera_name2', 'default': 'camera2', 'description': 'camera2 unique name'},
                    {'name': 'camera_namespace1', 'default': 'camera1', 'description': 'camera1 namespace'},
                    {'name': 'camera_namespace2', 'default': 'camera2', 'description': 'camera2 namespace'},
                    ]

OK. just moment

@hyunseok-yang
Copy link
Contributor Author

Please check, I modified the commit as what you require.

Copy link
Collaborator

@SamerKhshiboun SamerKhshiboun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

realsense2_camera/launch/rs_launch.py Show resolved Hide resolved
- Add namespace launch argument
@hyunseok-yang
Copy link
Contributor Author

@SamerKhshiboun Please check with latest commit 16d49e0

@SamerKhshiboun SamerKhshiboun merged commit 25a1191 into IntelRealSense:ros2-development Aug 8, 2023
6 checks passed
@hyunseok-yang hyunseok-yang deleted the modifiable_namespace branch August 9, 2023 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants