def __init__(self): #Use the 'motor_twist' topic rospy.Subscriber('motor_twist', Twist, self.callback) self.speed_offset = 0.95 #Create two objects from the classes MotorSpeedLeft and MotorSpeedRight which exist in me416_utilities self.L_motor = mu.MotorSpeedLeft() self.R_motor = mu.MotorSpeedRight(self.speed_offset) #To adjust the variables before actually setting the motors self.setRight = 0 self.setLeft = 0
def __init__(self): #Use the 'motor_twist' topic rospy.Subscriber('motor_twist', Twist, self.callback) #Change this speed_offset if the robot is turning while both motors are set to the same value self.speed_offset = 1 #Create two objects from the classes MotorSpeedLeft and MotorSpeedRight which exist in me416_utilities self.L_motor=mu.MotorSpeedLeft() self.R_motor=mu.MotorSpeedRight(self.speed_offset) #To adjust the variables before actually setting the motors self.setRight = 0 self.setLeft = 0
def __init__(self): # Set up publishers and subscribers self.pub = rospy.Publisher('motor_speeds', MotorSpeedsStamped, queue_size=10) self.sub = rospy.Subscriber('robot_twist', Twist, callback=self.twist_callback, queue_size=10) # Set up the motor feedback object self.motor_cmd = MotorSpeedsStamped() # Set up the motor objects with an offset for the right motor self.speed_offset = 0.84 self.L_motor = mu.MotorSpeedLeft() self.R_motor = mu.MotorSpeedRight(self.speed_offset)
#!/usr/bin/env python import me416_utilities as mu # The motors will most likely not spin exactly at the same speed, this is a simple factor to attempt to account for this. # multiply the faster motor by this offset. speed_offset = 0.95 L_motor=mu.MotorSpeedLeft(speed_offset) R_motor=mu.MotorSpeedRight() def main(): L_motor.set_speed(0.0) R_motor.set_speed(0.0) if __name__ == '__main__': main()