Struct ctre::motor_control::VictorSPX
source · pub struct VictorSPX { /* private fields */ }
Expand description
VEX Victor SPX Motor Controller when used on CAN Bus.
Trait Implementations§
source§impl BaseMotorController for VictorSPX
impl BaseMotorController for VictorSPX
fn handle(&self) -> Handle
fn get_base_id(&self) -> i32
fn get_device_id(&self) -> i32
source§fn set(
&self,
mode: ControlMode,
demand0: f64,
demand1_type: DemandType,
demand1: f64
)
fn set(
&self,
mode: ControlMode,
demand0: f64,
demand1_type: DemandType,
demand1: f64
)
mode
- Sets the appropriate output on the talon, depending on the mode.demand0
- The output value to apply.
such as advanced feed forward and/or auxiliary close-looping in firmware.
demand1Type
- The demand type for demand1.demand1
- Supplmental output value. Units match the set mode.source§fn neutral_output(&self)
fn neutral_output(&self)
Neutral the motor output by setting control mode to disabled.
source§fn set_neutral_mode(&self, neutral_mode: NeutralMode)
fn set_neutral_mode(&self, neutral_mode: NeutralMode)
Sets the mode of operation during neutral throttle output.
source§fn set_sensor_phase(&self, phase_sensor: bool)
fn set_sensor_phase(&self, phase_sensor: bool)
Sets the phase of the sensor. Use when controller forward/reverse output
doesn’t correlate to appropriate forward/reverse reading of sensor.
Pick a value so that positive PercentOutput yields a positive change in sensor.
After setting this, user can freely call
set_inverted
with any value. Read moresource§fn set_inverted(&self, invert: bool)
fn set_inverted(&self, invert: bool)
Inverts the hbridge output of the motor controller. Read more
fn config_openloop_ramp(
&self,
seconds_from_neutral_to_full: f64,
timeout_ms: i32
) -> ErrorCode
fn config_closedloop_ramp(
&self,
seconds_from_neutral_to_full: f64,
timeout_ms: i32
) -> ErrorCode
fn config_peak_output_forward(
&self,
percent_out: f64,
timeout_ms: i32
) -> ErrorCode
fn config_peak_output_reverse(
&self,
percent_out: f64,
timeout_ms: i32
) -> ErrorCode
fn config_nominal_output_forward(
&self,
percent_out: f64,
timeout_ms: i32
) -> ErrorCode
fn config_nominal_output_reverse(
&self,
percent_out: f64,
timeout_ms: i32
) -> ErrorCode
fn config_neutral_deadband(
&self,
percent_deadband: f64,
timeout_ms: i32
) -> ErrorCode
source§fn config_voltage_comp_saturation(
&self,
voltage: f64,
timeout_ms: i32
) -> ErrorCode
fn config_voltage_comp_saturation(
&self,
voltage: f64,
timeout_ms: i32
) -> ErrorCode
Configures the Voltage Compensation saturation voltage. Read more
source§fn config_voltage_measurement_filter(
&self,
filter_window_samples: i32,
timeout_ms: i32
) -> ErrorCode
fn config_voltage_measurement_filter(
&self,
filter_window_samples: i32,
timeout_ms: i32
) -> ErrorCode
Configures the voltage measurement filter. Read more
source§fn enable_voltage_compensation(&self, enable: bool)
fn enable_voltage_compensation(&self, enable: bool)
Enable voltage compensation.
If enabled, voltage compensation works in all control modes. Read more
fn get_bus_voltage(&self) -> Result<f64>
source§fn get_motor_output_percent(&self) -> Result<f64>
fn get_motor_output_percent(&self) -> Result<f64>
Gets the output percentage of the motor controller, in the interval [-1,+1].
fn get_motor_output_voltage(&self) -> Result<f64>
fn get_output_current(&self) -> Result<f64>
source§fn get_temperature(&self) -> Result<f64>
fn get_temperature(&self) -> Result<f64>
Gets the temperature of the motor controller in degrees Celsius.
source§fn config_selected_feedback_sensor(
&self,
feedback_device: RemoteFeedbackDevice,
pid_idx: i32,
timeout_ms: i32
) -> ErrorCode
fn config_selected_feedback_sensor(
&self,
feedback_device: RemoteFeedbackDevice,
pid_idx: i32,
timeout_ms: i32
) -> ErrorCode
Select the remote feedback device for the motor controller.
Most CTRE CAN motor controllers will support remote sensors over CAN. Read more
source§fn config_selected_feedback_coefficient(
&self,
coefficient: f64,
pid_idx: i32,
timeout_ms: i32
) -> ErrorCode
fn config_selected_feedback_coefficient(
&self,
coefficient: f64,
pid_idx: i32,
timeout_ms: i32
) -> ErrorCode
The Feedback Coefficient is a scalar applied to the value of the
feedback sensor. Useful when you need to scale your sensor values
within the closed-loop calculations. Default value is 1. Read more
source§fn config_remote_feedback_filter(
&self,
device_id: i32,
remote_sensor_source: RemoteSensorSource,
remote_ordinal: i32,
timeout_ms: i32
) -> ErrorCode
fn config_remote_feedback_filter(
&self,
device_id: i32,
remote_sensor_source: RemoteSensorSource,
remote_ordinal: i32,
timeout_ms: i32
) -> ErrorCode
Select what remote device and signal to assign to Remote Sensor 0 or Remote Sensor 1.
After binding a remote device and signal to Remote Sensor X, you may select Remote Sensor X
as a PID source for closed-loop features. Read more
source§fn config_sensor_term(
&self,
sensor_term: SensorTerm,
feedback_device: FeedbackDevice,
timeout_ms: i32
) -> ErrorCode
fn config_sensor_term(
&self,
sensor_term: SensorTerm,
feedback_device: FeedbackDevice,
timeout_ms: i32
) -> ErrorCode
Select what sensor term should be bound to switch feedback device.
Sensor Sum = Sensor Sum Term 0 - Sensor Sum Term 1
Sensor Difference = Sensor Diff Term 0 - Sensor Diff Term 1
The four terms are specified with this routine. Then Sensor Sum/Difference
can be selected for closed-looping. Read more
source§fn get_selected_sensor_position(&self, pid_idx: i32) -> Result<i32>
fn get_selected_sensor_position(&self, pid_idx: i32) -> Result<i32>
Get the selected sensor position (in raw sensor units).
fn get_selected_sensor_velocity(&self, pid_idx: i32) -> Result<i32>
fn set_selected_sensor_position(
&self,
sensor_pos: i32,
pid_idx: i32,
timeout_ms: i32
) -> ErrorCode
fn set_control_frame_period(
&self,
frame: ControlFrame,
period_ms: i32
) -> ErrorCode
fn set_status_frame_period(
&self,
frame: StatusFrame,
period_ms: i32,
timeout_ms: i32
) -> ErrorCode
fn get_status_frame_period(
&self,
frame: StatusFrame,
timeout_ms: i32
) -> Result<i32>
source§fn config_forward_limit_switch_source(
&self,
type_: RemoteLimitSwitchSource,
normal_open_or_close: LimitSwitchNormal,
device_id: i32,
timeout_ms: i32
) -> ErrorCode
fn config_forward_limit_switch_source(
&self,
type_: RemoteLimitSwitchSource,
normal_open_or_close: LimitSwitchNormal,
device_id: i32,
timeout_ms: i32
) -> ErrorCode
Configures the forward limit switch for a remote source.
For example, a CAN motor controller may need to monitor the Limit-F pin
of another Talon or CANifier. Read more
source§fn config_reverse_limit_switch_source(
&self,
type_: RemoteLimitSwitchSource,
normal_open_or_close: LimitSwitchNormal,
device_id: i32,
timeout_ms: i32
) -> ErrorCode
fn config_reverse_limit_switch_source(
&self,
type_: RemoteLimitSwitchSource,
normal_open_or_close: LimitSwitchNormal,
device_id: i32,
timeout_ms: i32
) -> ErrorCode
Configures the reverse limit switch for a remote source.
For example, a CAN motor controller may need to monitor the Limit-R pin
of another Talon or CANifier. Read more
fn override_limit_switches_enable(&self, enable: bool)
fn config_forward_soft_limit_threshold(
&self,
forward_sensor_limit: i32,
timeout_ms: i32
) -> ErrorCode
fn config_reverse_soft_limit_threshold(
&self,
reverse_sensor_limit: i32,
timeout_ms: i32
) -> ErrorCode
fn config_forward_soft_limit_enable(
&self,
enable: bool,
timeout_ms: i32
) -> ErrorCode
fn config_reverse_soft_limit_enable(
&self,
enable: bool,
timeout_ms: i32
) -> ErrorCode
fn override_soft_limits_enable(&self, enable: bool)
fn config_kp(&self, slot_idx: i32, value: f64, timeout_ms: i32) -> ErrorCode
fn config_ki(&self, slot_idx: i32, value: f64, timeout_ms: i32) -> ErrorCode
fn config_kd(&self, slot_idx: i32, value: f64, timeout_ms: i32) -> ErrorCode
fn config_kf(&self, slot_idx: i32, value: f64, timeout_ms: i32) -> ErrorCode
fn config_integral_zone(
&self,
slot_idx: i32,
izone: i32,
timeout_ms: i32
) -> ErrorCode
fn config_allowable_closedloop_error(
&self,
slot_idx: i32,
allowable_closed_loop_error: i32,
timeout_ms: i32
) -> ErrorCode
fn config_max_integral_accumulator(
&self,
slot_idx: i32,
iaccum: f64,
timeout_ms: i32
) -> ErrorCode
fn config_closed_loop_peak_output(
&self,
slot_idx: i32,
percent_out: f64,
timeout_ms: i32
) -> ErrorCode
fn config_closed_loop_period(
&self,
slot_idx: i32,
loop_time_ms: i32,
timeout_ms: i32
) -> ErrorCode
fn config_aux_pid_polarity(&self, invert: bool, timeout_ms: i32) -> ErrorCode
fn set_integral_accumulator(
&self,
iaccum: f64,
pid_idx: i32,
timeout_ms: i32
) -> ErrorCode
fn get_closed_loop_error(&self, pid_idx: i32) -> Result<i32>
fn get_integral_accumulator(&self, pid_idx: i32) -> Result<f64>
source§fn get_error_derivative(&self, pid_idx: i32) -> Result<f64>
fn get_error_derivative(&self, pid_idx: i32) -> Result<f64>
Gets the derivative of the closed-loop error.
source§fn select_profile_slot(&self, slot_idx: i32, pid_idx: i32) -> ErrorCode
fn select_profile_slot(&self, slot_idx: i32, pid_idx: i32) -> ErrorCode
Selects which profile slot to use for closed-loop control.
fn get_closed_loop_target(&self, pid_idx: i32) -> Result<i32>
source§fn get_active_trajectory_position(&self) -> Result<i32>
fn get_active_trajectory_position(&self) -> Result<i32>
Gets the active trajectory target position using MotionMagic/MotionProfile control modes.
source§fn get_active_trajectory_velocity(&self) -> Result<i32>
fn get_active_trajectory_velocity(&self) -> Result<i32>
Gets the active trajectory target velocity using MotionMagic/MotionProfile control modes.
source§fn get_active_trajectory_heading(&self) -> Result<f64>
fn get_active_trajectory_heading(&self) -> Result<f64>
Gets the active trajectory target heading using MotionMagic/MotionProfile control modes.
source§fn config_motion_cruise_velocity(
&self,
sensor_units_per_100ms: i32,
timeout_ms: i32
) -> ErrorCode
fn config_motion_cruise_velocity(
&self,
sensor_units_per_100ms: i32,
timeout_ms: i32
) -> ErrorCode
Sets the Motion Magic Cruise Velocity.
This is the peak target velocity that the motion magic curve generator can use. Read more
source§fn config_motion_acceleration(
&self,
sensor_units_per_100ms_per_sec: i32,
timeout_ms: i32
) -> ErrorCode
fn config_motion_acceleration(
&self,
sensor_units_per_100ms_per_sec: i32,
timeout_ms: i32
) -> ErrorCode
Sets the Motion Magic Acceleration.
This is the target acceleration that the motion magic curve generator can use. Read more
source§fn clear_motion_profile_trajectories(&self) -> ErrorCode
fn clear_motion_profile_trajectories(&self) -> ErrorCode
Clear the buffered motion profile in both motor controller’s RAM (bottom),
and in the API (top). Read more
source§fn get_motion_profile_top_level_buffer_count(&self) -> Result<i32>
fn get_motion_profile_top_level_buffer_count(&self) -> Result<i32>
Retrieve just the buffer count for the api-level (top) buffer.
This routine performs no CAN or data structure lookups, so its fast and ideal
if caller needs to quickly poll the progress of trajectory points being
emptied into motor controller’s RAM. Otherwise just use
get_motion_profile_status
. Read moresource§fn push_motion_profile_trajectory(&self, traj_pt: &TrajectoryPoint) -> ErrorCode
fn push_motion_profile_trajectory(&self, traj_pt: &TrajectoryPoint) -> ErrorCode
Push another trajectory point into the top level buffer (which is emptied
into the motor controller’s bottom buffer as room allows). Read more
source§fn is_motion_profile_top_level_buffer_full(&self) -> Result<bool>
fn is_motion_profile_top_level_buffer_full(&self) -> Result<bool>
Retrieve just the buffer full for the api-level (top) buffer.
This routine performs no CAN or data structure lookups, so its fast and ideal
if caller needs to quickly poll. Otherwise just use
get_motion_profile_status
. Read moresource§fn process_motion_profile_buffer(&self)
fn process_motion_profile_buffer(&self)
This must be called periodically to funnel the trajectory points from the
API’s top level buffer to the controller’s bottom level buffer. Recommendation
is to call this twice as fast as the execution rate of the motion profile.
So if MP is running with 20ms trajectory points, try calling this routine
every 10ms. All motion profile functions are thread-safe through the use of
a mutex, so there is no harm in having the caller utilize threading. Read more
source§fn get_motion_profile_status(
&self,
status_to_fill: &mut MotionProfileStatus
) -> ErrorCode
fn get_motion_profile_status(
&self,
status_to_fill: &mut MotionProfileStatus
) -> ErrorCode
Retrieve all status information.
For best performance, Caller can snapshot all status information regarding the
motion profile executer. Read more
source§fn get_new_motion_profile_status(&self) -> Result<MotionProfileStatus>
fn get_new_motion_profile_status(&self) -> Result<MotionProfileStatus>
Get all motion profile status information. This returns a new MotionProfileStatus.
See
get_motion_profile_status
. Read moresource§fn clear_motion_profile_has_underrun(&self, timeout_ms: i32) -> ErrorCode
fn clear_motion_profile_has_underrun(&self, timeout_ms: i32) -> ErrorCode
Clear the “Has Underrun” flag.
Typically this is called after application has confirmed an underrun had occured. Read more
source§fn change_motion_control_frame_period(&self, period_ms: i32) -> ErrorCode
fn change_motion_control_frame_period(&self, period_ms: i32) -> ErrorCode
Calling application can opt to speed up the handshaking between the robot API
and the controller to increase the download rate of the controller’s Motion Profile.
Ideally the period should be no more than half the period of a trajectory
point. Read more
source§fn config_motion_profile_trajectory_period(
&self,
base_traj_duration_ms: i32,
timeout_ms: i32
) -> ErrorCode
fn config_motion_profile_trajectory_period(
&self,
base_traj_duration_ms: i32,
timeout_ms: i32
) -> ErrorCode
When trajectory points are processed in the motion profile executer, the MPE determines
how long to apply the active trajectory point by summing
base_traj_duration_ms
with the
time_dur
of the trajectory point (see TrajectoryPoint
). Read moresource§fn get_last_error(&self) -> ErrorCode
fn get_last_error(&self) -> ErrorCode
Gets the last error generated by this object.
Not all functions return an error code but can potentially report errors.
This function can be used to retrieve those error codes. Read more
fn get_faults(&self) -> Result<Faults>
fn get_sticky_faults(&self) -> Result<StickyFaults>
fn clear_sticky_faults(&self, timeout_ms: i32) -> ErrorCode
source§fn get_firmware_version(&self) -> Result<i32>
fn get_firmware_version(&self) -> Result<i32>
Gets the firmware version of the device. Read more
source§fn has_reset_occurred(&self) -> Result<bool>
fn has_reset_occurred(&self) -> Result<bool>
Returns true if the device has reset since last call.
source§fn config_set_custom_param(
&self,
new_value: i32,
param_index: i32,
timeout_ms: i32
) -> ErrorCode
fn config_set_custom_param(
&self,
new_value: i32,
param_index: i32,
timeout_ms: i32
) -> ErrorCode
Sets the value of a custom parameter. This is for arbitrary use. Read more
source§fn config_get_custom_param(&self, param_index: i32, timout_ms: i32) -> Result<i32>
fn config_get_custom_param(&self, param_index: i32, timout_ms: i32) -> Result<i32>
Gets the value of a custom parameter. Read more
source§fn config_set_parameter(
&self,
param: ParamEnum,
value: f64,
sub_value: u8,
ordinal: i32,
timeout_ms: i32
) -> ErrorCode
fn config_set_parameter(
&self,
param: ParamEnum,
value: f64,
sub_value: u8,
ordinal: i32,
timeout_ms: i32
) -> ErrorCode
Sets a parameter. Generally this is not used.
This can be utilized in Read more
fn config_get_parameter(
&self,
param: ParamEnum,
ordinal: i32,
timeout_ms: i32
) -> Result<f64>
source§fn follow(
&self,
master_to_follow: &impl BaseMotorController,
follower_type: FollowerType
)
fn follow(
&self,
master_to_follow: &impl BaseMotorController,
follower_type: FollowerType
)
Set the control mode and output value so that this motor controller will
follow another motor controller.
Currently supports following Victor SPX and Talon SRX. Read more