How to use the sardana.util.motion.MotionPath function in sardana

To help you get started, we’ve selected a few sardana examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sardana-org / sardana / src / sardana / macroserver / scan / gscan.py View on Github external
real_vmotor = VMotor(min_vel=base_vel, max_vel=max_top_vel,
                                 accel_time=accel_time,
                                 decel_time=decel_time)
            real_path = MotionPath(real_vmotor, last_user_pos, position)
            real_path.moveable = moveable
            real_path.apply_correction = coordinate

            # Find the cruise duration of motion at top velocity. For this
            # create a virtual motor which has instantaneous acceleration and
            # deceleration
            ideal_vmotor = VMotor(min_vel=base_vel, max_vel=max_top_vel,
                                  accel_time=0, decel_time=0)

            # create a path which will tell us which is the cruise
            # duration of this motion at top velocity
            ideal_path = MotionPath(ideal_vmotor, last_user_pos, position)
            ideal_path.moveable = moveable
            ideal_path.apply_correction = coordinate

            # if really motor is moving in this waypoint
            if ideal_path.displacement > 0:
                # recalculate time to reach maximum velocity
                delta_start = max(delta_start, accel_time)

            # recalculate cruise duration of motion at top velocity
            cruise_duration = max(cruise_duration, ideal_path.duration)
            duration = max(duration, real_path.duration)

            ideal_paths.append(ideal_path)
            real_paths.append(real_path)

        if slow_down <= 0:
github sardana-org / sardana / src / sardana / macroserver / scan / gscan.py View on Github external
point_nb = 0
        interval_nb = None
        try:
            if not with_time:
                try:
                    start_pos = self.motion.readPosition(force=True)
                    v_motors = self.get_virtual_motors()
                    motion_time, acq_time = 0.0, 0.0
                    while point_nb < max_iter:
                        step = next(iterator)
                        end_pos = step['positions']
                        max_path_duration = 0.0
                        for v_motor, start, stop in zip(v_motors,
                                                        start_pos,
                                                        end_pos):
                            path = MotionPath(v_motor, start, stop)
                            max_path_duration = max(
                                max_path_duration, path.duration)
                        integ_time = step.get("integ_time", 0.0)
                        acq_time += integ_time
                        motion_time += max_path_duration
                        total_time += integ_time + max_path_duration
                        point_nb += 1
                        start_pos = end_pos
                finally:
                    if with_interval:
                        interval_nb = self.macro.getIntervalEstimation()
            else:
                try:
                    while point_nb < max_iter:
                        step = next(iterator)
                        point_nb += 1
github taurus-org / taurus / src / sardana / macroserver / scan / gscan.py View on Github external
self.macro.debug("Motor: %s" % motor.getName())
            self.macro.debug("AccTime: %f" % self.get_min_acc_time(motor))
            self.macro.debug("DecTime: %f" % self.get_min_dec_time(motor))
            max_acc_time = max(self.get_min_acc_time(motor), max_acc_time)
            max_dec_time = max(self.get_min_dec_time(motor), max_dec_time)
            
        acc_time = max_acc_time
        dec_time = max_dec_time
            
        for moveable, start_position, end_position in \
                      zip(self._physical_moveables, start_positions, positions):
            base_vel = moveable.getBaseRate()        
            ideal_vmotor = VMotor(accel_time=acc_time,
                                  decel_time=dec_time,
                                  min_vel=base_vel)
            ideal_path = MotionPath(ideal_vmotor, 
                                    start_position, 
                                    end_position, 
                                    active_time)            
            ideal_path.moveable = moveable
            ideal_path.apply_correction = True        
            ideal_paths.append(ideal_path)                                 
        
        return ideal_paths, acc_time, active_time
github sardana-org / sardana / src / sardana / macroserver / macros / scan.py View on Github external
def getTimeEstimation(self):
        gScan = self._gScan
        mode = self.mode
        it = gScan.generator()
        v_motors = gScan.get_virtual_motors()
        curr_pos = gScan.motion.readPosition()
        total_time = 0.0
        if mode == StepMode:
            # calculate motion time
            max_step0_time, max_step_time = 0.0, 0.0
            # first motion takes longer, all others should be "equal"
            step0 = it.next()
            for v_motor, start, stop, length in zip(v_motors, curr_pos,
                                                    step0['positions'],
                                                    self.interv_sizes):
                path0 = MotionPath(v_motor, start, stop)
                path = MotionPath(v_motor, 0, length)
                max_step0_time = max(max_step0_time, path0.duration)
                max_step_time = max(max_step_time, path.duration)
            motion_time = max_step0_time + self.nr_interv * max_step_time
            # calculate acquisition time
            acq_time = self.nr_points * self.integ_time
            total_time = motion_time + acq_time

        elif mode == ContinuousMode:
            total_time = gScan.waypoint_estimation()
        # TODO: add time estimation for ContinuousHwTimeMode
        return total_time
github sardana-org / sardana / src / sardana / macroserver / scan / gscan.py View on Github external
real_vmotor = VMotor(min_vel=base_vel, max_vel=max_top_vel,
                                 accel_time=accel_time,
                                 decel_time=decel_time)
            real_path = MotionPath(real_vmotor, last_user_pos, position)
            real_path.moveable = moveable
            real_path.apply_correction = coordinate

            # Find the cruise duration of motion at top velocity. For this
            # create a virtual motor which has instantaneous acceleration and
            # deceleration
            ideal_vmotor = VMotor(min_vel=base_vel, max_vel=max_top_vel,
                                  accel_time=0, decel_time=0)

            # create a path which will tell us which is the cruise
            # duration of this motion at top velocity
            ideal_path = MotionPath(ideal_vmotor, last_user_pos, position)
            ideal_path.moveable = moveable
            ideal_path.apply_correction = coordinate

            # if really motor is moving in this waypoint
            if ideal_path.displacement > 0:
                # recalculate time to reach maximum velocity
                delta_start = max(delta_start, accel_time)

            # recalculate cruise duration of motion at top velocity
            cruise_duration = max(cruise_duration, ideal_path.duration)
            duration = max(duration, real_path.duration)

            ideal_paths.append(ideal_path)
            real_paths.append(real_path)

        if slow_down <= 0:
github sardana-org / sardana / src / sardana / macroserver / scan / gscan.py View on Github external
dec_time = max_dec_time

        for moveable, start, end in \
                zip(self._physical_moveables, start_positions, positions):
            total_displacement = abs(end - start)
            direction = 1 if end > start else -1
            interval_displacement = total_displacement / self.macro.nr_interv
            # move further in order to acquire the last point at constant
            # velocity
            end = end + direction * interval_displacement

            base_vel = moveable.getBaseRate()
            ideal_vmotor = VMotor(accel_time=acc_time,
                                  decel_time=dec_time,
                                  min_vel=base_vel)
            ideal_path = MotionPath(ideal_vmotor, start, end, active_time)

            # check if calculated ideal velocity is accepted by hardware
            backup_vel = moveable.getVelocity(force=True)
            ideal_max_vel = try_vel = ideal_path.max_vel
            try:
                while True:
                    moveable.setVelocity(try_vel)
                    get_vel = moveable.getVelocity(force=True)
                    if get_vel < ideal_max_vel:
                        msg = 'Ideal scan velocity {0} of motor {1} cannot ' \
                              'be reached, {2} will be used instead'.format(
                                  ideal_max_vel, moveable.name, get_vel)
                        self.macro.warning(msg)
                        ideal_path.max_vel = get_vel
                        break
                    elif get_vel > ideal_max_vel:
github taurus-org / taurus / src / sardana / macroserver / scan / gscan.py View on Github external
real_vmotor = VMotor(min_vel=base_vel, max_vel=max_top_vel,
                                 accel_time=accel_time,
                                 decel_time=decel_time)
            real_path = MotionPath(real_vmotor, last_user_pos, position)
            real_path.moveable = moveable            
            real_path.apply_correction = coordinate
            
            # Find the cruise duration of motion at top velocity. For this create a
            # virtual motor which has instantaneous acceleration and deceleration
            ideal_vmotor = VMotor(min_vel=base_vel, max_vel=max_top_vel,
                                  accel_time=0, decel_time=0)
            
            # create a path which will tell us which is the cruise duration of this
            # motion at top velocity
            ideal_path = MotionPath(ideal_vmotor, last_user_pos, position)
            ideal_path.moveable = moveable
            ideal_path.apply_correction = coordinate
            
            # if really motor is moving in this waypoint
            if ideal_path.displacement > 0:
                # recalculate time to reach maximum velocity
                delta_start = max(delta_start, accel_time)
            
            # recalculate cruise duration of motion at top velocity
            cruise_duration = max(cruise_duration, ideal_path.duration)
            duration = max(duration, real_path.duration)
            
            ideal_paths.append(ideal_path)
            real_paths.append(real_path)
            
        if slow_down <= 0: