Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
ROS START AND RECORD
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenyulei
ROS START AND RECORD
Commits
7fef54e0
Commit
7fef54e0
authored
Mar 22, 2022
by
chenyulei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parents
Pipeline
#1027
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
137 additions
and
0 deletions
+137
-0
run_ros.sh
run_ros.sh
+137
-0
No files found.
run_ros.sh
0 → 100644
View file @
7fef54e0
#!/bin/bash
# How to use: (only accept three params below)
# 1.start lv nodes and record lv rosbag(the number represents the recording time): ./run_ros.sh lv 10
# 2.only start lv node: ./run_ros.sh lv
# 3.only start all nodes: ./run_ros.sh jfx
# 4. stop all nodes: ./run_ros.sh stop
# 5. restart all nodes: ./run_ros.sh restart
function
getpids
(){
local
res
=
`
ps
-ef
|
grep
-v
grep
|
grep
$1
|
sed
's/[ ][ ]*/ /g'
|
cut
-d
' '
-f8
`
echo
$res
}
function
killpids
(){
local
res
=
`
ps
-ef
|
grep
-v
grep
|
grep
$1
|
sed
's/[ ][ ]*/ /g'
|
cut
-d
' '
-f2
,8
`
local
arr
=(
$res
)
for
i
in
${
!arr[@]
}
do
if
[
`
expr
$i
% 2
`
-eq
0
]
;
then
`
echo
"123"
|
sudo
-S
kill
-9
${
arr
[
$i
]
}
`
echo
"
\t
process
\0
33[36m
${
arr
[
$i
+1]
}
\0
33[0m killed
\n
"
fi
done
}
function
stopapp
(){
source
/home/nvidia/catkin_ws/devel/setup.sh
rosnode list
rosnode
kill
--all
rosnode cleanup
`
killall roslaunch
`
echo
"============ ALL ROS NODE HAS BEEN SHUTDOWN ============"
}
function
startapp
(){
echo
"====== ROSNODE KILL ALL======"
rosnode
kill
--all
clear
sleep
2
echo
"====== START ROSCORE ======"
cd
/home/nvidia/catkin_ws/
roscore_logname
=
"roscore-
$(
date
+%Y%m%d
)
_
$(
date
+%H%M%S
)
.log"
nohup
roscore
>
../log/
$roscore_logname
2>&1 &
sleep
3
echo
"====== START PANDAR64 ROS NODES ======"
cd
/home/nvidia/catkin_ws/
source
devel/setup.bash
lidar_logname
=
"lidar-
$(
date
+%Y%m%d
)
_
$(
date
+%H%M%S
)
.log"
nohup
roslaunch hesai_lidar hesai_lidar.launch
>
../log/
$lidar_logname
2>&1 &
echo
"====== START CAMERA ROS NODES ======"
cd
/home/nvidia/catkin_ws/
source
devel/setup.bash
camera_logname
=
"camera-
$(
date
+%Y%m%d
)
_
$(
date
+%H%M%S
)
.log"
nohup
roslaunch spinnaker_sdk_camera_driver node_acquisition.launch
>
../log/
$camera_logname
2>&1 &
if
[
$1
==
"jfx"
]
;
then
echo
"====== Start PROJECT ROS NODES ========"
cd
/home/nvidia/catkin_ws/
source
devel/setup.bash
rosproject_logname
=
"project-
$(
date
+%Y%m%d
)
_
$(
date
+%H%M%S
)
.log"
nohup
roslaunch jfxrosperceiver project.launch
>
../log/
$rosproject_logname
2>&1 &
fi
echo
-e
"----------------------------------------------------------------------------
\n\n
"
sleep
4
if
[
$2
!=
" "
]
;
then
for
j
in
1 2 3
;
do
if
[
$j
==
1
]
;
then
sleep
4
rm
-rf
/home/nvidia/rosbag/
*
fi
echo
"++++++ RECORD ROSBAG(LV)
$j
TIMES ++++++"
record_rosbag
$2
j
done
echo
"RECORD ROSBAG IS FINISHED"
fi
}
function
record_rosbag
(){
mkdir
-p
/home/nvidia/rosbag
cd
/home/nvidia/rosbag
rosbag_logname
=
"rosbag-
$(
date
+%Y%m%d
)
_
$(
date
+%H%M%S
)
.log"
nohup
rosbag record
--duration
=
$1
$(
rostopic list |
grep
'pandar$'
)
$(
rostopic list |
grep
'compressed$'
)
>
../log/
$rosbag_logname
2>&1 &
tm
=
"scale=1;
$1
/100"
| bc
export
tm
=
$(
echo
"scale=1;
$1
/100"
| bc
)
i
=
0
icon
=
''
arr
=(
'|'
'/'
'-'
'\\'
)
index
=
0
while
[
$i
-le
100
]
do
index
=
`
echo
$i
%4
`
printf
"[%-74s][%d%%][%c]
\r
"
"
$icon
"
"
$i
"
"
${
arr
[
$index
]
}
"
icon
=
'#'
$icon
((
i++
))
sleep
$tm
done
echo
echo
"++++++ RECORD ROSBAG(LV)
$j
TIMES OK ++++++"
sleep
3
save_path
=
"/media/nvidia/Data/7-1/"
rosbag_name
=
$(
ls
|
grep
'.bag$'
)
rosbag info
$rosbag_name
echo
"++++++ SCP
$rosbag_name
TO
$save_path
(POINT 1-1) ++++++"
scp ./
*
.bag nvidia@10.50.108.1:
$save_path
rm
-rf
./
*
.bag
echo
-e
"
\n
"
}
MODE
=
"start"
if
[
$#
-ge
1
]
;
then
MODE
=
$1
fi
clear
mkdir
-p
/home/nvidia/log
if
[
$MODE
==
"stop"
]
;
then
stopapp
echo
"mec app stopped at "
`
date
`
>>
/home/nvidia/log/rosstop.log
elif
[
$MODE
==
"start"
]
;
then
startapp
$2
$3
echo
"mec app started at "
`
date
`
>>
/home/nvidia/log/rosstart.log
elif
[
$MODE
==
"restart"
]
;
then
stopapp
startapp
$2
$3
echo
"mec app restarted at "
`
date
`
>>
/home/nvidia/log/rosrestart.log
else
echo
"Unexpected param(start stop or restart)"
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment