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 14, 2024
1 parent 07c380e commit be0ca19
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 @@ -41,11 +41,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)
});

info!("Starting OPC UA client");
let _session = opc_ua_client_copy_run.lock().unwrap().run_async();
info!("Spinning ROS");
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 be0ca19

Please sign in to comment.