Skip to content

Commit

Permalink
feat: Properly implement enable/disable impedance control
Browse files Browse the repository at this point in the history
like it is implemented by the voraus core.
  • Loading branch information
philipp-caspers committed Oct 16, 2024
1 parent 6001f8f commit 2574aa4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
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

0 comments on commit 2574aa4

Please sign in to comment.