Created
March 12, 2023 18:52
-
-
Save joshua-8/63c00aee4528786558835b61ec5def2c to your computer and use it in GitHub Desktop.
optical_flow_node_replacer.py is a ros node that can be used instead of the optical_flow_node in pidrone_pkg/scripts to publish a zero velocity and fly with no camera.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
optical_flow_node_replacer.py is a ros node that can be used instead of the optical_flow_node in pidrone_pkg/scripts to publish a zero velocity and fly with no camera. | |
JoshuaPhelps127@gmail.com 2023-03-10 | |
""" | |
import rospy | |
from geometry_msgs.msg import TwistStamped | |
class OpticalFlowNode(object): | |
def __init__(self, node_name): | |
rospy.init_node(node_name) | |
self.twistpub = rospy.Publisher('/pidrone/picamera/twist', TwistStamped, queue_size=1) | |
def main(): | |
optical_flow_node = OpticalFlowNode("optical_flow_node") | |
r = rospy.Rate(25) | |
print("starting to publish 0 velocity to /pidrone/picamera/twist") | |
while not rospy.is_shutdown(): | |
twist_msg = TwistStamped() | |
twist_msg.header.stamp = rospy.Time.now() | |
twist_msg.twist.linear.x = 0 | |
twist_msg.twist.linear.y = 0 | |
optical_flow_node.twistpub.publish(twist_msg) | |
r.sleep() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment