pub struct Cartesian<'a> {
pub robot: &'a KinematicsWithShape,
pub check_step_m: f64,
pub check_step_rad: f64,
pub max_transition_cost: f64,
pub transition_coefficients: Joints,
pub linear_recursion_depth: usize,
pub rrt: RRTPlanner,
pub include_linear_interpolation: bool,
pub debug: bool,
}
Expand description
Class doing Cartesian planning
Fields§
§robot: &'a KinematicsWithShape
§check_step_m: f64
Check step size in meters. Objects and features of the robotic cell smaller than this may not be noticed during collision checks.
check_step_rad: f64
Check step size in radians. Objects and features of the robotic cell smaller than this may not be noticed during collision checks.
max_transition_cost: f64
Maximum allowed transition cost between Joints
transition_coefficients: Joints
Transition cost coefficients (smaller joints are allowed to rotate more)
linear_recursion_depth: usize
If movement between adjacent poses results transition costs over this threshold, the Cartesian segment is divided by half, checking boths side separatedly while collision checking also the middle segment.
rrt: RRTPlanner
RRT planner that plans the onboarding part, and may potentially plan other parts that involve collision free relocation of the robot, but without Cartesian (linear) movement.
include_linear_interpolation: bool
If set, linear interpolated poses are included in the output. Otherwise, they are discarded, many robots can do Cartesian stroke much better on they own
debug: bool
Debug mode for logging
Implementations§
Source§impl Cartesian<'_>
impl Cartesian<'_>
Sourcepub fn plan(
&self,
from: &Joints,
land: &Pose,
steps: Vec<Pose>,
park: &Pose,
) -> Result<Vec<AnnotatedJoints>, String>
pub fn plan( &self, from: &Joints, land: &Pose, steps: Vec<Pose>, park: &Pose, ) -> Result<Vec<AnnotatedJoints>, String>
Path plan for the given vector of poses. The returned path must be transitionable and collision free.
Examples found in repository?
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
fn main() {
fn pose(kinematics: &KinematicsWithShape, angles_in_degrees: [f32; 6]) -> Pose {
kinematics.forward(&utils::joints(&angles_in_degrees))
}
// Initialize kinematics with your robot's specific parameters
let k = create_rx160_robot();
// Starting point, where the robot exists at the beginning of the task.
let start = utils::joints(&[-120.0, -90.0, -92.51, 18.42, 82.23, 189.35]);
// In production, other poses are normally given in Cartesian, but here they are given
// in joints as this way it is easier to craft when in rs-opw-kinematics IDE.
// "Landing" pose close to the surface, from where Cartesian landing on the surface
// is possible and easy. Robot will change into one of the possible alternative configurations
// between start and land.
let land = pose(&k, [-120.0, -10.0, -92.51, 18.42, 82.23, 189.35]);
let steps: Vec<Pose> = [
pose(&k, [-225.0, -27.61, 88.35, -85.42, 44.61, 138.0]),
pose(&k, [-225.0, -33.02, 134.48, -121.08, 54.82, 191.01]),
//pose(&k, [-225.0, 57.23, 21.61, -109.48, 97.50, 148.38]) // this collides
]
.into();
// "Parking" pose, Cartesian lifting from the surface at the end of the stroke. Park where we landed.
let park = pose(&k, [-225.0, -27.61, 88.35, -85.42, 44.61, 110.0]);
// Creat Cartesian planner
let planner = Cartesian {
robot: &k, // The robot, instance of KinematicsWithShape
check_step_m: 0.02, // Pose distance check accuracy in meters (for translation)
check_step_rad: 3.0_f64.to_radians(), // Pose distance check accuracy in radians (for rotation)
max_transition_cost: 3_f64.to_radians(), // Maximal transition costs (not tied to the parameter above)
// (weighted sum of abs differences between 'from' and 'to' for all joints, radians).
transition_coefficients: DEFAULT_TRANSITION_COSTS, // Joint weights to compute transition cost
linear_recursion_depth: 8,
// RRT planner that computes the non-Cartesian path from starting position to landing pose
rrt: RRTPlanner {
step_size_joint_space: 2.0_f64.to_radians(), // RRT planner step in joint space
max_try: 1000,
debug: true,
},
include_linear_interpolation: true, // If true, intermediate Cartesian poses are
// included in the output. Otherwise, they are checked but not included in the output
debug: true,
};
// plan path
let started = Instant::now();
let path = planner.plan(&start, &land, steps, &park);
let elapsed = started.elapsed();
match path {
Ok(path) => {
for joints in path {
println!("{:?}", &joints);
}
}
Err(message) => {
println!("Failed: {}", message);
}
}
println!("Took {:?}", elapsed);
}
Auto Trait Implementations§
impl<'a> Freeze for Cartesian<'a>
impl<'a> !RefUnwindSafe for Cartesian<'a>
impl<'a> Send for Cartesian<'a>
impl<'a> Sync for Cartesian<'a>
impl<'a> Unpin for Cartesian<'a>
impl<'a> !UnwindSafe for Cartesian<'a>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.