/// <summary> /// Drive the specified rotations. /// </summary> /// <param name="leftRotations">Linear distance for the left motor to travel.</param> /// <param name="rightRotations">Linear distance for the right motor to travel.</param> public static void DriveRotations(double rightRotations) { SmartDashboard.PutNumber("Right Ticks", rightRotations); Right1.SetEncoderPostition(0); // Reset the encoder position to 0. Left1.SetEncoderPostition(0); // Reset the eoncoder position to 0. RobotMap.Right1.Set(rightRotations); RobotMap.Left1.Set(rightRotations); }
private void GetListDelivery(int pageIndex, int pageSize) { try { _DeliveryList = null; DeliveryIndexInput qsom = InitDeliveryIndexInput(); string msg = string.Empty; var c = PharmacyDatabaseService.GetDeliveryPaged(out pageInfo, out msg, qsom, pageIndex, pageSize); var result = from ds in ListStatus join i in c on ds.num equals i.DeliveryStatusValue join u in ListUser on i.AcceptedOperatorId equals u.Id into Left1 from u in Left1.DefaultIfEmpty() join u1 in ListUser on i.outedOperatorId equals u1.Id into Left2 from u1 in Left2.DefaultIfEmpty() join u2 in ListUser on i.SignedOperatorId equals u2.Id into Left3 from u2 in Left3.DefaultIfEmpty() select new Business.Models.DeliveryModel { AcceptedOperator = u == null ? "未受理" : u.Employee.Name, AcceptedTime = u == null ? i.CreateTime : i.AcceptedTime, DeliveryAddress = i.DeliveryAddress, DeliveryMethod = u == null ? "未受理" : (i.DeliveryMethodValue == 0 ? "客户自理" : i.DeliveryMethodValue == 1 ? "自有车辆运输" : "委托运输"), DeliveryStatus = ds.nam, DrugsCount = i.DrugsCount, ID = i.Id, outedOperator = u1 == null ? "未出库" : u1.Employee.Name, outedTime = u1 == null ? i.CreateTime : i.outedTime, Principal = u == null ? string.Empty : i.Principal, PrincipalPhone = u == null ? string.Empty : i.PrincipalPhone, ReceivingCompasnyID = i.ReceivingCompasnyID, ReceivingCompasnyName = i.ReceivingCompasnyName, SalesOrderID = i.OrderID, SalesOrderNumber = i.SalesOrder, ShippingAddress = i.ShippingAddress, SignedOperator = u2 == null ? "未签收" : u2.Employee.Name, SignedTime = u2 == null ? i.CreateTime : i.SignedTime, TransportCompany = u == null ? string.Empty : i.TransportCompany, TransportMethod = u == null ? "未受理" : (i.TransportMethodValue == 0 ? "客户自理" : i.TransportMethodValue == 1 ? "自有车辆运输" : "委托运输"), VehicleInfo = u == null ? string.Empty : i.VehicleInfo, Memo = i.Memo }; this.dgvMain.DataSource = result.ToList(); pcMain.RecordCount = pageInfo.RecordCount; this.HideColumns(); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK); Log.Error(ex); } }
public static void DriveFast(double desiredDistance) { AutoFunctions.ConfigureTalon(Right1, ConfigureType.Position, new EncoderParameters { AllowedError = 0, Device = CANTalon.FeedbackDevice.CtreMagEncoderRelative, NominalVoltage = 0.0f, PeakVoltage = 12f * .7f, PIDFValues = new PIDF { kP = 0.151, kI = 0, kD = 0, kF = 0 }, ReverseSensor = false }); AutoFunctions.ConfigureTalon(Left1, ConfigureType.Position, new EncoderParameters { AllowedError = 0, Device = CANTalon.FeedbackDevice.CtreMagEncoderRelative, NominalVoltage = 0.0f, PeakVoltage = 12f * .9f, PIDFValues = new PIDF { kP = 0.151, kI = 0, kD = 0, kF = 0 }, ReverseSensor = true }); Right1.SetEncoderPostition(0); // Reset the encoder position to 0. Left1.SetEncoderPostition(0); // Reset the eoncoder position to 0. // Converts meters to inches. double desiredInches = 39.3701 * desiredDistance; // Converts inches to rotations. double rotations = desiredInches / 3.29; // 3.29 inches per rotation. // Gets the displacement of the motors to set. double left = /*(RobotMap.Left1 .GetEncoderPosition() / 4096 * 39.3701 / 3.29) + */ rotations; double right = /*(RobotMap.Right1.GetEncoderPosition() / 4096 * 39.3701 / 3.29) + */ rotations; // Drive with the specified distance. DriveRotations(left); SmartDashboard.PutNumber("Encoder Distance", rotations); }
/// <summary> /// Initializes the AutoHandler. /// </summary> protected override void Init() { // Instantiates AutoHandler. AutoHandler = new Handler(); //Sets the CAN Talons to rely off of the encoders for movement. AutoFunctions.ConfigureTalon(Right1, ConfigureType.Position, new EncoderParameters { AllowedError = 0, Device = CANTalon.FeedbackDevice.CtreMagEncoderRelative, NominalVoltage = 0.0f, PeakVoltage = 12.0f, PIDFValues = new PIDF { kP = 0.151, kI = 0, kD = 0, kF = 0 }, ReverseSensor = false }); AutoFunctions.ConfigureTalon(Left1, ConfigureType.Position, new EncoderParameters { AllowedError = 0, Device = CANTalon.FeedbackDevice.CtreMagEncoderRelative, NominalVoltage = 0.0f, PeakVoltage = 12.0f, //3.4f PIDFValues = new PIDF { kP = 0.151, kI = 0, kD = 0, kF = 0 }, ReverseSensor = true }); Right1.SetEncoderPostition(0); // Reset the encoder position to 0. Right1.ReverseOutput(true); // Reverse the direction of the motor. Right2.MotorControlMode = WPILib.Interfaces.ControlMode.Follower; Right2.Set(Right1.DeviceId); // Configure the second right talon to be a follower of the other right talon. Left1.SetEncoderPostition(0); // Reset the eoncoder position to 0. Left1.ReverseOutput(false); // Reverse the direction of the motor. Left1.ReverseSensor(true); Left2.MotorControlMode = WPILib.Interfaces.ControlMode.Follower; Left2.Set(Left1.DeviceId); // Configure the second left talon to be a follower of the other left talon. NavX.Reset(); // Reset the NavX's yaw value to zero. }
/// <summary> /// Runs the auto handler. /// </summary> protected override void Main() { Right1.SetEncoderPostition(0); // Reset the encoder position to 0. Left1.SetEncoderPostition(0); // Reset the eoncoder position to 0. // Runs the selected autonomous. //AutoHandler.RunAuto(Handler.AutoPosition.Disabled); // Both down. 0b00 if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5) { SmartConsole.PrintInfo("Currently running disabled autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance."); AutoHandler.RunAuto(Handler.AutoPosition.Disabled); } // Left stick down, right stick up. 0b01 else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5) { SmartConsole.PrintInfo("Currently running position 1 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance."); AutoHandler.RunAuto(Handler.AutoPosition.Position1); } // Left stick up, right stick down. 0b10 else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) < 0.5) { SmartConsole.PrintInfo("Currently running position 2 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance."); AutoHandler.RunAuto(Handler.AutoPosition.Position2); /*DriveTrain.Move(.65, .70); * * Snooze(2500); * * DriveTrain.StopMotor(); * * GearSlot.Set(true); * * while (true) Snooze(1);*/ } // Left stick up, right stick up. 0b11 else if (DriveStick_Left.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5 && DriveStick_Right.GetAxis(WPILib.Joystick.AxisType.Z) > 0.5) { SmartConsole.PrintInfo("Currently running position 3 autonomous on the " + DriverStation.Instance.GetAlliance() + " alliance."); AutoHandler.RunAuto(Handler.AutoPosition.Position3); } }