Ejemplo n.º 1
0
        private void SetupDrives(uint side, float phaseTarget, float elapsedSeconds_reciprocal, float rpmSide)
        {
            for (uint ii = 0; ii < phaseCount; ii++)            //column
            {
                for (uint iii = 0; iii < driveIdCount; iii++)   //id
                {
                    uint        indexDrive = IndexDrive(side, ii, iii);
                    DriveConfig drive      = drives[indexDrive];

                    //calculate target angle based on phase
                    float                     //0..2pi
                        target = NormaliseRadians_2Pi(phaseTarget - (ii * phaseSize));
                    float                     //-pi..pi
                        error = NormaliseRadians_Pi(NormaliseRadians_Pi(drives[indexDrive].TrueAngle) - target);

                    float
                        correction = status.driveControllers[indexDrive].Update(error, elapsedSeconds_reciprocal);
                    float
                        velocity = MyMath.Clamp(rpmSide + correction, 0.0f, rpmMax);

                    MotorStator.SetVelocity(drive.drive,
                                            drive.inverted ? -velocity : velocity);
                }
            }
        }
Ejemplo n.º 2
0
        public ResultBean DriveItem(int id)
        {
            Console.WriteLine(id);
            DriveConfig driveConfig = systemManager.GetDriveConfigById(id);

            return(ResultBean.Success(driveConfig));
        }
Ejemplo n.º 3
0
 public void AddDrive(DriveConfig drive)
 {
     if (!_drives.TryAdd(drive.Root[0], new DriveMounter(_user.Username, drive, _logger)))
     {
         throw new InvalidOperationException($"Drive already exists: {drive.Root}");
     }
 }
Ejemplo n.º 4
0
 void Start()
 {
     joint  = GetComponent <HingeJoint>();
     config = GetComponentInParent <DriveConfig>();
     if (config != null)
     {
         config.onConfigChange.AddListener(OnConfigModified);
         OnConfigModified(config);
     }
 }
Ejemplo n.º 5
0
 public bool EditDrive(DriveConfig driveConfig)
 {
     using (var context = new CustomZfileDbContext())
     {
         Drive d = context.drive.Find(driveConfig.id);
         if (d == null)
         {
             return(false);
         }
         d.name = driveConfig.name;
         context.drive.Update(d);
         context.SaveChanges();
     }
     return(true);
 }
Ejemplo n.º 6
0
 public ResultBean EditDrive(DriveConfig driveConfig)
 {
     if (driveConfig.id == null)
     {
         int userId;
         if (int.TryParse(SystemManager.Decrypt(HttpContext.Request.Cookies["userId"]), out userId))
         {
             systemManager.SaveNewDrive(driveConfig.name, userId);
             return(ResultBean.Success());
         }
     }
     else
     {
         if (systemManager.EditDrive(driveConfig))
         {
             return(ResultBean.Success());
         }
     }
     return(ResultBean.Error("未知错误"));
 }
Ejemplo n.º 7
0
    void OnConfigModified(DriveConfig config)
    {
        if (joint == null || config == null)
        {
            return;
        }
        // set joint limits/params bsaed on public vars
        var limits = joint.limits;

        limits.min      = -config.steeringMaxAngle;
        limits.max      = config.steeringMaxAngle;
        joint.limits    = limits;
        joint.useLimits = true;
        var hingeSpring = joint.spring;

        hingeSpring.spring         = config.steeringMaxTorque;
        hingeSpring.damper         = config.steeringDamper;
        hingeSpring.targetPosition = 0;
        joint.spring    = hingeSpring;
        joint.useSpring = true;
    }
 void Start()
 {
     rb     = GetComponent <Rigidbody>();
     config = GetComponentInParent <DriveConfig>();
 }
Ejemplo n.º 9
0
 public DriveMounter(string username, DriveConfig driveConfig, ILogger logger)
 {
     _username = username;
     _config   = driveConfig;
     _logger   = logger;
 }