def joy_callback(msg): global drive_pub, drive, X_SCALE, Y_SCALE drive = drive_msg() if msg.buttons[1]==1: drive.velocity = 0 else: drive.drive_angle = 255*msg.axes[3] #left && right drive.velocity = 255*msg.axes[1] #front && back drive_pub.publish(drive)
def __init__(self): rospy.init_node("potentialField") self.data = None self.cmd = drive_msg() self.camera_sub = rospy.Subscriber("/camera", Image, self.camera_callback) self.ML_sub = rospy.Subscriber("/teachable_machine", Float32MultiArray, self.machine_learning_callback) self.laser_sub = rospy.Subscriber("/scan", LaserScan, self.scan_callback) self.drive_pub = rospy.Publisher("/drive", drive_msg, queue_size=1) self.cartPoints = [None for x in range(500)] self.finalVector = [100, 0] self.max= 255
def joy_callback(msg): global mux_mode, mux_out_pub if msg.buttons[4] == 1: mux_mode = 'gamepad' #LB >> joy elif msg.buttons[5] ==1: mux_mode = 'autonomy' #RB >> auto #print("mux_mode: autonomy") else: mux_mode = '' #print("mux_mode: standby") drive=drive_msg() drive.velocity=0 drive.drive_angle=0 mux_out_pub.publish(drive)