1 写launch文件
把ROS程序写成一个launch文件,例如
powerline_with_rviz.launch
<launch><!-- Load camera parameters --><rosparam file="$(find choose_powerline)/config/camera_params.yaml" command="load"/><!-- Launch the RealSense camera node --><include file="$(find realsense2_camera)/launch/rs_camera.launch"/><!-- Launch the Yolov8 Segment node --><include file="$(find yolov8_seg)/launch/yolov8_seg.launch"/><!-- Launch the min_rects_processor_node --><include file="$(find choose_powerline)/launch/min_rects_processor.launch"/><!-- Launch the min_rects_processor_node --><include file="$(find choose_powerline)/launch/mouse.launch"/><node name="rviz" pkg="rviz" type="rviz" args="-d $(find choose_powerline)/rviz/pl.rviz" />
</launch>
写sh文件启动launch
powerline_with_rviz.sh
#!/bin/bashsource /opt/ros/noetic/setup.bash
source /home/work/catkin_ws/devel/setup.bashgnome-terminal -- bash -c "roslaunch choose_powerline powerline_with_rviz.launch; exec bash"
记得赋予权限
chmod +x 文件名
写desktop文件启动sh
这个文件一定要在桌面上
start.desktop
[Desktop Entry]
Name=原神启动
Comment=启动ROS Noetic程序
Exec=/home/work/catkin_ws/src/choose_powerline/launch/powerline_with_rviz.sh
Icon=utilities-terminal
Terminal=true
Type=Application
赋予权限
chmod +x 文件名
还要右键允许启动
此时双击可以启动