-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from jhu-dvrk/rc-2.3.1
merge rc 2.3.1
- Loading branch information
Showing
490 changed files
with
528 additions
and
27,673 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# (C) Copyright 2023-2024 Johns Hopkins University (JHU), All Rights Reserved. | ||
# | ||
# --- begin cisst license - do not edit --- | ||
# | ||
# This software is provided "as is" under an open source license, with | ||
# no warranty. The complete license can be found in license.txt and | ||
# http://www.cisst.org/cisst/license.txt. | ||
# | ||
# --- end cisst license --- | ||
|
||
cmake_minimum_required (VERSION 3.10) | ||
project (sawIntuitiveResearchKitSUJBluetoothReset VERSION 2.3.0) | ||
|
||
# find cisst and make sure the required libraries have been compiled | ||
find_package (cisst 1.3.0 REQUIRED ${REQUIRED_CISST_LIBRARIES}) | ||
|
||
if (cisst_FOUND_AS_REQUIRED) | ||
|
||
# load cisst configuration | ||
include (${CISST_USE_FILE}) | ||
|
||
# catkin/ROS paths | ||
cisst_set_output_path () | ||
|
||
set (sawIntuitiveResearchKitSUJBluetoothReset_FILES | ||
${sawIntuitiveResearchKitSUJBluetoothReset_SOURCE_DIR}/dvrk-suj-bluetooth-reset.py) | ||
|
||
add_custom_target (sawIntuitiveResearchKitSUJBluetoothReset ALL) | ||
foreach (_file ${sawIntuitiveResearchKitSUJBluetoothReset_FILES}) | ||
add_custom_command (TARGET sawIntuitiveResearchKitSUJBluetoothReset PRE_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E | ||
copy ${_file} ${EXECUTABLE_OUTPUT_PATH}) | ||
endforeach () | ||
|
||
install ( | ||
FILES ${sawIntuitiveResearchKitSUJBluetoothReset_FILES} | ||
COMPONENT sawIntuitiveResearchKit-Applications | ||
DESTINATION bin) | ||
|
||
endif (cisst_FOUND_AS_REQUIRED) |
74 changes: 74 additions & 0 deletions
74
core/applications/suj-bluetooth-reset/dvrk-suj-bluetooth-reset.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Script used to disconnect and reconnect the SUJ Si Arduino BLE | ||
# | ||
|
||
import os | ||
import re | ||
import json | ||
import subprocess | ||
import time | ||
import argparse | ||
from argparse import Namespace | ||
|
||
def load_json_dvrk(file_path:str)->dict: | ||
''' | ||
Load json files from dVRK repository | ||
:param file_path: json file path | ||
:return: a dictionary with loaded json file content | ||
''' | ||
with open(file_path) as f: | ||
data = f.read() | ||
data = re.sub("//.*?\n", "", data) | ||
data = re.sub("/\\*.*?\\*/", "", data) | ||
obj = data[data.find('{'): data.rfind('}') + 1] | ||
jsonObj = json.loads(obj) | ||
return jsonObj | ||
|
||
|
||
def suj_bluetooth_reset(args: Namespace)->None: | ||
''' | ||
Reset the dVRK SUJ bluetooth connections | ||
''' | ||
suj_file_path = args.file_path | ||
data = load_json_dvrk(suj_file_path) | ||
|
||
address_list = [] | ||
address_list.append(data['base-arduino-mac']) | ||
|
||
num_arms = len(data['arms']) | ||
|
||
for i_arm in range(num_arms): | ||
address_list.append(data['arms'][i_arm]['arduino-mac']) | ||
|
||
for addr in address_list: | ||
print(f"Disconnecting and reconnecting {addr}, timeout is 30 seconds") | ||
try: | ||
res_disconnect = subprocess.run(['bluetoothctl', 'disconnect', addr], | ||
capture_output = True, text = True, | ||
timeout = 30) | ||
print(res_disconnect.stdout) | ||
except subprocess.TimeoutExpired: | ||
print('Disconnect failed, timeout') | ||
|
||
time.sleep(1.0) | ||
try: | ||
res_connect = subprocess.run(['bluetoothctl', 'connect', addr], | ||
capture_output = True, text = True, | ||
timeout = 30) | ||
print(res_connect.stdout) | ||
except subprocess.TimeoutExpired: | ||
print('Connect failed, timeout') | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-f', '--file_path', required = True, | ||
help = 'path to dvrk SUJ Si JSON config file') | ||
|
||
args = parser.parse_args() | ||
suj_bluetooth_reset(args) | ||
|
||
print('SUJ Bluetooth reset complete!') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
ros/dvrk_arms_from_ros/components/include/dvrk_mtm_from_ros.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | ||
/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ | ||
|
||
/* | ||
Author(s): Anton Deguet | ||
Created on: 2020-01-13 | ||
(C) Copyright 2020-2024 Johns Hopkins University (JHU), All Rights Reserved. | ||
--- begin cisst license - do not edit --- | ||
This software is provided "as is" under an open source license, with | ||
no warranty. The complete license can be found in license.txt and | ||
http://www.cisst.org/cisst/license.txt. | ||
--- end cisst license --- | ||
*/ | ||
|
||
#ifndef _dvrk_mtm_from_ros_h | ||
#define _dvrk_mtm_from_ros_h | ||
|
||
#include <dvrk_arm_from_ros.h> | ||
|
||
class dvrk_mtm_from_ros: public dvrk_arm_from_ros | ||
{ | ||
CMN_DECLARE_SERVICES(CMN_DYNAMIC_CREATION_ONEARG, CMN_LOG_ALLOW_DEFAULT); | ||
|
||
public: | ||
typedef mtsROSBridge BaseType; | ||
|
||
dvrk_mtm_from_ros(const std::string & componentName, | ||
cisst_ral::node_ptr_t _node_handle, | ||
const double periodInSeconds); | ||
dvrk_mtm_from_ros(const mtsTaskPeriodicConstructorArg & arg); | ||
~dvrk_mtm_from_ros() {} | ||
|
||
void InitMTM(void); | ||
|
||
protected: | ||
}; | ||
|
||
CMN_DECLARE_SERVICES_INSTANTIATION(dvrk_mtm_from_ros); | ||
|
||
#endif // _dvrk_mtm_from_ros_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.