Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
张 煜
sage_magnet_opt
Commits
d140277d
Commit
d140277d
authored
1 year ago
by
张 煜
Browse files
Options
Download
Patches
Plain Diff
更改磁铁state
parent
84c7e659
main
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+6
-5
CMakeLists.txt
scripts/magnet_opt.py
+10
-2
scripts/magnet_opt.py
with
16 additions
and
7 deletions
+16
-7
CMakeLists.txt
+
6
−
5
View file @
d140277d
...
...
@@ -57,11 +57,12 @@ find_package(catkin REQUIRED COMPONENTS
# )
## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )
add_service_files
(
FILES
ClawMagnetControl.srv
# Service2.srv
)
## Generate actions in the 'action' folder
# add_action_files(
...
...
This diff is collapsed.
Click to expand it.
scripts/magnet_opt.py
+
10
−
2
View file @
d140277d
...
...
@@ -3,7 +3,7 @@
import
sagepy
import
rospy
import
sage_arm_msgs.srv
#磁铁消磁
from
sage_magnet_opt.srv
import
ClawMagnetControl
from
sage_magnet_opt.srv
import
ClawMagnetControlResponse
...
...
@@ -28,6 +28,13 @@ def magnet_set_callback(request):
response
.
result
=
True
# or set to a default value
return
response
#磁铁检测函数
def
magnet_state_check
():
res
=
get_io_state
()
if
(
res
.
D0
[
0
])
or
(
res
.
D0
[
1
]
or
(
res
.
D0
[
2
])):
rospy
.
logerr
(
"磁铁异常,正在关闭磁铁"
)
set_magnet
(
False
)
if
__name__
==
'__main__'
:
...
...
@@ -36,5 +43,6 @@ if __name__ == '__main__':
#磁铁控制功能
stack_operate_service
=
rospy
.
Service
(
'/claw_magnet_set'
,
ClawMagnetControl
,
magnet_set_callback
)
# 获取夹爪io状态
get_io_state
=
rospy
.
ServiceProxy
(
'get_io_states'
,
sage_arm_msgs
.
srv
.
GetIoStates
)
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets