How to run a python script file for ros ?
I have developed python script to make a drone to fly. I have kept the code inside
tumsimulator/src/scripts/DroneFly.py. ## catkin make is done in this directory
When I run the code in tumsimulator directory, it throws an error saying that scripts directory is not found.
I gave chmod 777 permission for directory as well as the file.
Can Somebody help me to run the python script in ros ?
Just to be on the same page
you need to create a catkin workspace a catkin package. For example you create a workspace called catkin_ws
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
Create your package called tumsimulator in ~/home/catkin_ws/src
catkin_create_pkg tumsimulator rospy
Put the scripts directory in tumsimulator/ not in tumsimulator/src. Once after running catkin_make, you should be able to run the script via
Run catkin_make
cd ~/catkin_ws
catkin_make
Finally, run your script
rosrun tumsimulator DroneFly.py
As a side note, scripts should note have the py extension. You can add the python shebang line at the top of your script file #! /usr/bin/env python. If your are writing a python module, you may put these files in tumsimulator/src/tumsimulator/ next to tumsimulator/src/tumsimulator/__init__.py.
Related
Need your kind advise on this. I am very new to Jenkins pipeline and groovy. I have also Googled quite a bit about this specific thing but can't find any definite answers (mostly due to how inexperience I am so I might be missing it).
I have a groovy that is used to run a Jenkins job, at one point I have to run a python script in $WORKSPACE (see below)
stage("Compile Canary") {
steps {
script {
Map bbMap = [
name: env.STAGE_NAME,
commitID: gitInfo.GIT_COMMIT,
url: env.BUILD_URL,
message: "Local Compile"
]
try {
updateBitBucket.inProgress(bbMap)
sh label: '', script: '''
#!/bin/bash
set -e
cd $WORKSPACE/automation/
pip install --upgrade pip
pip install botocore==1.19.50
pip install boto3==1.16.0
python bin/install-dependencies.py
All the pip install / upgrade and boto installs went fine, it's only when running this section:
python bin/install-dependencies.py
that is having issues due to the fact that it cannot find the file (see below for Jenkins output)
+ python bin/install-lambda-dependencies.py
python: can't open file 'bin/install-dependencies.py': [Errno 2] No such file or directory
The error is obvious, which begs the question, how can I import this file? Can I copy it to the git repo and then import it? I'm using this python script because there are quite a long list of dependencies, and also I want to use this script as a standard across my team.
FYI: the python file is currently residing in the same code repository as the groovy file, it is placed in "bin" directory.
Thank you very much!
In my Jenkinsfile I have cloned one git repo using Git SCM and for relativeTargetDir I added for example "myGit".
So it is saved in directory "myGit".
After that I need to run my bash script, and inside after executing some lines of codes, I need to go inside myGit folder to be able to run some tests.
But I'm always getting cd: myGit: No such file or directory.
In my bash script I have tried like this :
some code...
cd myGit
run some tests inside myGit directory...
But when I try in Jenkinsfile like this :
dir('myGit') {
run some tests inside myGit directory...
}
it's working.
But I need to do that in my bash script.
Expected result : to go inside myGit directory
Actual result : throws cd: myGit: No such file or directory.
you can always do a
sh 'cd myGit && run some tests inside myGit directory
We are using slave as service and we r trying to run protractor with simple batch file after calling to npm install , but from some reason protractor was not detected, do u know what could be the reason/problem?
if i use web option (slave) for running job - everything went fine,
BTW - I try to set the service with user that allowed to run the test, and also set node in PATH, but nothing help
Appreciate your comments,
Thanks
Eyal
because you install protractor as a global package, So you should use webdriver-manager from global package install folder. The current folder where you execute npm install -g protractor has no webdriver-manager this cmd/binary. So jenkins report can't find webdriver-manager in current folder or PATH.
For best practice, you should add protractor as your nodejs project's dependency through npm install -S protractor before you write script, after do that, you will found 'protractor' will be add into package.json.
When others who get your source code, he only need to execute npm install under folder where package.json insides to get all dependencies installed.
After npm install done, the webdriver-manager will be found <package.json file inside folder>\node_modules\.bin\webriver-manager
So your cmd should write down as following:
pwd
ls -l "${WORKSPACE}"
cd /d <package.json file inside folder>
npm install
node_modules\.bin\webdriver-manager update
node_modules\.bin\protractor conf.js
I would love to be able to customize the UI to fit the guidelines of our brand.
I'm not very familiar with Sass and Angular.
Can you suggest which IDE, tools or plugins are best in this particular project to modify and test the UI without having to build the whole project every time?
Thank you!
thingsboard ui is using angularjs, react, webpack, babel and ...
but all of the ui is connected to all project and i couldn't run it separate and after npm install and npm run build had some problems . based on pom.xml file in ui folder the project first is build with maven and make a jar file in ui folder then run it as front-end module . if we want not to clean install maven every time we change the project, one way is to run commands in pom.xml file ourselves . because the project does not use our global installed npm and node first it installs the particular version of them (nodeVersion: v6.9.1 npmVersion: 3.10.8) locally in ui folder then move them to folder named node and make link to node_modules : ln -s node_modules/npm/bin/npm-cli.js npm after this run the commands:
node/npm install
node/npm run build
node/npm start
so you can write a script file to run all this commands together . don't forget to change your tb-gateway forwardHost and forwardPort in server.js file . the script file based on my os :
#!/usr/bin/env bash
if [ ! -d node-v6.9.1-linux-x64 ] ; then
wget https://nodejs.org/dist/v6.9.1/node-v6.9.1-linux-x64.tar.gz
tar -xzvf node-v6.9.1-linux-x64.tar.gz
mkdir node
mv node-v6.9.1-linux-x64/lib/node_modules node/
mv node-v6.9.1-linux-x64/bin/* node/
cd node
ln -s node_modules/npm/bin/npm-cli.js npm
cd ..
fi
node/npm install
node/npm run build
node/npm start
after all this every ui project build will take time . you can use webstorm IDE or some web ides to open ui folder .
I have setup a jenkins job to build my project. I have a jake.sh file in my project and the code is pulled from github. I want "npm install" command to be executed and then jake.sh to be executed once the the code is checked out.
How can I configure this in jenkins? I have tried givin ./jake.sh and jake.sh in Build->Execute Shell section
According what you tell I think the problem can be
The script is not marked as a executable. In this case add in Build -> Execute Shell (in case you have linux) sudo chmod 777 path_to_script/jake.sh.
The script is not in the base directory. Remembeber that when you execute a bash script, the current directory is /path_to_job/workspace. So you have first to move to the script folder (cd path_to_script) or specify the path when running it: ./path_to_script/jake.sh.
I hope this solves your problem.
A workaround for shell scripts can be to run the script as
bash ./jake.sh
instead of
./jake.sh
Then you don't have to do chmod. Useful when you wipe the workspace before every build.
In the same manner, if you have a nodejs shell script or python script, you can run node myscript.js / python myscript.py.