Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_ros_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
ros
iri_core
iri_ros_scripts
Commits
4477ed29
Commit
4477ed29
authored
7 years ago
by
Fernando Herrero
Browse files
Options
Downloads
Patches
Plain Diff
Changed script names: added 'topic' and 'service'
parent
e25d010f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
add_service_server_client.sh
+121
-0
121 additions, 0 deletions
add_service_server_client.sh
add_topic_publisher_subscriber.sh
+145
-0
145 additions, 0 deletions
add_topic_publisher_subscriber.sh
with
266 additions
and
0 deletions
add_service_server_client.sh
0 → 100755
+
121
−
0
View file @
4477ed29
#!/bin/bash
# WET
# check wether the scripts path environment variable has been defined
scripts_path
=
`
echo
"
${
IRI_ROS_SCRIPTS_PATH
}
"
`
if
[[
-z
"
${
scripts_path
}
"
]]
then
echo
"The scripts path environment variable has not been defined. Please see the wiki documentation for instructions on how to create it."
exit
else
echo
"The scripts path environment variable has been properly defined."
fi
source
"
${
IRI_ROS_SCRIPTS_PATH
}
/libraries/scripts_library.sh"
source
"
${
IRI_ROS_SCRIPTS_PATH
}
/libraries/create_server.sh"
source
"
${
IRI_ROS_SCRIPTS_PATH
}
/libraries/create_client.sh"
check_libraries
check_templates
echo
""
echo
"/*********************************************/"
echo
"/* Creating New ROS Server/Client */"
echo
"/*********************************************/"
server_client
=
ros_pkg
=
service_name
=
srv_file
=
#check for input project name paramenter
while
getopts
“:o:p:s:m:” OPTION
do
case
$OPTION
in
o
)
server_client
=
$OPTARG
;;
p
)
ros_pkg
=
$OPTARG
;;
s
)
service_name
=
$OPTARG
;;
m
)
srv_file
=
$OPTARG
;;
?
)
echo
"invalid input argument
${
OPTION
}
"
kill_exit
"Usage: add_service_server_client.sh -o [server,client] -p ros_pkg -s service_name -m service.srv"
exit
;;
esac
done
#check if publisher name parameter is filled up
if
[
!
"
${
server_client
}
"
]
||
[
!
"
${
ros_pkg
}
"
]
||
[
!
"
${
service_name
}
"
]
||
[
!
"
${
srv_file
}
"
]
then
echo
"Missing input parameters..."
kill_exit
"Usage: add_service_server_client.sh -o [server,client] -p ros_pkg -s service_name -m service.srv"
fi
#check server client parameter
if
[[
!
"
${
server_client
}
"
=
"server"
]]
&&
[[
!
"
${
server_client
}
"
=
"client"
]]
then
kill_exit
"First parameter must be either
\"
server
\"
or
\"
client
\"
, aborting ..."
fi
#check if package exists
check_package
"
${
ros_pkg
}
"
if
[[
${
pkg_exists
}
==
true
]]
then
roscd
${
ros_pkg
}
else
kill_exit
"ROS package
${
ros_pkg
}
does NOT exist yet, please first run iri_ros_create_package.sh"
fi
#validate file extension .srv
srv
=
"srv"
ext
=
${
srv_file
##*.
}
ext
=
$(
echo
${
ext
}
|
tr
"[:upper:]"
"[:lower:]"
)
#check extension
if
[[
!
"
${
ext
}
"
=
"
${
srv
}
"
]]
then
kill_exit
"Wrong file extension, please provide a .srv file, aborting ..."
fi
#look for SRV file
find_ros_message
${
srv_file
}
${
srv
}
${
ros_pkg
}
if
${
found_it
}
then
srv_file
=
${
my_file
}
echo
"SRV file
${
srv_file
}
found!"
else
echo
"SRV file
${
srv_file
}
does NOT exist, please check if file is in valid directories"
kill_exit
"Aborting ..."
fi
#retrieve header and source files and pkg kind (algorithm/driver)
get_h_cpp_files
${
ros_pkg
}
is_driver_or_alg_node
${
ros_pkg
}
echo
"node_h=
${
node_h
}
"
echo
"node_c=
${
node_c
}
"
echo
"driver_alg=
${
driver_alg
}
"
if
[[
-z
${
node_h
}
]]
||
[[
-z
${
node_c
}
]]
||
[[
-z
${
driver_alg
}
]]
then
kill_exit
"Problems with headers and/or source files"
fi
#go to package folder
roscd
"
${
ros_pkg
}
"
#modify node files adding server/client parameters
if
[[
"
${
server_client
}
"
=
"server"
]]
then
create_server
${
ros_pkg
}
${
service_name
}
${
srv_file
%.srv
}
${
file_pkg
}
${
node_h
}
${
node_c
}
${
driver_alg
}
else
create_client
${
ros_pkg
}
${
service_name
}
${
srv_file
%.srv
}
${
file_pkg
}
${
node_h
}
${
node_c
}
${
driver_alg
}
fi
This diff is collapsed.
Click to expand it.
add_topic_publisher_subscriber.sh
0 → 100755
+
145
−
0
View file @
4477ed29
#!/bin/bash
# WET
# check wether the scripts path environment variable has been defined
scripts_path
=
`
echo
"
${
IRI_ROS_SCRIPTS_PATH
}
"
`
if
[[
-z
"
${
scripts_path
}
"
]]
then
echo
"The scripts path environment varibale has not been defined. Please see the wiki documentation for instructions on how to create it."
exit
else
echo
"The scripts path environment variable has been properly defined."
fi
source
"
${
IRI_ROS_SCRIPTS_PATH
}
/libraries/scripts_library.sh"
source
"
${
IRI_ROS_SCRIPTS_PATH
}
/libraries/create_publisher.sh"
source
"
${
IRI_ROS_SCRIPTS_PATH
}
/libraries/create_subscriber.sh"
check_libraries
check_templates
echo
""
echo
"/*********************************************/"
echo
"/* Creating New ROS Publisher/Subscriber */"
echo
"/*********************************************/"
pub_subs
=
ros_pkg
=
topic_name
=
msg_file
=
buffer
=
#check for input project name paramenter
while
getopts
“:o:p:t:m:b:” OPTION
do
case
$OPTION
in
o
)
pub_subs
=
$OPTARG
;;
p
)
ros_pkg
=
$OPTARG
;;
t
)
topic_name
=
$OPTARG
;;
m
)
msg_file
=
$OPTARG
;;
b
)
buffer
=
$OPTARG
;;
?
)
echo
"invalid input argument
${
OPTION
}
"
kill_exit
"Usage: add_topic_publisher_subscriber.sh -o [publisher,subscriber] -p ros_pkg -t topic_name -m message.msg -b 100"
exit
;;
esac
done
#check if publisher name parameter is filled up
if
[
!
"
${
pub_subs
}
"
]
||
[
!
"
${
ros_pkg
}
"
]
||
[
!
"
${
topic_name
}
"
]
||
[
!
"
${
msg_file
}
"
]
||
[
!
"
${
buffer
}
"
]
then
echo
"Missing input parameters..."
kill_exit
"Usage: add_topic_publisher_subscriber.sh -o [publisher,subscriber] -p ros_pkg -t topic_name -m message.msg -b 100"
fi
#check publisher subscriber parameter
if
[[
!
"
${
pub_subs
}
"
=
"publisher"
]]
&&
[[
!
"
${
pub_subs
}
"
=
"subscriber"
]]
then
kill_exit
"First parameter must be either
\"
publisher
\"
or
\"
subscriber
\"
, aborting ..."
fi
#check if package exists
result
=
`
roscd
${
ros_pkg
}
`
if
[[
-z
"
${
result
}
"
]]
then
roscd
${
ros_pkg
}
else
kill_exit
"ROS package
${
ros_pkg
}
does NOT exist yet, please first run iri_ros_create_package.sh"
fi
check_package
"
${
ros_pkg
}
"
if
[[
${
pkg_exists
}
==
true
]]
then
roscd
${
ros_pkg
}
else
kill_exit
"ROS package
${
ros_pkg
}
does NOT exist yet, please first run iri_ros_create_package.sh"
fi
#validate file extension .msg
msg
=
"msg"
ext
=
${
msg_file
##*.
}
ext
=
$(
echo
${
ext
}
|
tr
"[:upper:]"
"[:lower:]"
)
#check extension
if
[[
!
"
${
ext
}
"
=
"
${
msg
}
"
]]
then
kill_exit
"Wrong file extension, please provide a .msg file, aborting ..."
fi
#look for MSG file
find_ros_message
${
msg_file
}
${
msg
}
${
ros_pkg
}
if
${
found_it
}
then
msg_file
=
${
my_file
}
echo
"MSG file
${
msg_file
}
found!"
else
echo
"MSG file
${
msg_file
}
does NOT exist, please check if file is in valid directories"
kill_exit
"Aborting ..."
fi
# Sanitize input and assign to new variable
export
clean_buffer
=
`
echo
"
${
buffer
}
"
|
tr
-cd
'[:digit:]'
`
#check if buffer parameter is filled up
if
[
"
$clean_buffer
"
]
&&
[
"
$clean_buffer
-gt 0"
]
then
echo
"Setting buffer length to
$clean_buffer
"
else
kill_exit
"No buffer provided, aborting ..."
fi
#retrieve header and source files and pkg kind (algorithm/driver)
get_h_cpp_files
${
ros_pkg
}
is_driver_or_alg_node
${
ros_pkg
}
echo
"node_h=
${
node_h
}
"
echo
"node_c=
${
node_c
}
"
echo
"driver_alg=
${
driver_alg
}
"
if
[[
-z
${
node_h
}
]]
||
[[
-z
${
node_c
}
]]
||
[[
-z
${
driver_alg
}
]]
then
kill_exit
"Problems with headers and/or source files"
fi
#go to package folder
roscd
"
${
ros_pkg
}
"
#modify node files adding server/client parameters
if
[[
"
${
pub_subs
}
"
=
"publisher"
]]
then
create_publisher
${
ros_pkg
}
${
topic_name
}
${
msg_file
%.msg
}
${
file_pkg
}
${
buffer
}
${
node_h
}
${
node_c
}
${
driver_alg
}
else
create_subscriber
${
ros_pkg
}
${
topic_name
}
${
msg_file
%.msg
}
${
file_pkg
}
${
buffer
}
${
node_h
}
${
node_c
}
${
driver_alg
}
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment