mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 09:28:58 +00:00
adding previous integration demo tests
This commit is contained in:
committed by
Thomas Gubler
parent
cbbc660b88
commit
a54849eeff
59
integrationtests/demo_tests/manual_input.py
Executable file
59
integrationtests/demo_tests/manual_input.py
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import rospy
|
||||
|
||||
from sensor_msgs.msg import Joy
|
||||
from std_msgs.msg import Header
|
||||
|
||||
|
||||
#
|
||||
# Manual input control helper, fakes joystick input
|
||||
# > needs to correspond to default mapping in manual_input node
|
||||
#
|
||||
class ManualInput:
|
||||
|
||||
def __init__(self):
|
||||
rospy.init_node('test_node', anonymous=True)
|
||||
self.joyPx4 = rospy.Publisher('px4_multicopter/joy', Joy, queue_size=10)
|
||||
self.joyIris = rospy.Publisher('iris/joy', Joy, queue_size=10)
|
||||
|
||||
def arm(self):
|
||||
rate = rospy.Rate(10) # 10hz
|
||||
|
||||
msg = Joy()
|
||||
msg.header = Header()
|
||||
msg.buttons = [0, 0, 0, 0, 0]
|
||||
msg.axes = [-0.0, -0.0, 1.0, -0.0, -0.0, 0.0, 0.0]
|
||||
count = 0
|
||||
while not rospy.is_shutdown() and count < 10:
|
||||
rospy.loginfo("zeroing")
|
||||
self.joyPx4.publish(msg)
|
||||
self.joyIris.publish(msg)
|
||||
rate.sleep()
|
||||
count = count + 1
|
||||
|
||||
msg.buttons = [0, 0, 0, 0, 0]
|
||||
msg.axes = [-1.0, -0.0, 1.0, -0.0, -0.0, 0.0, 0.0]
|
||||
count = 0
|
||||
while not rospy.is_shutdown() and count < 10:
|
||||
rospy.loginfo("arming")
|
||||
self.joyPx4.publish(msg)
|
||||
self.joyIris.publish(msg)
|
||||
rate.sleep()
|
||||
count = count + 1
|
||||
|
||||
def posctl(self):
|
||||
rate = rospy.Rate(10) # 10hz
|
||||
|
||||
# triggers posctl
|
||||
msg = Joy()
|
||||
msg.header = Header()
|
||||
msg.buttons = [0, 0, 1, 0, 0]
|
||||
msg.axes = [-0.0, -0.0, 1.0, -0.0, -0.0, 0.0, 0.0]
|
||||
count = 0
|
||||
while not rospy.is_shutdown() and count < 10:
|
||||
rospy.loginfo("triggering posctl")
|
||||
self.joyPx4.publish(msg)
|
||||
self.joyIris.publish(msg)
|
||||
rate.sleep()
|
||||
count = count + 1
|
||||
Reference in New Issue
Block a user