Ask Your Question
0

How to Run ros2 launch file using service file

asked 2021-02-09 09:11:25 -0500

Flash gravatar image

updated 2021-02-09 12:57:32 -0500

gvdhoorn gravatar image

Hi, I am trying to run launch file in ros2 using service file but I am unable to do it.

[Unit]
After=network-online.target
Description=desc

[Service]
Environment=source home/$USER/dev_ws/install/setup.bash
ExecStart=ros2 launch topics topic.launch.py
RemainAfterExit=no
Restart=on-failure
RestartSec=2s

[Install]
WantedBy=user.target

This is the error I am getting

Invalid environment assignment, ignoring: source
Feb 09 09:59:54 USER-pc systemd[1]: /etc/systemd/system/name.service:6: Invalid environment assignment, ignoring: home/USER/dev_ws/install/setup.bash
Feb 09 09:59:54 USER-pc systemd[1]: /etc/systemd/system/name.service:7: Executable "ros2" not found in path "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Can anyone please helpme

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-03-25 10:37:03 -0500

Flash gravatar image

I was able to resolve this issue by sourcing and running the launch file by using /bin/bash -c

ExecStart=/bin/bash -c 'source /opt/ros/foxy/setup.bash; source home/$USER/dev_ws/install/setup.bash; ros2 launch pkg_name launch_file_name.launch.py; sleep 60'
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-02-09 09:11:25 -0500

Seen: 142 times

Last updated: Mar 25