-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d74f75
commit ad69c57
Showing
10 changed files
with
302 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ======================================= | ||
# Namespace config | ||
# ======================================= | ||
# To use multimle devices on multible robot you have to specify following field | ||
|
||
# Uncomment to add robot namespace | ||
# ROS_NAMESPACE=robot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
# Quick Start | ||
# docker compose up | ||
x-common-config: | ||
&common-config | ||
network_mode: host | ||
ipc: host | ||
env_file: .env | ||
|
||
services: | ||
|
||
rplidar: | ||
image: husarion/rplidar:humble | ||
restart: unless-stopped | ||
network_mode: host | ||
ipc: host | ||
# image: husarion/rplidar:humble | ||
build: | ||
context: .. | ||
dockerfile: Dockerfile | ||
<<: *common-config | ||
devices: | ||
- /dev/ttyUSB0 | ||
environment: | ||
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0} | ||
- RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION:-rmw_fastrtps_cpp} | ||
command: > | ||
ros2 launch sllidar_ros2 sllidar_launch.py | ||
serial_baudrate:=${RPLIDAR_BAUDRATE:-256000} | ||
serial_baudrate:=${RPLIDAR_BAUDRATE:-115200} | ||
device_namespace:=lidar | ||
rviz: | ||
image: husarion/rviz2:humble | ||
restart: on-failure | ||
network_mode: host | ||
ipc: host | ||
<<: *common-config | ||
volumes: | ||
- /tmp/.X11-unix:/tmp/.X11-unix:rw | ||
- ./default.rviz:/root/.rviz2/default.rviz | ||
- ./rviz.launch.py:/ros2_ws/rviz.launch.py | ||
environment: | ||
- DISPLAY=${DISPLAY:?err} | ||
- LIBGL_ALWAYS_SOFTWARE=1 | ||
- ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-0} | ||
- RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION:-rmw_fastrtps_cpp} | ||
command: > | ||
ros2 launch rviz.launch.py | ||
device_namespace:=lidar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from launch import LaunchDescription | ||
from launch_ros.actions import Node, PushRosNamespace | ||
from launch.actions import DeclareLaunchArgument, OpaqueFunction | ||
from launch.substitutions import EnvironmentVariable, LaunchConfiguration | ||
|
||
|
||
def replace_rviz_fixed_frame(input_file, output_file, fix_frame): | ||
with open(input_file, "r") as file: | ||
rviz_content = file.read() | ||
|
||
rviz_content = rviz_content.replace("Fixed Frame: laser", f"Fixed Frame: {fix_frame}") | ||
|
||
with open(output_file, "w") as file: | ||
file.write(rviz_content) | ||
|
||
|
||
def launch_setup(context, *args, **kwargs): | ||
robot_namespace = LaunchConfiguration("robot_namespace").perform(context) | ||
device_namespace = LaunchConfiguration("device_namespace").perform(context) | ||
|
||
default_rviz_conf = "/root/.rviz2/default.rviz" | ||
rviz_conf = "/root/.rviz2/modified_default.rviz" | ||
if device_namespace: | ||
frame_id = f"{device_namespace}_link" | ||
else: | ||
frame_id = "laser" | ||
replace_rviz_fixed_frame(default_rviz_conf, rviz_conf, frame_id) | ||
|
||
remapping = [] | ||
if robot_namespace: | ||
remapping.append(("/clicked_point", f"/{robot_namespace}/clicked_point")) | ||
remapping.append(("/goal_pose", f"/{robot_namespace}/goal_pose")) | ||
remapping.append(("/initialpose", f"/{robot_namespace}/initialpose")) | ||
remapping.append(("/tf", f"/{robot_namespace}/tf")) | ||
remapping.append(("/tf_static", f"/{robot_namespace}/tf_static")) | ||
|
||
rviz = Node( | ||
package="rviz2", | ||
executable="rviz2", | ||
name="rviz2", | ||
namespace=device_namespace, | ||
remappings=remapping, | ||
arguments=["-d", rviz_conf], | ||
output="screen", | ||
) | ||
|
||
return [PushRosNamespace(robot_namespace), rviz] | ||
|
||
|
||
def generate_launch_description(): | ||
return LaunchDescription( | ||
[ | ||
DeclareLaunchArgument( | ||
"robot_namespace", | ||
default_value=EnvironmentVariable("ROS_NAMESPACE", default_value=""), | ||
description="Namespace which will appear in front of all topics (including /tf and /tf_static).", | ||
), | ||
DeclareLaunchArgument( | ||
"device_namespace", | ||
default_value="", | ||
description="Sensor namespace that will appear after all topics and TF frames, used for distinguishing multiple cameras on the same robot.", | ||
), | ||
OpaqueFunction(function=launch_setup), | ||
PushRosNamespace(LaunchConfiguration("robot_namespace")), | ||
] | ||
) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.