Ask Your Question
0

How can I make a bash script in a package run after catkin_make has been used on workspace?

asked 2021-09-05 22:40:55 -0600

katsostak gravatar image

I have a bash script that installs some packages necessary to use a package I am building. Ideally I would want this bash script to be executed the first time someone uses catkin_make on the workspace after my package has been cloned on the src folder of the workspace. How can this be done? Is there another way to accomplish what I am trying to do?

I have tried to do this from launch file without much success.

Running this on ROS melodic, Ubuntu 18.04

edit retag flag offensive close merge delete

Comments

1

To avoid an xy-problem, it might be good to take a look at what sort of dependencies you're referring to.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-06 05:29:56 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-09-06 04:11:01 -0600

Ranjit Kathiriya gravatar image

updated 2021-09-06 04:11:13 -0600

Hello @katsostak,

Let's say you have created a bash script including all package init. I am just providing an example instead of whoami and date command think it is your script.

Mini batch script: abc.sh

#!/bin/bash
whoami
date

You first need to chmod +x abc.sh

You can execute it in 2 ways: 1. bash abc.sh 2. ./abc.sh

Ideally I would want this bash script to be executed the first time someone uses catkin_make on the workspace after my package has been cloned on the src folder of the workspace.

CMake Solution

It is also possible to add a "post build" command for a target in CMake with add_custom_command using the "POST_BUILD COMMAND" option:

add_custom_command(TARGET doc
    POST_BUILD COMMAND your_script.sh
)

(I am not sure if this will work as intended for the target, maybe you have to experiment a bit.)

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-09-05 22:40:55 -0600

Seen: 21 times

Last updated: Sep 06 '21