Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Properly implement enable/disable impedance control #58

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ fn main() -> Result<(), RclrsError> {

let ros_services = Arc::new(ROSServices::new(opc_ua_client_copy_services));
let _enable_impedance_control = ros_node_copy_service
.create_service::<std_srvs::srv::Empty, _>("~/enable_impedance_control", {
.create_service::<std_srvs::srv::Empty, _>("~/impedance_control/enable", {
let rsc = Arc::clone(&ros_services);
move |request_header, request| rsc.enable_impedance_control(request_header, request)
});

let _disable_impedance_control = ros_node_copy_service
.create_service::<std_srvs::srv::Empty, _>("~/impedance_control/disable", {
let rsc = Arc::clone(&ros_services);
move |request_header, request| rsc.disable_impedance_control(request_header, request)
});

let _wrench_subscriber: Arc<Subscription<Wrench>> = ros_node.create_subscription(
"~/impedance_control/set_wrench",
QOS_PROFILE_DEFAULT,
Expand Down
16 changes: 16 additions & 0 deletions src/ros_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,20 @@ impl ROSServices {
structure_needs_at_least_one_member: 0,
}
}

pub fn disable_impedance_control(
&self,
_request_header: &rclrs::rmw_request_id_t,
_request: Empty_Request,
) -> Empty_Response {
let object_id = NodeId::new(1, 100182);
let method_id = NodeId::new(1, 100264);
self.opc_ua_client
.lock()
.unwrap()
.call_method(object_id, method_id, None::<Vec<()>>);
Empty_Response {
structure_needs_at_least_one_member: 0,
}
}
}
2 changes: 1 addition & 1 deletion tests/test_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async fn e2e_ros_service_to_opc_ua_call() {

let service_caller = Arc::new(
helpers::ros_service_caller::ServiceCaller::new(
"/voraus_bridge_node/enable_impedance_control",
"/voraus_bridge_node/impedance_control/enable",
)
.unwrap(),
);
Expand Down