pub struct RobotiqGripper { /* private fields */ }Expand description
Data Structure for interfacing with robotiq gripper with modbus rtu protocol.
Implementations§
Source§impl RobotiqGripper
impl RobotiqGripper
Sourcepub const DEFAULT_SLAVE_ID: u8 = 9u8
pub const DEFAULT_SLAVE_ID: u8 = 9u8
The Default Modbus slave ID of robotiq gripper
Sourcepub fn from_path_slave_id(
path: impl Into<String>,
slave_id: u8,
) -> Result<Self, Error>
pub fn from_path_slave_id( path: impl Into<String>, slave_id: u8, ) -> Result<Self, Error>
Constructer from USB port path, and slave id.
Sourcepub fn from_path(path: impl Into<String>) -> Result<Self, Error>
pub fn from_path(path: impl Into<String>) -> Result<Self, Error>
Constructer form USB port path.
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn write_async(
&mut self,
cmd: GripperCommand,
) -> Result<(), RobotiqError>
pub async fn write_async( &mut self, cmd: GripperCommand, ) -> Result<(), RobotiqError>
Async function for writing a GripperCommand to the gripper
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn read_async(&mut self) -> Result<GripperStatus, RobotiqError>
pub async fn read_async(&mut self) -> Result<GripperStatus, RobotiqError>
Async function for reading GripperCommand from the gripper
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn reset(&mut self) -> Result<&mut Self, RobotiqError>
pub async fn reset(&mut self) -> Result<&mut Self, RobotiqError>
Turn off the activation bit rACT, to reset fault.
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn activate(&mut self) -> Result<&mut Self, RobotiqError>
pub async fn activate(&mut self) -> Result<&mut Self, RobotiqError>
Turn on the activation bit rACT to start initalization of the gripper
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn await_activate(&mut self) -> Result<&mut Self, RobotiqError>
pub async fn await_activate(&mut self) -> Result<&mut Self, RobotiqError>
Await for the initalization process to finish.
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn go_to(
&mut self,
pos_req: u8,
speed: u8,
force: u8,
) -> Result<&mut Self, RobotiqError>
pub async fn go_to( &mut self, pos_req: u8, speed: u8, force: u8, ) -> Result<&mut Self, RobotiqError>
Command the gripper to go to a certain set point with specified position, speed and force
§Parameter
§pos_req: u8
This register is used to set the target position for the gripper’s fingers.
The position 0x00 and 0xFF correspond respectively to the fully opened and fully closed mechanical stops.
For detail finger trajectory, please refer to the Specifications section of repective manual.
0x00- Open position0xFF- Close position
§Info
The activation will allow the gripper to adjust to any fingertips.
No matter what is the size and/or shape of the fingertips,
0 will always be fully opened and 255 fully closed,
with a quasi-linear relationship between the two values.
§speed: u8
This register is used to set the gripper closing and opening speed in real time, however, setting a speed will not initiate a motion.
0x00- Minimum speed0xFF- Maximum speed
§force: u8
The force setting defines the final gripper force for the gripper. The force will fix the maximum current sent to the motor. If the current limit is exceeded, the fingers stop and trigger an object detection notification. Please refer to the “Picking Features” section of respective manual.
0x00- Minimum force0xFF- Maximum force
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn await_go_to(&mut self) -> Result<ObjDetectStatus, RobotiqError>
pub async fn await_go_to(&mut self) -> Result<ObjDetectStatus, RobotiqError>
Await for the “Go To” command to finish.
§Return ObjDetectStatus
this function will return, when the gripper detected object at the end point, or reached target position.
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn automatic_release(
&mut self,
open: bool,
) -> Result<&mut Self, RobotiqError>
pub async fn automatic_release( &mut self, open: bool, ) -> Result<&mut Self, RobotiqError>
§Automatic release feature.
Automatic Release routine action slowly opens the gripper fingers until all motion axes reach their mechanical limits
After all motion are completed, the gripper sends a fault signal and needed to be reinitalized before any other motion is performed.
The atr(rATR) bit overrides all other commands excluding the activation bit act(rACT).
§Auto-release direction.
When auto-releasing, ard(rARD) commands the direction of the movement. The ard(rARD) bit should be set prior to
or at the same time as the atr(rATR) bit. as the motion direction is set when the auto-release is initated.
Examples found in repository?
4async fn main() -> Result<(), RobotiqError> {
5 // The serial port path
6 let path = "COM17";
7
8 // create a connection to serial RS485 modbus
9 let mut gripper = RobotiqGripper::from_path(path)?;
10
11 // Reset and Activation of Gripper
12 //
13 // reset gripper, recommended
14 gripper.reset().await?;
15 // activate the gripper, it will try to open and close.
16 gripper.activate().await?.await_activate().await?;
17 println!("finished activation.");
18 std::thread::sleep(std::time::Duration::from_millis(1000));
19
20 // Basic Gripper Command
21 //
22 // set gripper with position, speed and force
23 gripper.go_to(0x08, 0x00, 0x00).await?;
24 // the result of the setting command, return whether or not it have clamp an object
25 let obj_detect_status = gripper.await_go_to().await?;
26 println!("Object Detect Status : {:?}", obj_detect_status);
27 std::thread::sleep(std::time::Duration::from_millis(1000));
28
29 // Chained command
30 //
31 // chained command with builder pattern
32 let obj_detect_status = gripper.go_to(0xFF, 0xFF, 0xFF).await?.await_go_to().await?;
33 println!("Object Detect Status : {:?}", obj_detect_status);
34 std::thread::sleep(std::time::Duration::from_millis(1000));
35
36 // Automatic Release Routine
37 //
38 // set the gripper into motion
39 gripper.go_to(0x08, 0x00, 0x00).await?;
40 std::thread::sleep(std::time::Duration::from_millis(100));
41 gripper.automatic_release(false).await?;
42 // you will need to reset and reactivate the gripper after automatic release routine
43 gripper
44 .reset()
45 .await?
46 .activate()
47 .await?
48 .await_activate()
49 .await?;
50 std::thread::sleep(std::time::Duration::from_millis(1000));
51 gripper.go_to(0x08, 0x00, 0x00).await?;
52 std::thread::sleep(std::time::Duration::from_millis(1000));
53
54 // Gripper Command
55 //
56 // Construct GripperCommand to command gripper
57 //
58 // a null command, all zero, will deactivate and reset the gripper
59 let cmd_null = GripperCommand::new();
60 // command to activate the gripper
61 let cmd_act = GripperCommand::new().act(true);
62 // commands to set the gripper with position requested, speed, and force
63 let cmd_goto_1 = GripperCommand::new()
64 .act(true)
65 .gto(true)
66 .pos_req(0x08)
67 .speed(0x00)
68 .force(0x00);
69 let cmd_goto_2 = GripperCommand::new()
70 .act(true)
71 .gto(true)
72 .pos_req(0xFF)
73 .speed(0xFF)
74 .force(0xFF);
75 // command to perform automatic release routine
76 let cmd_atr = GripperCommand::new().act(true).atr(true).ard(true);
77
78 //
79 //
80 gripper.write_async(cmd_null).await?;
81 gripper.write_async(cmd_act).await?;
82 while gripper.read_async().await?.sta != ActivationStatus::Completed {
83 std::thread::sleep(std::time::Duration::from_millis(100));
84 }
85 std::thread::sleep(std::time::Duration::from_millis(1000));
86
87 //
88 //
89 gripper.write_async(cmd_goto_1).await?;
90 while gripper.read_async().await?.obj == ObjDetectStatus::InMotion {
91 std::thread::sleep(std::time::Duration::from_millis(100));
92 }
93 std::thread::sleep(std::time::Duration::from_millis(1000));
94
95 //
96 //
97 gripper.write_async(cmd_goto_2).await?;
98 std::thread::sleep(std::time::Duration::from_millis(100));
99 gripper.write_async(cmd_atr).await?;
100 while gripper.read_async().await?.fault != GripperFault::AutomaticReleaseCompleted {
101 std::thread::sleep(std::time::Duration::from_millis(100));
102 }
103 std::thread::sleep(std::time::Duration::from_millis(1000));
104
105 gripper
106 .reset()
107 .await?
108 .activate()
109 .await?
110 .await_activate()
111 .await?
112 .go_to(0x00, 0xFF, 0xFF)
113 .await?
114 .await_go_to()
115 .await?;
116
117 Ok(())
118}Sourcepub async fn await_automatic_release(
&mut self,
) -> Result<&mut Self, RobotiqError>
pub async fn await_automatic_release( &mut self, ) -> Result<&mut Self, RobotiqError>
Await for the automatic release routine to finish.