└── HandControlLongBtn ├── .gitignore ├── .idea ├── caches │ └── build_file_checksums.ser ├── codeStyles │ └── Project.xml ├── dictionaries │ └── dadachenchen.xml ├── gradle.xml ├── misc.xml └── runConfigurations.xml ├── app ├── .gitignore ├── build.gradle ├── libs │ ├── eventbus.jar │ ├── fastjson-1.2.45.jar │ ├── java_websocket.jar │ └── json-simple-1.1.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── dadac │ │ └── sqlitesavaname │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ ├── com │ │ │ ├── example │ │ │ │ └── dadac │ │ │ │ │ ├── RCApplication.java │ │ │ │ │ ├── savenavigationinfo │ │ │ │ │ ├── NavigationInfo.java │ │ │ │ │ ├── SaveData.java │ │ │ │ │ └── SetNavigationActivity.java │ │ │ │ │ └── sqlitesavaname │ │ │ │ │ ├── IStatus.java │ │ │ │ │ ├── LoginActivity.java │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── PublishEvent.java │ │ │ ├── fragment │ │ │ │ ├── SetNavigationFragemnt.java │ │ │ │ └── ShowRobotLocationFragment.java │ │ │ └── jilk │ │ │ │ └── ros │ │ │ │ ├── Example.java │ │ │ │ ├── MessageHandler.java │ │ │ │ ├── ROSClient.java │ │ │ │ ├── Service.java │ │ │ │ ├── Topic.java │ │ │ │ ├── message │ │ │ │ ├── AudioMsg.java │ │ │ │ ├── Clock.java │ │ │ │ ├── Duration.java │ │ │ │ ├── DurationPrimitive.java │ │ │ │ ├── Empty.java │ │ │ │ ├── Header.java │ │ │ │ ├── Log.java │ │ │ │ ├── Message.java │ │ │ │ ├── MessageException.java │ │ │ │ ├── MessageType.java │ │ │ │ ├── SemanticRequest.java │ │ │ │ ├── SemanticResponse.java │ │ │ │ ├── StdMsg.java │ │ │ │ ├── Time.java │ │ │ │ └── TimePrimitive.java │ │ │ │ ├── rosapi │ │ │ │ └── message │ │ │ │ │ ├── Empty.java │ │ │ │ │ ├── GetTime.java │ │ │ │ │ ├── MessageDetails.java │ │ │ │ │ ├── Nodes.java │ │ │ │ │ ├── Service.java │ │ │ │ │ ├── Services.java │ │ │ │ │ ├── Topic.java │ │ │ │ │ ├── Topics.java │ │ │ │ │ ├── Type.java │ │ │ │ │ └── TypeDef.java │ │ │ │ └── rosbridge │ │ │ │ ├── FullMessageHandler.java │ │ │ │ ├── ROSBridgeClient.java │ │ │ │ ├── implementation │ │ │ │ ├── Base64.java │ │ │ │ ├── JSON.java │ │ │ │ ├── ROSBridgeWebSocketClient.java │ │ │ │ └── Registry.java │ │ │ │ ├── indication │ │ │ │ ├── AsArray.java │ │ │ │ ├── Base64Encoded.java │ │ │ │ ├── Indicate.java │ │ │ │ ├── Indicated.java │ │ │ │ ├── Indication.java │ │ │ │ └── Indicator.java │ │ │ │ └── operation │ │ │ │ ├── Advertise.java │ │ │ │ ├── Authenticate.java │ │ │ │ ├── CallService.java │ │ │ │ ├── Fragment.java │ │ │ │ ├── Operation.java │ │ │ │ ├── PNG.java │ │ │ │ ├── Publish.java │ │ │ │ ├── ServiceResponse.java │ │ │ │ ├── SetStatusLevel.java │ │ │ │ ├── Status.java │ │ │ │ ├── Subscribe.java │ │ │ │ ├── Unadvertise.java │ │ │ │ ├── Unsubscribe.java │ │ │ │ └── Wrapper.java │ │ ├── customView │ │ │ ├── BatteryView.java │ │ │ ├── DialogActivity.java │ │ │ └── PopupView.java │ │ └── utils │ │ │ ├── BroadCastTemplate.java │ │ │ └── SerialUtils.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── background.jpg │ │ ├── first.png │ │ ├── ic_launcher_background.xml │ │ ├── ico_robot.png │ │ ├── move_down.png │ │ ├── move_down_press.png │ │ ├── move_left.png │ │ ├── move_left_press.png │ │ ├── move_right.png │ │ ├── move_right_press.png │ │ ├── move_up.png │ │ ├── move_up_press.png │ │ ├── xml_move_down.xml │ │ ├── xml_move_left.xml │ │ ├── xml_move_right.xml │ │ └── xml_move_up.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ ├── activity_welcome.xml │ │ ├── activitydialog.xml │ │ ├── fragemnt_showrobot.xml │ │ ├── fragment_setnavi.xml │ │ ├── passworddialog.xml │ │ ├── popupdialog.xml │ │ └── rowshow_navlist.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── attrs.xml │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── dadac │ └── sqlitesavaname │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /HandControlLongBtn/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /HandControlLongBtn/.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /HandControlLongBtn/.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /HandControlLongBtn/.idea/dictionaries/dadachenchen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /HandControlLongBtn/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /HandControlLongBtn/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /HandControlLongBtn/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.example.dadac.sqlitesavaname" 7 | minSdkVersion 15 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:28.0.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 28 | implementation 'org.xutils:xutils:3.3.22' 29 | implementation files('libs/fastjson-1.2.45.jar') 30 | implementation files('libs/eventbus.jar') 31 | implementation files('libs/java_websocket.jar') 32 | implementation files('libs/json-simple-1.1.jar') 33 | } 34 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/libs/eventbus.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/libs/eventbus.jar -------------------------------------------------------------------------------- /HandControlLongBtn/app/libs/fastjson-1.2.45.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/libs/fastjson-1.2.45.jar -------------------------------------------------------------------------------- /HandControlLongBtn/app/libs/java_websocket.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/libs/java_websocket.jar -------------------------------------------------------------------------------- /HandControlLongBtn/app/libs/json-simple-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/libs/json-simple-1.1.jar -------------------------------------------------------------------------------- /HandControlLongBtn/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/androidTest/java/com/example/dadac/sqlitesavaname/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac.sqlitesavaname; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.dadac.sqlitesavaname", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 13 | 14 | 15 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/RCApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac; 2 | 3 | import android.app.Application; 4 | 5 | import com.jilk.ros.rosbridge.ROSBridgeClient; 6 | 7 | import org.xutils.x; 8 | 9 | 10 | /** 11 | * @ Create by dadac on 2018/9/27. 12 | * @Function: 供给SQLite使用 13 | * @Return: 14 | */ 15 | public class RCApplication extends Application { 16 | //ROS 17 | ROSBridgeClient client; 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | //EventBus xUtils 22 | x.Ext.init(this); 23 | x.Ext.setDebug(false); //输出debug日志,开启会影响性能 24 | } 25 | 26 | @Override //ROS 27 | public void onTerminate() { 28 | if(client != null) 29 | client.disconnect(); 30 | super.onTerminate(); 31 | } 32 | 33 | public ROSBridgeClient getRosClient() { 34 | return client; 35 | } 36 | 37 | public void setRosClient(ROSBridgeClient client) { 38 | this.client = client; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/savenavigationinfo/NavigationInfo.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac.savenavigationinfo; 2 | 3 | 4 | import org.xutils.db.annotation.Column; 5 | import org.xutils.db.annotation.Table; 6 | 7 | /** 8 | * @ Create by dadac on 2018/10/29. 9 | * @Function: 保存导航点的信息 当第一次创建表格需要插入数据时,在此写 sql 语句 10 | * @Return: 11 | */ 12 | 13 | @Table(name = "navigation_info", onCreated = "") 14 | public class NavigationInfo { 15 | 16 | /** 17 | * id: 序列号 18 | * name: 名称 19 | * x_position: 位置信息 x 20 | * y_position: y 21 | * z_position: z 22 | * w_position: w 23 | */ 24 | /** 25 | * name = "_id"; 数据库表中的第一个字段 26 | * isId = true ; 是否主键 27 | * autoGen = true; 自动增长 28 | * property = "NOTNULL"; 不为空 29 | */ 30 | @Column(name = "_id", isId = true, autoGen = true, property = "NOT NULL") 31 | private int _id; 32 | @Column(name = "u_name", property = "NOT NULL") 33 | private String u_name; 34 | @Column(name = "x_position", property = "NOT NULL") 35 | private double x_position; 36 | @Column(name = "y_position", property = "NOT NULL") 37 | private double y_position; 38 | @Column(name = "z_orientation", property = "NOT NULL") 39 | private double z_orientation; 40 | @Column(name = "w_orientation", property = "NOT NULL") 41 | private double w_orientation; 42 | 43 | public NavigationInfo() { 44 | } 45 | 46 | public NavigationInfo(int _id, String u_name, double x_position, double y_position, double z_orientation, double w_orientation) { 47 | this._id = _id; 48 | this.u_name = u_name; 49 | this.x_position = x_position; 50 | this.y_position = y_position; 51 | this.z_orientation = z_orientation; 52 | this.w_orientation = w_orientation; 53 | } 54 | 55 | public NavigationInfo(String u_name, double x_position, double y_position, double z_orientation, double w_orientation) { 56 | this.u_name = u_name; 57 | this.x_position = x_position; 58 | this.y_position = y_position; 59 | this.z_orientation = z_orientation; 60 | this.w_orientation = w_orientation; 61 | } 62 | 63 | @Override 64 | public String toString() { 65 | return "navigation_Info{" + "_id" + _id + " u_name" + u_name + " x_position" + x_position + " y_position" + y_position + " " + 66 | "z_orientation" + z_orientation + " " + "w_orientation" + w_orientation; 67 | } 68 | 69 | public int get_id() { 70 | return _id; 71 | } 72 | 73 | public void set_id(int _id) { 74 | this._id = _id; 75 | } 76 | 77 | public String getU_name() { 78 | return u_name; 79 | } 80 | 81 | public void setU_name(String u_name) { 82 | this.u_name = u_name; 83 | } 84 | 85 | public double getX_position() { 86 | return x_position; 87 | } 88 | 89 | public void setX_position(double x_position) { 90 | this.x_position = x_position; 91 | } 92 | 93 | public double getY_position() { 94 | return y_position; 95 | } 96 | 97 | public void setY_position(double y_position) { 98 | this.y_position = y_position; 99 | } 100 | 101 | public double getZ_orientation() { 102 | return z_orientation; 103 | } 104 | 105 | public void setZ_orientation(double z_orientation) { 106 | this.z_orientation = z_orientation; 107 | } 108 | 109 | public double getW_orientation() { 110 | return w_orientation; 111 | } 112 | 113 | public void setW_orientation(double w_orientation) { 114 | this.w_orientation = w_orientation; 115 | } 116 | } 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/savenavigationinfo/SaveData.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac.savenavigationinfo; 2 | 3 | import android.content.Context; 4 | import android.support.annotation.Nullable; 5 | import android.util.Log; 6 | 7 | import com.alibaba.fastjson.JSON; 8 | import com.alibaba.fastjson.JSONObject; 9 | 10 | import org.xutils.DbManager; 11 | 12 | import org.xutils.db.sqlite.SqlInfo; 13 | import org.xutils.db.table.DbModel; 14 | import org.xutils.db.table.TableEntity; 15 | import org.xutils.ex.DbException; 16 | import org.xutils.x; 17 | 18 | import java.io.File; 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | /** 23 | * @ Create by dadac on 2018/10/29. 24 | * @Function: 使用SQLite来存储数据 25 | * @Return: 26 | */ 27 | public class SaveData { 28 | 29 | //新建数据库 30 | DbManager dbManager; 31 | DbManager.DaoConfig daoConfig = new DbManager.DaoConfig(); 32 | 33 | /** 34 | * @Function: 初始化 DaoConfig 配置 35 | * @Return: 36 | * @attention: 不管什么使用 SaveData saveData = new SavaData() 都 37 | * 必须使用初始化的函数 即: saveData.InitDaoConfig() 38 | */ 39 | public void InitDaoConfig(Context context) { 40 | String path = context.getExternalFilesDir("Documents").getPath(); //平板路径 41 | //平板存放SQL的路径 42 | daoConfig.setDbName("navigation_info.db") 43 | //设置数据库的名字 默认的是 xutils.db 44 | .setDbDir(new File("/mnt/sdcard/SQLite")) //设置数据库路径,默认存储在 app 的私有目录 RK 45 | //.setDbDir(new File(path + "/SQLite")) //平板的路径 46 | .setDbVersion(1) //设置当前的版本号 47 | .setDbOpenListener(new DbManager.DbOpenListener() { //设置数据库打开的监听 48 | @Override 49 | public void onDbOpened(DbManager db) { 50 | //适用于大量数据写的时候 开启数据库支持多线程的操作 51 | db.getDatabase().enableWriteAheadLogging(); 52 | } 53 | }).setDbUpgradeListener(new DbManager.DbUpgradeListener() { //设置数据库更新的监听 54 | @Override 55 | public void onUpgrade(DbManager db, int oldVersion, int newVersion) { 56 | Log.i("dachenSQLite", "数据库已经更新了 oldversion: " + oldVersion + " newversion" + newVersion); 57 | } 58 | }).setTableCreateListener(new DbManager.TableCreateListener() { //设置表创建的监听 59 | @Override 60 | public void onTableCreated(DbManager db, TableEntity table) { 61 | Log.i("dachenSQLite", "表已经被创建了" + table.getName()); 62 | } 63 | }).setAllowTransaction(true); //设置是否允许事务 默认为 true 64 | dbManager = x.getDb(daoConfig); 65 | } 66 | 67 | /*创建数据库*/ 68 | public void CreateSQLData(int count) { 69 | ArrayList navigationInfos = new ArrayList<>(); 70 | for (int i = 1; i <= count; i++) { 71 | navigationInfos.add(new NavigationInfo("导航点" + i, 0.0, 0.0, 0.0, 0.0)); 72 | } 73 | try { 74 | dbManager.save(navigationInfos); 75 | Log.i("dachenSQLite", "数据库已经创建成功"); 76 | } catch (DbException e) { 77 | e.printStackTrace(); 78 | Log.e("dachenSQLite", e.getMessage() + "数据库创建失败"); 79 | } 80 | } 81 | 82 | 83 | /** 84 | * @Function: 查询表中的指定的数据 都是保存为 JSON 的格式 85 | * @Return: 86 | * @attention: 数据库索引没有 0 87 | */ 88 | public String QuerySQLData(@Nullable int Index) { 89 | NavigationInfo navigationIndex = null; 90 | String jsonObject = "Error"; 91 | try { 92 | navigationIndex = dbManager.findById(NavigationInfo.class, Index); 93 | // javaToJson 将 Java 对象转换成 JSON 对象扔出去 94 | jsonObject = JSON.toJSONString(navigationIndex); 95 | } catch (DbException e) { 96 | e.printStackTrace(); 97 | Log.e("dachenSQLite", "找不到指定的数据"); 98 | } 99 | return jsonObject; 100 | } 101 | 102 | /** 103 | * @Function: 删除数据库指定的内容 104 | * @Return: 105 | */ 106 | public void DeleteSQLIndex(int index) { 107 | try { 108 | dbManager.deleteById(NavigationInfo.class, index); 109 | } catch (DbException e) { 110 | e.printStackTrace(); 111 | } 112 | } 113 | 114 | /** 115 | * @Function: 删除数据库 116 | * @Return: 117 | */ 118 | public void deleteSQL() { 119 | try { 120 | dbManager.dropDb(); 121 | } catch (DbException e) { 122 | e.printStackTrace(); 123 | } 124 | } 125 | 126 | /** 127 | * @Function: 删除表 128 | * @Return: 129 | */ 130 | public void deletetable() { 131 | try { 132 | dbManager.dropTable(NavigationInfo.class); 133 | } catch (DbException e) { 134 | e.printStackTrace(); 135 | } 136 | } 137 | 138 | /** 139 | * @Function: 新增表中的数据 140 | * @Return: 141 | */ 142 | public void newSQLData(int id, String name, double x, double y, double z, double w) { 143 | try { 144 | NavigationInfo navigationInfo = new NavigationInfo(id, name, x, y, z, w); 145 | dbManager.save(navigationInfo); 146 | } catch (DbException e) { 147 | e.printStackTrace(); 148 | } 149 | } 150 | 151 | /** 152 | * @Function: 修改表中的数据 153 | * @Return: 154 | */ 155 | public void updateSQLData(int Index, String name, double x, double y, double z, double w) { 156 | try { 157 | //第一种写法 158 | NavigationInfo navigationInfo = dbManager.findById(NavigationInfo.class, Index); 159 | navigationInfo.setU_name(name); 160 | navigationInfo.setX_position(x); 161 | navigationInfo.setY_position(y); 162 | navigationInfo.setZ_orientation(z); 163 | navigationInfo.setW_orientation(w); 164 | dbManager.update(navigationInfo, "u_name"); // u_name 表中的字段名 165 | dbManager.update(navigationInfo, "x_position"); // x_position 表中的字段名 166 | dbManager.update(navigationInfo, "y_position"); // y_position 表中的字段名 167 | dbManager.update(navigationInfo, "z_orientation"); // z_position 表中的字段名 168 | dbManager.update(navigationInfo, "w_orientation"); // w_position 表中的字段名 169 | } catch (DbException e) { 170 | e.printStackTrace(); 171 | } 172 | } 173 | 174 | /** 175 | * @Function: 返回 sql 语句的长度 176 | * @Return: 177 | */ 178 | public int GetTheTableSize() { 179 | DbManager dbManager = x.getDb(daoConfig); 180 | try { 181 | List ed = dbManager.findDbModelAll(new SqlInfo("select * from navigation_info")); 182 | return ed.size(); 183 | } catch (DbException e) { 184 | e.printStackTrace(); 185 | } 186 | return 1; 187 | } 188 | 189 | 190 | /** 191 | * @Function: UI 异步执行 192 | * @Return: 193 | */ 194 | public void AsyUISQL() { 195 | x.task().run(new Runnable() { 196 | @Override 197 | public void run() { 198 | //异步代码 199 | } 200 | }); 201 | } 202 | 203 | /** 204 | * @Function: 同步代码 205 | * @Return: 206 | */ 207 | public void TogetherUISQL() { 208 | x.task().post(new Runnable() { 209 | @Override 210 | public void run() { 211 | //同步代码 212 | 213 | } 214 | }); 215 | } 216 | 217 | /** 218 | * @Function: 获取 数据库中所有的的名字 219 | * @Return: 220 | */ 221 | public String[] GetSQLALLName() { 222 | //获取长度 223 | int size = GetTheTableSize(); 224 | String[] contents = new String[size]; 225 | for (int i = 1; i <= size; i++) { 226 | contents[i - 1] = (String) (JSONObject.parseObject(QuerySQLData(i))).get("u_name"); 227 | } 228 | return contents; 229 | } 230 | 231 | /** 232 | * @Function: 获取 数据库中所有的的ID 233 | * @Return: 234 | */ 235 | public String[] GetSQLALLID() { 236 | //获取长度 237 | int size = GetTheTableSize(); 238 | String[] contents = new String[size]; 239 | for (int i = 1; i <= size; i++) { 240 | contents[i - 1] = i + ""; 241 | } 242 | return contents; 243 | } 244 | 245 | 246 | } 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/savenavigationinfo/SetNavigationActivity.java: -------------------------------------------------------------------------------- 1 | //package com.example.dadac.savenavigationinfo; 2 | // 3 | //import android.app.AlertDialog; 4 | //import android.app.ListActivity; 5 | //import android.content.DialogInterface; 6 | //import android.os.Bundle; 7 | //import android.util.Log; 8 | //import android.view.LayoutInflater; 9 | //import android.view.MotionEvent; 10 | //import android.view.View; 11 | //import android.view.ViewGroup; 12 | //import android.widget.AdapterView; 13 | //import android.widget.BaseAdapter; 14 | //import android.widget.Button; 15 | //import android.widget.EditText; 16 | //import android.widget.TextView; 17 | //import android.widget.Toast; 18 | // 19 | //import com.example.dadac.sqlitesavaname.R; 20 | // 21 | //import java.util.ArrayList; 22 | //import java.util.HashMap; 23 | //import java.util.List; 24 | //import java.util.Map; 25 | // 26 | // 27 | ///** 28 | // * @ Create by dadac on 2018/10/29. 29 | // * @Function: 设置导航点 Activity 不用了 30 | // * @Return: 31 | // */ 32 | //public class SetNavigationActivity extends ListActivity implements View.OnClickListener { 33 | // 34 | // private String[] IdString = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14"}; 35 | // private String[] ShowString = {"导航点1", "导航点2", "导航点3", "导航点4", "导航点5", "导航点6", "导航点7", 36 | // "导航点8", "导航点9", "导航点10", "导航点11", "导航点12", "导航点13", "导航点14"}; 37 | // private List list; 38 | // private MyAdapter myAdapter; 39 | // //保证窗口的显示每页刚好10个 40 | // private float fFirstx; 41 | // private float fSecx; 42 | // 43 | // private Button DC_Button_AddNavigation; 44 | // private Button DC_Button_RemoveNavigation; 45 | // private Button DC_Button_SubmitNavigation; 46 | // 47 | // //保存当前修改的导航点的名称 48 | // private String CurrentPositionName = null; 49 | // 50 | // @Override 51 | // protected void onCreate(Bundle savedInstanceState) { 52 | // super.onCreate(savedInstanceState); 53 | // setContentView(R.layout.fragment_setnavi); 54 | // //初始化按键 55 | // DC_Button_AddNavigation = (Button) findViewById(R.id.DC_Button_AddNavigation); 56 | // DC_Button_AddNavigation.setOnClickListener(this); 57 | // DC_Button_RemoveNavigation = (Button) findViewById(R.id.DC_Button_RemoveNavigation); 58 | // DC_Button_RemoveNavigation.setOnClickListener(this); 59 | // DC_Button_SubmitNavigation = (Button) findViewById(R.id.DC_Button_SubmitNavigation); 60 | // DC_Button_SubmitNavigation.setOnClickListener(this); 61 | // 62 | // getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { 63 | // @Override 64 | // public void onItemClick(AdapterView parent, View view, int position, long id) { 65 | // TextView textView = (TextView) view.findViewById(R.id.DC_TextView_ShowIndex); 66 | // Log.i("msg", textView.getText().toString()); 67 | // } 68 | // }); 69 | // 70 | // list = new ArrayList<>(); 71 | // for (int i = 0; i < ShowString.length; i++) { 72 | // Map map = new HashMap(); 73 | // map.put("name", ShowString[i]); 74 | // map.put("id", IdString[i]); 75 | // list.add(map); 76 | // } 77 | // myAdapter = new MyAdapter(); 78 | // setListAdapter(myAdapter); 79 | // } 80 | // 81 | // @Override 82 | // public void onClick(View v) { 83 | // switch (v.getId()) { 84 | // case R.id.DC_Button_AddNavigation: //增加导航点 85 | // Map map = new HashMap(); 86 | // map.put("id", list.size() + 1 + ""); 87 | // map.put("name", "导航点" + (list.size() + 1) + ""); 88 | // list.add(map); 89 | // myAdapter.notifyDataSetChanged(); 90 | // break; 91 | // case R.id.DC_Button_RemoveNavigation: //删除导航点 92 | // int SaveIndex = list.size(); 93 | // SaveIndex--; 94 | // if (SaveIndex < 0) { 95 | // Toast.makeText(getApplicationContext(), "没得删了,请添加导航点", Toast.LENGTH_SHORT).show(); 96 | // } else 97 | // list.remove(SaveIndex); 98 | // myAdapter.notifyDataSetChanged(); 99 | // break; 100 | // case R.id.DC_Button_SubmitNavigation: //提交更改 101 | // //具体实现 102 | // myAdapter.notifyDataSetChanged(); 103 | // break; 104 | // default: 105 | // break; 106 | // } 107 | // } 108 | // 109 | // public class MyAdapter extends BaseAdapter { 110 | // 111 | // @Override 112 | // public int getCount() { 113 | // return list.size(); 114 | // } 115 | // 116 | // @Override 117 | // public View getView(final int position, View convertView, final ViewGroup parent) { 118 | // ViewHold viewHold = new ViewHold(); 119 | // if (convertView == null) { 120 | // convertView = View.inflate(SetNavigationActivity.this, R.layout.rowshow_navlist, null); 121 | // viewHold.id = (TextView) convertView.findViewById(R.id.DC_TextView_ShowIndex); 122 | // viewHold.name = (TextView) convertView.findViewById(R.id.DC_TextView_ShowName); 123 | // viewHold.DC_Button_NotifyPoint = (Button) convertView.findViewById(R.id.DC_Button_NotifyPoint); 124 | // convertView.setTag(viewHold); 125 | // } else { 126 | // viewHold = (ViewHold) convertView.getTag(); 127 | // } 128 | // viewHold.id.setText(list.get(position).get("id").toString()); 129 | // viewHold.name.setText(list.get(position).get("name").toString()); 130 | // viewHold.DC_Button_NotifyPoint.setOnClickListener(new View.OnClickListener() { 131 | // @Override 132 | // public void onClick(View v) { //更改导航点,数据库的操作 133 | // //具体实现 134 | // PopupWindow(position); 135 | // myAdapter.notifyDataSetChanged(); 136 | // } 137 | // }); 138 | // 139 | // convertView.setOnTouchListener(new View.OnTouchListener() { 140 | // @Override 141 | // public boolean onTouch(View v, MotionEvent event) { 142 | // switch (event.getAction()) { 143 | // case MotionEvent.ACTION_UP: 144 | // fSecx = event.getX(); 145 | // if ((fSecx - fFirstx) > 10) { 146 | // ViewHold viewHold = (ViewHold) v.getTag(); 147 | // viewHold.DC_Button_NotifyPoint.setVisibility(Button.VISIBLE); 148 | // viewHold.DC_Button_NotifyPoint.setOnClickListener(new View.OnClickListener() { 149 | // @Override 150 | // public void onClick(View v) { 151 | // list.remove(position); 152 | // myAdapter.notifyDataSetChanged(); 153 | // } 154 | // }); 155 | // } 156 | // break; 157 | // case MotionEvent.ACTION_DOWN: 158 | // fFirstx = event.getX(); 159 | // break; 160 | // case MotionEvent.ACTION_MOVE: 161 | // break; 162 | // } 163 | // return true; 164 | // } 165 | // }); 166 | // return convertView; 167 | // } 168 | // 169 | // @Override 170 | // public Object getItem(int position) { 171 | // return null; 172 | // } 173 | // 174 | // @Override 175 | // public long getItemId(int position) { 176 | // return 0; 177 | // } 178 | // 179 | // class ViewHold { 180 | // private TextView id; 181 | // private TextView name; 182 | // private Button DC_Button_NotifyPoint; 183 | // } 184 | // 185 | // 186 | // private void PopupWindow(final int position) { 187 | // AlertDialog.Builder builder = new AlertDialog.Builder(SetNavigationActivity.this); 188 | // builder.setIcon(R.drawable.first); 189 | // builder.setTitle("请输入新的导航点的名称"); 190 | // // 通过LayoutInflater来加载一个xml的布局文件作为一个View对象 191 | // View view = LayoutInflater.from(SetNavigationActivity.this).inflate(R.layout.popupdialog, null); 192 | // // 设置我们自己定义的布局文件作为弹出框的Content 193 | // builder.setView(view); 194 | // 195 | // final EditText DC_EditTextNewNavigation = (EditText) view.findViewById(R.id.DC_EditTextNewNavigation); 196 | // 197 | // builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 198 | // @Override 199 | // public void onClick(DialogInterface dialog, int which) { 200 | // CurrentPositionName = DC_EditTextNewNavigation.getText().toString().trim(); 201 | // //修改显示的界面 202 | // Map map = new HashMap(); 203 | // map.put("id", (position + 1) + ""); 204 | // map.put("name", CurrentPositionName); 205 | // list.set(position + 1, map); 206 | // myAdapter.notifyDataSetChanged(); 207 | // //保存新的导航点的名称 208 | // Toast.makeText(SetNavigationActivity.this, "新的导航点的名称为" + CurrentPositionName, Toast.LENGTH_SHORT).show(); 209 | // } 210 | // }); 211 | // builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 212 | // @Override 213 | // public void onClick(DialogInterface dialog, int which) { 214 | // Toast.makeText(SetNavigationActivity.this, "取消操作", Toast.LENGTH_SHORT).show(); 215 | // } 216 | // }); 217 | // builder.show(); 218 | // } 219 | // 220 | // 221 | // } 222 | //} 223 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/sqlitesavaname/IStatus.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac.sqlitesavaname; 2 | 3 | /** 4 | * @ Create by dadac on 2018/9/10. 5 | * @Function: 存储各种变量 6 | * @Return: 7 | */ 8 | public class IStatus { 9 | 10 | /************************ Fragment 的状态变量 **************************/ 11 | public static final int STATUS_NONE = 0x01; 12 | public static final int STATUS_Fragment_AskForQuestiton = 0x02; 13 | public static final int STATUS_Fragment_BigRoomGuide = 0x03; 14 | public static final int STATUS_Fragment_QuenueForNumber = 0x04; 15 | public static final int STATUS_Fragment_TuLingRobot = 0x05; 16 | 17 | 18 | /******************* Message 中使用的变量 ***************************/ 19 | public static final int STATE_Message_GetSysDataAndTimeSerive = 0x20; 20 | public static final int STATE_Message_GetSerialPortAngle = 0x21; 21 | public static final int STATE_Message_GetIdentifyContent = 0x22; 22 | public static final int STATE_Message_GetPowerInfo = 0x23; 23 | public static final int STATE_Message_ShowPowerView = 0x24; 24 | public static final int STATE_Message_SetNavi = 0x25; 25 | public static final int STATE_Message_StartPatrol = 0x26; 26 | public static final int STATE_Message_Nav1 = 0x27; 27 | public static final int STATE_Message_Nav2 = 0x28; 28 | public static final int STATE_Message_Nav3 = 0x29; 29 | public static final int STATE_Message_Nav4 = 0x30; 30 | public static final int STATE_Message_Nav5 = 0x31; 31 | public static final int STATE_Message_Act2FraContent= 0x32; 32 | 33 | 34 | 35 | 36 | /******************** 各种Fragment标志位 ***********/ 37 | 38 | public static final int STATE_Flag_AskForQuestionToTuLing = 0x40; 39 | public static final int STATE_Flag_AskForQuesyionPageShowOK = 0x41; 40 | public static final int STATE_Flag_AskForQuesyionPageShowFailed = 0x42; 41 | public static final int STATE_Flag_TuLingRobotCustom_SEND = 0x43; 42 | public static final int STATE_Flag_TuLingRobotRobot_RECEIVE = 0x44; 43 | 44 | 45 | /******************** LOG 出现的标志位 *******************/ 46 | public static final String STATE_Log_Info = "dachenI"; 47 | public static final String STATE_Log_Debug = "dachenD"; 48 | public static final String STATE_Log_Error = "dachenE"; 49 | 50 | /***********************广播的标志位Action位 及其对应的广播的Key位***********/ 51 | public static final String BroadCast_Action_WakeUpAngle = "BroadCast_Action_WakeUp_Angle"; 52 | public static final String BroadCast_Key_WakeUpAngle = "BroadCast_Key_WakeUp_Angle"; 53 | 54 | 55 | /******************** 机器人转动的标志位 左 右 ***********/ 56 | 57 | public static final int STATE_Robot_TurnLeft = 0x51; 58 | public static final int STATE_Robot_TurnRight = 0x52; 59 | 60 | /*********************** remote 显示 Fragement ********************************/ 61 | public static final int STATE_Fragement_ShowRobot = 0x61; 62 | public static final int STATE_Fragemnt_SetNavi = 0x62; 63 | 64 | /*********************** Intent 的标志位 ****************************************/ 65 | public static final int STATE_IntentResultCode_Psd = 0x72; 66 | public static final String STATE_Intent_ContentPsd = "Intent_EnterPassword"; 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/sqlitesavaname/LoginActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac.sqlitesavaname; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.util.Log; 7 | import android.view.View; 8 | import android.widget.Button; 9 | import android.widget.EditText; 10 | import android.widget.Toast; 11 | 12 | 13 | import com.example.dadac.RCApplication; 14 | import com.jilk.ros.ROSClient; 15 | import com.jilk.ros.rosbridge.ROSBridgeClient; 16 | 17 | import customView.PopupView; 18 | 19 | 20 | public class LoginActivity extends AppCompatActivity implements View.OnClickListener { 21 | 22 | /*欢迎界面的设计*/ 23 | ROSBridgeClient client; 24 | private EditText DC_EditTextGetIP; 25 | private String IP = "192.168.2.119"; 26 | private EditText DC_EditTextGetPort; 27 | private String port = "9090"; 28 | private Button DC_Button_Connect; 29 | private boolean Flag_Connect = false; 30 | //String ip = "192.168.2.119"; //虚拟机的 IP 31 | // String ip = "192.168.10.20"; //半残废机器人的IP 32 | // String ip = "192.168.10.200"; //机器人的IP 33 | 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.onCreate(savedInstanceState); 37 | setContentView(R.layout.activity_welcome); 38 | InitMenuShow(); 39 | } 40 | 41 | private void connect(String ip, String port) { 42 | client = new ROSBridgeClient("ws://" + ip + ":" + port); 43 | Flag_Connect = client.connect(new ROSClient.ConnectionStatusListener() { 44 | @Override 45 | public void onConnect() { 46 | client.setDebug(true); 47 | ((RCApplication) getApplication()).setRosClient(client); 48 | showTip("Connect ROS success"); 49 | Log.d(IStatus.STATE_Log_Info, "Connect ROS success"); 50 | if (Flag_Connect == true) { 51 | startActivity(new Intent(LoginActivity.this, MainActivity.class)); 52 | } 53 | } 54 | 55 | @Override 56 | public void onDisconnect(boolean normal, String reason, int code) { 57 | Log.d(IStatus.STATE_Log_Info, "ROS Connect ERROR"); 58 | } 59 | 60 | @Override 61 | public void onError(Exception ex) { 62 | ex.printStackTrace(); 63 | 64 | showTip("ROS communication error"); 65 | Log.d(IStatus.STATE_Log_Info, "ROS communication error"); 66 | } 67 | }); 68 | // if (Flag_Connect == false) { 69 | // PopupView.PopupWindow(getApplication()); 70 | // } 71 | } 72 | 73 | private void showTip(final String tip) { 74 | runOnUiThread(new Runnable() { 75 | @Override 76 | public void run() { 77 | Toast.makeText(LoginActivity.this, tip, Toast.LENGTH_SHORT).show(); 78 | } 79 | }); 80 | } 81 | 82 | //初始化界面的设计 83 | private void InitMenuShow() { 84 | DC_EditTextGetIP = (EditText) findViewById(R.id.DC_EditTextGetIP); 85 | DC_EditTextGetPort = (EditText) findViewById(R.id.DC_EditTextGetPort); 86 | DC_Button_Connect = (Button) findViewById(R.id.DC_Button_Connect); 87 | DC_Button_Connect.setOnClickListener(this); 88 | } 89 | 90 | @Override //按键的监听 91 | public void onClick(View v) { 92 | switch (v.getId()) { 93 | case R.id.DC_Button_Connect: 94 | IP = DC_EditTextGetIP.getText().toString().trim(); 95 | port = DC_EditTextGetPort.getText().toString().trim(); 96 | connect(IP, port); 97 | break; 98 | default: 99 | break; 100 | } 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/example/dadac/sqlitesavaname/PublishEvent.java: -------------------------------------------------------------------------------- 1 | package com.example.dadac.sqlitesavaname; 2 | 3 | import com.jilk.ros.rosbridge.operation.Operation; 4 | 5 | /**EventBus event entity,describe ros server response info 6 | * Created by xxhong on 16-11-22. 7 | */ 8 | 9 | public class PublishEvent { 10 | public String msg; 11 | public String id; 12 | public String name; 13 | public String op; 14 | 15 | 16 | public PublishEvent(Operation operation, String name, String content) { 17 | if(operation != null) { 18 | id = operation.id; 19 | op = operation.op; 20 | } 21 | this.name = name; 22 | msg = content; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/fragment/ShowRobotLocationFragment.java: -------------------------------------------------------------------------------- 1 | package com.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.example.dadac.sqlitesavaname.R; 10 | 11 | /** 12 | * @ Create by dadac on 2018/10/30. 13 | * @Function: 14 | * @Return: 15 | */ 16 | public class ShowRobotLocationFragment extends Fragment { 17 | 18 | @Override 19 | public void onCreate(Bundle savedInstanceState) { 20 | super.onCreate(savedInstanceState); 21 | } 22 | 23 | @Override 24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 25 | 26 | View ShowRobotView = inflater.inflate(R.layout.fragemnt_showrobot, container, false); 27 | 28 | return ShowRobotView; 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/Example.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros; 21 | 22 | import com.jilk.ros.message.Clock; 23 | import com.jilk.ros.message.Log; 24 | import com.jilk.ros.rosapi.message.Empty; 25 | import com.jilk.ros.rosapi.message.GetTime; 26 | import com.jilk.ros.rosapi.message.MessageDetails; 27 | import com.jilk.ros.rosapi.message.Type; 28 | import com.jilk.ros.rosbridge.ROSBridgeClient; 29 | 30 | public class Example { 31 | 32 | public Example() {} 33 | 34 | public static void main(String[] args) { 35 | ROSBridgeClient client = new ROSBridgeClient("ws://162.243.238.80:9090"); 36 | client.connect(); 37 | //testTopic(client); 38 | try { 39 | testService(client); 40 | } 41 | catch (RuntimeException ex) { 42 | ex.printStackTrace(); 43 | } 44 | finally { 45 | client.disconnect(); 46 | } 47 | } 48 | 49 | public static void testService(ROSBridgeClient client) { 50 | try { 51 | Service timeService = 52 | new Service("/rosapi/get_time", Empty.class, GetTime.class, client); 53 | timeService.verify(); 54 | //System.out.println("Time (secs): " + timeService.callBlocking(new Empty()).time.sec); 55 | 56 | Service serviceTypeService = 57 | new Service("/rosapi/service_type", 58 | com.jilk.ros.rosapi.message.Service.class, Type.class, client); 59 | serviceTypeService.verify(); 60 | String type = serviceTypeService.callBlocking(new com.jilk.ros.rosapi.message.Service("/rosapi/service_response_details")).type; 61 | 62 | Service serviceDetails = 63 | new Service("/rosapi/service_response_details", 64 | Type.class, MessageDetails.class, client); 65 | serviceDetails.verify(); 66 | //serviceDetails.callBlocking(new Type(type)).print(); 67 | 68 | com.jilk.ros.Topic logTopic = 69 | new com.jilk.ros.Topic("/rosout", Log.class, client); 70 | logTopic.verify(); 71 | 72 | /* 73 | System.out.println("Nodes"); 74 | for (String s : client.getNodes()) 75 | System.out.println(" " + s); 76 | System.out.println("Topics"); 77 | for (String s : client.getTopics()) { 78 | System.out.println(s + ":"); 79 | client.getTopicMessageDetails(s).print(); 80 | } 81 | System.out.println("Services"); 82 | for (String s : client.getServices()) { 83 | System.out.println(s + ":"); 84 | client.getServiceRequestDetails(s).print(); 85 | System.out.println("-----------------"); 86 | client.getServiceResponseDetails(s).print(); 87 | } 88 | */ 89 | } 90 | catch (InterruptedException ex) { 91 | System.out.println("Process was interrupted."); 92 | } 93 | /* 94 | Service topicService = 95 | new Service("/rosapi/topics", Empty.class, Topics.class, client); 96 | Service typeService = 97 | new Service("/rosapi/topic_type", Topic.class, Type.class, client); 98 | Service messageService = 99 | new Service("/rosapi/message_details", Type.class, MessageDetails.class, client); 100 | try { 101 | Topics topics = topicService.callBlocking(new Empty()); 102 | for (String topicString : topics.topics) { 103 | Topic topic = new Topic(); 104 | topic.topic = topicString; 105 | Type type = typeService.callBlocking(topic); 106 | MessageDetails details = messageService.callBlocking(type); 107 | System.out.println("Topic: " + topic.topic + " Type: " + type.type); 108 | details.print(); 109 | System.out.println(); 110 | } 111 | Type type = new Type(); 112 | type.type = "time"; 113 | System.out.print("Single type check on \'time\': "); 114 | messageService.callBlocking(type).print(); 115 | } 116 | catch (InterruptedException ex) { 117 | System.out.println("testService: process was interrupted."); 118 | } 119 | */ 120 | } 121 | 122 | public static void testTopic(ROSBridgeClient client) { 123 | com.jilk.ros.Topic clockTopic = new com.jilk.ros.Topic("/clock", Clock.class, client); 124 | clockTopic.subscribe(); 125 | try { 126 | Thread.sleep(20000);} catch(InterruptedException ex) {} 127 | Clock cl = null; 128 | try { 129 | cl = clockTopic.take(); // just gets one 130 | } 131 | catch (InterruptedException ex) {} 132 | cl.print(); 133 | cl.clock.nsecs++; 134 | clockTopic.unsubscribe(); 135 | clockTopic.advertise(); 136 | clockTopic.publish(cl); 137 | clockTopic.unadvertise(); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/MessageHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros; 21 | 22 | import com.jilk.ros.message.Message; 23 | 24 | public interface MessageHandler { 25 | public void onMessage(T message); 26 | } 27 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/ROSClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.rosapi.message.TypeDef; 24 | import com.jilk.ros.rosbridge.FullMessageHandler; 25 | import com.jilk.ros.rosbridge.ROSBridgeClient; 26 | import com.jilk.ros.rosbridge.operation.Operation; 27 | 28 | public abstract class ROSClient { 29 | 30 | public ROSClient() {} 31 | 32 | public static ROSClient create(String uriString) { 33 | // if we ever implement other ROSClient types, we'll key off the URI protocol (e.g., ws://) 34 | // we'd also have to abstract out Topic and Service since they depend on the ROSBridge operations 35 | return new ROSBridgeClient(uriString); 36 | } 37 | 38 | public abstract boolean connect(); 39 | public abstract boolean connect(ConnectionStatusListener listener); 40 | public abstract void disconnect(); 41 | public abstract void send(Operation operation); 42 | public abstract void send(String json); 43 | public abstract void register(Class c, 44 | String s, 45 | Class m, 46 | FullMessageHandler h); 47 | public abstract void unregister(Class c, String s); 48 | public abstract void setDebug(boolean debug); 49 | public abstract String[] getNodes() throws InterruptedException; 50 | public abstract String[] getTopics() throws InterruptedException; 51 | public abstract String[] getServices() throws InterruptedException; 52 | public abstract TypeDef getTopicMessageDetails(String topic) throws InterruptedException; 53 | public abstract TypeDef[] getTopicMessageList(String topic) throws InterruptedException; 54 | public abstract TypeDef getServiceRequestDetails(String service) throws InterruptedException; 55 | public abstract TypeDef[] getServiceRequestList(String service) throws InterruptedException; 56 | public abstract TypeDef getServiceResponseDetails(String service) throws InterruptedException; 57 | public abstract TypeDef[] getServiceResponseList(String service) throws InterruptedException; 58 | public abstract TypeDef getTypeDetails(String type) throws InterruptedException; 59 | public abstract TypeDef[] getTypeList(String type) throws InterruptedException; 60 | public abstract void typeMatch(TypeDef t, Class c) throws InterruptedException; 61 | public abstract Object getUnderlyingClient(); // for debugging 62 | 63 | public interface ConnectionStatusListener { 64 | public void onConnect(); 65 | public void onDisconnect(boolean normal, String reason, int code); 66 | public void onError(Exception ex); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/Service.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.rosbridge.FullMessageHandler; 24 | import com.jilk.ros.rosbridge.operation.CallService; 25 | import com.jilk.ros.rosbridge.operation.ServiceResponse; 26 | 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | import java.util.concurrent.CountDownLatch; 30 | 31 | public class Service extends Message implements FullMessageHandler { 32 | private String service; 33 | private Class responseType; 34 | private Class callType; 35 | private ROSClient client; 36 | private Map calls; 37 | 38 | public Service(String service, Class callType, 39 | Class responseType, ROSClient client) { 40 | this.service = service; 41 | this.client = client; 42 | this.responseType = responseType; 43 | this.callType = callType; 44 | calls = new HashMap(); 45 | } 46 | 47 | // A result can only be returned once; it is cleared from the hash before 48 | // being sent/returned. This is to ensure that results do not accumulate 49 | // indefinitely. If callers need to keep these around they can set up their 50 | // own hash. 51 | 52 | @Override 53 | public void onMessage(String id, Message response) { 54 | //System.out.print("Service.onMessage: "); 55 | //response.print(); 56 | CallRecord call = calls.get(id); 57 | if(call == null) { 58 | System.out.print("No caller service response"); 59 | return; 60 | } 61 | if (call.handler != null) { 62 | calls.remove(id); 63 | call.handler.onMessage((ResponseType) response); 64 | } 65 | else { 66 | call.result = (ResponseType) response; 67 | call.latch.countDown(); 68 | } 69 | } 70 | 71 | public String call(CallType args) { 72 | return callImpl(args, null); 73 | } 74 | 75 | public void callWithHandler(CallType args, MessageHandler responseHandler) { 76 | callImpl(args, responseHandler); 77 | } 78 | 79 | public ResponseType callBlocking(CallType args) throws InterruptedException { 80 | return take(call(args)); 81 | } 82 | 83 | private String callImpl(CallType args, MessageHandler responseHandler) { 84 | client.register(ServiceResponse.class, service, responseType, this); // do this once on creation? 85 | CallService messageCallService = new CallService(service, args); 86 | String id = messageCallService.id; 87 | CallRecord callRecord = new CallRecord(responseHandler); 88 | calls.put(id, callRecord); 89 | client.send(messageCallService); 90 | return id; 91 | } 92 | 93 | public ResponseType poll(String id) { 94 | CallRecord call = calls.get(id); 95 | if (call.result != null) 96 | calls.remove(id); 97 | return call.result; 98 | } 99 | 100 | public ResponseType take(String id) throws InterruptedException { 101 | CallRecord call = calls.get(id); 102 | call.latch.await(); 103 | calls.remove(id); 104 | return call.result; 105 | } 106 | 107 | public void verify() throws InterruptedException { 108 | 109 | boolean hasService = false; 110 | for (String s : client.getServices()) { 111 | if (s.equals(service)) { 112 | hasService = true; 113 | break; 114 | } 115 | } 116 | if (!hasService) 117 | throw new RuntimeException("Service \'" + service + "\' not available."); 118 | 119 | client.typeMatch(client.getServiceRequestDetails(service), callType); 120 | client.typeMatch(client.getServiceResponseDetails(service), responseType); 121 | } 122 | 123 | private class CallRecord { 124 | public ResponseType result; 125 | public CountDownLatch latch; 126 | public MessageHandler handler; 127 | 128 | public CallRecord(MessageHandler handler) { 129 | this.result = null; 130 | this.latch = new CountDownLatch(1); 131 | this.handler = handler; 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/Topic.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.rosbridge.FullMessageHandler; 24 | import com.jilk.ros.rosbridge.operation.Advertise; 25 | import com.jilk.ros.rosbridge.operation.Operation; 26 | import com.jilk.ros.rosbridge.operation.Publish; 27 | import com.jilk.ros.rosbridge.operation.Subscribe; 28 | import com.jilk.ros.rosbridge.operation.Unadvertise; 29 | import com.jilk.ros.rosbridge.operation.Unsubscribe; 30 | 31 | import java.util.concurrent.LinkedBlockingQueue; 32 | 33 | 34 | public class Topic extends LinkedBlockingQueue implements FullMessageHandler { 35 | protected String topic; 36 | private Class type; 37 | private String messageType; 38 | private ROSClient client; 39 | private Thread handlerThread; 40 | 41 | public Topic(String topic, Class type, ROSClient client) { 42 | this.topic = topic; 43 | this.client = client; 44 | this.type = type; 45 | messageType = Message.getMessageType(type); 46 | handlerThread = null; 47 | } 48 | 49 | @Override 50 | public void onMessage(String id, Message message) { 51 | add((T) message); 52 | } 53 | 54 | 55 | // warning: there is a delay between the completion of this method and 56 | // the completion of the subscription; it takes longer than 57 | // publishing multiple other messages, for example. 58 | public void subscribe(MessageHandler handler) { 59 | startRunner(handler); 60 | subscribe(); 61 | } 62 | 63 | public void subscribe() { 64 | client.register(Publish.class, topic, type, this); 65 | send(new Subscribe(topic, messageType)); 66 | } 67 | 68 | public void unsubscribe() { 69 | // need to handle race conditions in incoming message handler 70 | // so that once unsubscribe has happened the handler gets no more 71 | // messages 72 | send(new Unsubscribe(topic)); 73 | client.unregister(Publish.class, topic); 74 | stopRunner(); 75 | } 76 | 77 | private void startRunner(MessageHandler handler) { 78 | stopRunner(); 79 | handlerThread = new Thread(new MessageRunner(handler)); 80 | handlerThread.setName("Message handler for " + topic); 81 | handlerThread.start(); 82 | } 83 | 84 | private void stopRunner() { 85 | if (handlerThread != null) { 86 | handlerThread.interrupt(); 87 | clear(); 88 | handlerThread = null; 89 | } 90 | } 91 | 92 | 93 | public void advertise() { 94 | send(new Advertise(topic, messageType)); 95 | } 96 | 97 | public void publish(T message) { 98 | send(new Publish(topic, message)); 99 | } 100 | 101 | public void unadvertise() { 102 | send(new Unadvertise(topic)); 103 | } 104 | 105 | private void send(Operation operation) { 106 | client.send(operation); 107 | } 108 | 109 | public void verify() throws InterruptedException { 110 | 111 | boolean hasTopic = false; 112 | for (String s : client.getTopics()) { 113 | if (s.equals(topic)) { 114 | hasTopic = true; 115 | break; 116 | } 117 | } 118 | if (!hasTopic) 119 | throw new RuntimeException("Topic \'" + topic + "\' not available."); 120 | 121 | client.typeMatch(client.getTopicMessageDetails(topic), type); 122 | } 123 | 124 | private class MessageRunner implements Runnable { 125 | private MessageHandler handler; 126 | 127 | public MessageRunner(MessageHandler handler) { 128 | this.handler = handler; 129 | } 130 | 131 | @Override 132 | public void run() { 133 | while (!Thread.interrupted()) { 134 | try { 135 | handler.onMessage(take()); 136 | } 137 | catch (InterruptedException ex) { 138 | break; 139 | } 140 | } 141 | } 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/AudioMsg.java: -------------------------------------------------------------------------------- 1 | package com.jilk.ros.message; 2 | 3 | /** 4 | * Created by xxhong on 16-11-17. 5 | */ 6 | @MessageType(string = "std_msgs/Int16MultiArray") 7 | public class AudioMsg extends Message { 8 | public short[] data; 9 | } 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Clock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "rosgraph_msgs/Clock") 23 | public class Clock extends Message { 24 | public TimePrimitive clock; 25 | } 26 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Duration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "std_msgs/Duration") 23 | public class Duration extends DurationPrimitive { 24 | } 25 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/DurationPrimitive.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "duration") 23 | public class DurationPrimitive extends TimePrimitive { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Empty.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "std_srvs/Empty") 23 | public class Empty extends Message { 24 | } 25 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Header.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "std_msgs/Header") 23 | public class Header extends Message { 24 | public long seq; 25 | public TimePrimitive stamp; 26 | public String frame_id; 27 | } 28 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Log.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "rosgraph_msgs/Log") 23 | public class Log extends Message { 24 | public Header header; 25 | public byte level; 26 | public String name; 27 | public String msg; 28 | public String file; 29 | public String function; 30 | public long line; 31 | public String[] topics; 32 | } 33 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Message.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | import java.lang.reflect.Array; 23 | import java.lang.reflect.Field; 24 | import java.util.Map; 25 | 26 | 27 | @MessageType(string = "message") 28 | public abstract class Message { 29 | 30 | // Some requirements about message types: 31 | // - It must have a MessageType declaration to be recognized on inbound messages 32 | // - Every field must be explicitly designated as public 33 | // - Every field that is not a primitive or near-primitive must be another Message class 34 | // - If there is a non-empty constructor, you must also have an empty constructor 35 | // - If it is set up as an inner class, it needs an explicit nullary constructor 36 | // (note: I have seen an inner class otherwise fail, I have not tested it with the explicit constructor) 37 | 38 | public static void register(Class c, Map messageClasses) { 39 | try { 40 | typecheck(c); 41 | 42 | // Must register the class and not have duplicate 43 | // This is not recursive because only the top level message class 44 | // needs to be determined from the string - others are top-down. 45 | String messageString = getMessageType(c); 46 | Class existingClass = messageClasses.get(messageString); 47 | if (existingClass != null && !existingClass.equals(c)) 48 | throw new MessageException("Message String \'" + messageString + 49 | "\' is assigned to two different classes (" + 50 | c.getName() + " and " + existingClass.getName() + ")"); 51 | messageClasses.put(messageString, c); 52 | } 53 | catch (MessageException ex) { 54 | // should be changed to be a hooked method to give library user control 55 | System.out.println(ex.getMessage()); 56 | } 57 | } 58 | 59 | public static String getMessageType(Class c) { 60 | return ((MessageType) c.getAnnotation(MessageType.class)).string(); 61 | } 62 | 63 | // this has never been used or tested but kind of belongs here 64 | // commented out because it uses ReflectiveOperationException which is not available on Android 65 | /* 66 | public static Message newInstance(String className) { 67 | try { 68 | Class messageClass = Class.forName(className); 69 | if (Message.class.isAssignableFrom(messageClass)) 70 | return (Message) messageClass.newInstance(); 71 | else throw new ClassCastException(); 72 | } 73 | catch (ReflectiveOperationException ex) { 74 | throw new RuntimeException("Unable to create message of class \'" + className + "\'.", ex); 75 | } 76 | } 77 | */ 78 | 79 | // Could probably do more checking here, but not sure what right now 80 | private static void typecheck(Class c) throws MessageException { 81 | 82 | // Must inherit from Message 83 | if (!Message.class.isAssignableFrom(c)) 84 | throw new MessageException("Class \'" + c.getName() + 85 | "\' does not extend Message"); 86 | 87 | // Must have the MessageType annotation 88 | if (getMessageType(c) == null) 89 | throw new MessageException("Class \'" + c.getName() + 90 | "\' is missing the MessageType annotation"); 91 | 92 | // All fields must also be valid Message classes 93 | // Note that this also serves to force-load all the message classes 94 | // so that they get registered 95 | for (Field f : c.getFields()) { 96 | Class fc = f.getType(); 97 | if (fc.isArray()) { 98 | Class ac = fc.getComponentType(); 99 | if (!isPrimitive(ac)) 100 | typecheck(ac); 101 | } 102 | else if (!isPrimitive(fc)) 103 | typecheck(fc); 104 | } 105 | } 106 | 107 | public void print() { 108 | printMessage(this, ""); 109 | } 110 | 111 | private static void printMessage(Object o, String indent) { 112 | for (Field f : o.getClass().getFields()) { 113 | Class c = f.getType(); 114 | Object fieldObject = getFieldObject(f, o); 115 | if (fieldObject != null) { 116 | if (isPrimitive(c)) 117 | System.out.println(indent + f.getName() + ": " + fieldObject); 118 | else if (c.isArray()) { 119 | System.out.println(indent + f.getName() + ": ["); 120 | printArray(fieldObject, indent + " "); 121 | System.out.println(indent + "]"); 122 | } 123 | else { 124 | System.out.println(indent + f.getName() + ":"); 125 | printMessage(fieldObject, indent + " "); 126 | } 127 | } 128 | } 129 | } 130 | 131 | private static void printArray(Object array, String indent) { 132 | Class arrayClass = array.getClass().getComponentType(); 133 | for (int i = 0; i < Array.getLength(array); i++) { 134 | Object elementObject = Array.get(array, i); 135 | if (elementObject != null) { 136 | if (isPrimitive(arrayClass)) 137 | System.out.println(indent + i + ": " + elementObject); 138 | else if (arrayClass.isArray()) { // this is not actually allowed in ROS 139 | System.out.println(indent + i + ": ["); 140 | printArray(elementObject, indent + " "); 141 | System.out.println(indent + "]"); 142 | } 143 | else { 144 | System.out.println(indent + i + ":"); 145 | printMessage(elementObject, indent + " "); 146 | } 147 | } 148 | } 149 | // remember to print array indices 150 | } 151 | 152 | public static boolean isPrimitive(Class c) { 153 | return (c.isPrimitive() || 154 | c.equals(String.class) || 155 | Number.class.isAssignableFrom(c) || 156 | c.equals(Boolean.class)); 157 | } 158 | 159 | 160 | // Copied from com.jilk.ros.rosbridge.JSON 161 | private static Object getFieldObject(Field f, Object o) { 162 | Object fo = null; 163 | try { 164 | fo = f.get(o); 165 | } 166 | catch (IllegalAccessException ex) { 167 | ex.printStackTrace(); 168 | } 169 | return fo; 170 | } 171 | 172 | public void copyFrom(Message source) { 173 | try { 174 | if (source.getClass() != getClass()) 175 | throw new RuntimeException("Attempt to copy non-matching classes"); 176 | for (Field f : getClass().getFields()) { 177 | Class fc = f.getType(); 178 | if (fc.isArray()) 179 | throw new RuntimeException("copyFrom - array types not implemented"); 180 | else if (!isPrimitive(fc)) 181 | ((Message) f.get(this)).copyFrom((Message) f.get(source)); 182 | else { 183 | Object value = f.get(source); 184 | f.set(this, value); 185 | } 186 | } 187 | } 188 | catch (IllegalAccessException ex) { 189 | throw new RuntimeException("copyFrom error", ex); 190 | } 191 | catch (ClassCastException ex) { 192 | throw new RuntimeException("copyFrom error", ex); 193 | } 194 | // ReflectiveOperationException is not available on Android (Java 1.6) 195 | /* 196 | catch (ReflectiveOperationException ex) { 197 | throw new RuntimeException ("copyFrom error", ex); 198 | } 199 | */ 200 | } 201 | 202 | } 203 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/MessageException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | public class MessageException extends Exception { 23 | 24 | public MessageException(String message) { 25 | super(message); 26 | } 27 | 28 | public MessageException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/MessageType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.TYPE) 29 | public @interface MessageType { 30 | String string() default ""; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/SemanticRequest.java: -------------------------------------------------------------------------------- 1 | package com.jilk.ros.message; 2 | 3 | /** 4 | * Created by xxhong on 16-11-17. 5 | */ 6 | @MessageType(string = "std_msgs/String") 7 | public class SemanticRequest extends Message { 8 | public SemanticRequest(String args) { 9 | jsonStr = args; 10 | } 11 | 12 | public String jsonStr; 13 | } 14 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/SemanticResponse.java: -------------------------------------------------------------------------------- 1 | package com.jilk.ros.message; 2 | 3 | /** 4 | * Created by xxhong on 16-11-17. 5 | */ 6 | @MessageType(string = "std_msgs/String") 7 | public class SemanticResponse extends Message { 8 | public String result; 9 | } 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/StdMsg.java: -------------------------------------------------------------------------------- 1 | package com.jilk.ros.message; 2 | 3 | /** 4 | * Created by xxhong on 16-11-17. 5 | */ 6 | @MessageType(string = "std_msgs/String") 7 | public class StdMsg extends Message { 8 | public String data; 9 | } 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/Time.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "std_msgs/Time") 23 | public class Time extends TimePrimitive { 24 | } 25 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/message/TimePrimitive.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.message; 21 | 22 | @MessageType(string = "time") 23 | public class TimePrimitive extends Message { 24 | public int secs; // when requesting this format from ROSbridge, it uses 'sec' (no 's') 25 | public int nsecs; // when requesting this format from ROSbridge, it uses 'nsec' 26 | } 27 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Empty.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "std_msgs/Empty") 26 | public class Empty extends Message { 27 | } 28 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/GetTime.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | import com.jilk.ros.message.TimePrimitive; 25 | 26 | 27 | @MessageType(string = "rosapi/GetTimeResponse") 28 | public class GetTime extends Message { 29 | public TimePrimitive time; 30 | } 31 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/MessageDetails.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/MessageDetails") 26 | public class MessageDetails extends Message { 27 | public TypeDef[] typedefs; 28 | } 29 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Nodes.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/Nodes") 26 | public class Nodes extends Message { 27 | public String[] nodes; 28 | } 29 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Service.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/Service") 26 | public class Service extends Message { 27 | public String service; 28 | 29 | public Service() {} 30 | 31 | public Service(String service) { 32 | this.service = service; 33 | } 34 | } -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Services.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/Services") 26 | public class Services extends Message { 27 | public String[] services; 28 | } 29 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Topic.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/Topic") 26 | public class Topic extends Message { 27 | public String topic; 28 | 29 | public Topic() {} 30 | 31 | public Topic(String topic) { 32 | this.topic = topic; 33 | } 34 | } -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Topics.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/Topics") 26 | public class Topics extends Message { 27 | public String[] topics; 28 | } 29 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/Type.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/Type") 26 | public class Type extends Message { 27 | public String type; 28 | 29 | public Type() {} 30 | 31 | public Type(String type) { 32 | this.type = type; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosapi/message/TypeDef.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosapi.message; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | 25 | @MessageType(string = "rosapi/TypeDef") 26 | public class TypeDef extends Message { 27 | public String type; 28 | public String[] fieldnames; 29 | public String[] fieldtypes; 30 | public int[] fieldarraylen; 31 | public String[] examples; 32 | 33 | public static boolean match(String type, Class c) { 34 | boolean result = false; 35 | if ( 36 | (type.equals("bool") && ((boolean.class.equals(c)) || (Boolean.class.equals(c)))) || 37 | (type.equals("int8") && ((byte.class.equals(c)) || (Byte.class.equals(c)))) || 38 | (type.equals("byte") && ((byte.class.equals(c)) || (Byte.class.equals(c)))) || // deprecated 39 | (type.equals("uint8") && ((short.class.equals(c)) || (Short.class.equals(c)))) || 40 | (type.equals("char") && ((short.class.equals(c)) || (Short.class.equals(c)))) || // deprecated 41 | (type.equals("int16") && ((short.class.equals(c)) || (Short.class.equals(c)))) || 42 | (type.equals("uint16") && ((int.class.equals(c)) || (Integer.class.equals(c)))) || 43 | (type.equals("int32") && ((int.class.equals(c)) || (Integer.class.equals(c)))) || 44 | (type.equals("uint32") && ((long.class.equals(c)) || (Long.class.equals(c)))) || 45 | (type.equals("int64") && ((long.class.equals(c)) || (Long.class.equals(c)))) || 46 | (type.equals("float32") && ((float.class.equals(c)) || (Float.class.equals(c)))) || 47 | (type.equals("float64") && ((double.class.equals(c)) || (Double.class.equals(c)))) || 48 | (type.equals("uint64") && (java.math.BigInteger.class.equals(c))) || 49 | (type.equals("string") && (String.class.equals(c))) 50 | ) 51 | result = true; 52 | 53 | return result; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/FullMessageHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge; 21 | 22 | import com.jilk.ros.message.Message; 23 | 24 | public interface FullMessageHandler { 25 | public void onMessage(String id, T message); 26 | } 27 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/implementation/ROSBridgeWebSocketClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.implementation; 21 | 22 | import com.example.dadac.sqlitesavaname.PublishEvent; 23 | import com.jilk.ros.ROSClient; 24 | import com.jilk.ros.message.Message; 25 | import com.jilk.ros.rosbridge.FullMessageHandler; 26 | import com.jilk.ros.rosbridge.operation.Operation; 27 | import com.jilk.ros.rosbridge.operation.Publish; 28 | import com.jilk.ros.rosbridge.operation.ServiceResponse; 29 | 30 | 31 | 32 | import org.java_websocket.client.WebSocketClient; 33 | import org.java_websocket.framing.CloseFrame; 34 | import org.java_websocket.handshake.ServerHandshake; 35 | import org.json.simple.JSONObject; 36 | import org.json.simple.parser.JSONParser; 37 | import org.json.simple.parser.ParseException; 38 | 39 | import java.lang.reflect.Field; 40 | import java.net.Socket; 41 | import java.net.URI; 42 | import java.net.URISyntaxException; 43 | import java.nio.channels.SocketChannel; 44 | 45 | import de.greenrobot.event.EventBus; 46 | 47 | 48 | public class ROSBridgeWebSocketClient extends WebSocketClient { 49 | private Registry classes; 50 | private Registry handlers; 51 | private boolean debug; 52 | private ROSClient.ConnectionStatusListener listener; 53 | 54 | ROSBridgeWebSocketClient(URI serverURI) { 55 | super(serverURI); 56 | classes = new Registry(); 57 | handlers = new Registry(); 58 | Operation.initialize(classes); // note, this ensures that the Message Map is initialized too 59 | listener = null; 60 | } 61 | 62 | public static ROSBridgeWebSocketClient create(String URIString) { 63 | ROSBridgeWebSocketClient client = null; 64 | try { 65 | URI uri = new URI(URIString); 66 | client = new ROSBridgeWebSocketClient(uri); 67 | } 68 | catch (URISyntaxException ex) { 69 | ex.printStackTrace(); 70 | } 71 | return client; 72 | } 73 | 74 | public void setListener(ROSClient.ConnectionStatusListener listener) { 75 | this.listener = listener; 76 | } 77 | 78 | @Override 79 | public void onOpen(ServerHandshake handshakedata) { 80 | if (listener != null) 81 | listener.onConnect(); 82 | } 83 | 84 | @Override 85 | public void onMessage(String message) { 86 | if (debug) System.out.println(" " + json); 184 | send(json); 185 | } 186 | 187 | public void register(Class c, 188 | String s, 189 | Class m, 190 | FullMessageHandler h) { 191 | Message.register(m, classes.get(Message.class)); 192 | classes.register(c, s, m); 193 | if (h != null) 194 | handlers.register(c, s, h); 195 | } 196 | 197 | public void unregister(Class c, String s) { 198 | handlers.unregister(c, s); 199 | // Note that there is no concept of unregistering a class - it can get replaced is all 200 | } 201 | 202 | public Class getRegisteredMessage(String messageString) { 203 | return classes.lookup(Message.class, messageString); 204 | } 205 | 206 | public void setDebug(boolean debug) { 207 | this.debug = debug; 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/implementation/Registry.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.implementation; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | public class Registry extends HashMap> { 26 | 27 | public void register(Class c, String s, T t) { 28 | Map table = get(c); 29 | if (table == null) { 30 | table = new HashMap(); 31 | put(c, table); 32 | } 33 | table.put(s, t); 34 | } 35 | 36 | public void unregister(Class c, String s) { 37 | Map table = get(c); 38 | if (table != null) 39 | table.remove(s); 40 | } 41 | 42 | public T lookup(Class c, String s) { 43 | T result = null; 44 | Map table = get(c); 45 | if (table != null) 46 | result = table.get(s); 47 | return result; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/indication/AsArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.indication; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.FIELD) 29 | public @interface AsArray { 30 | } 31 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/indication/Base64Encoded.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.indication; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.FIELD) 29 | public @interface Base64Encoded { 30 | } 31 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/indication/Indicate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.indication; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.METHOD) 29 | public @interface Indicate { 30 | // if later we want multiple indicated fields, use an int here 31 | } 32 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/indication/Indicated.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.indication; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.FIELD) 29 | public @interface Indicated { 30 | // if later we want multiple indicated fields, use an int here 31 | } 32 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/indication/Indication.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.indication; 21 | 22 | import java.lang.reflect.Field; 23 | 24 | public class Indication { 25 | public static boolean isIndicated(Field f) { 26 | return (f.getAnnotation(Indicated.class) != null); 27 | } 28 | 29 | public static boolean asArray(Field f) { 30 | return (f.getAnnotation(AsArray.class) != null); 31 | } 32 | 33 | public static boolean isBase64Encoded(Field f) { 34 | return ((f.getAnnotation(Base64Encoded.class) != null) && 35 | f.getType().isArray() && 36 | f.getType().getComponentType().equals(byte.class)); 37 | } 38 | 39 | public static String getIndicatorName(Class c) { 40 | return getName(c, Indicator.class); 41 | } 42 | 43 | public static String getIndicatedName(Class c) { 44 | return getName(c, Indicated.class); 45 | } 46 | 47 | private static String getName(Class c, Class annotation) { 48 | String result = null; 49 | for (Field f : c.getFields()) { 50 | if (f.getAnnotation(annotation) != null) { 51 | result = f.getName(); 52 | break; 53 | } 54 | } 55 | return result; 56 | } 57 | 58 | /* 59 | public static Class getIndication(Object o, String s) { 60 | Class c = o.getClass(); 61 | Class result = null; 62 | try { 63 | Method m = getIndicateMethod(c); 64 | result = (Class) (m.invoke(o, s)); 65 | } 66 | catch (ReflectiveOperationException ex) { 67 | ex.printStackTrace(); 68 | } 69 | return result; 70 | } 71 | 72 | private static Method getIndicateMethod(Class c) { 73 | Method result = null; 74 | for (Method m : c.getMethods()) { 75 | if (m.getAnnotation(Indicate.class) != null) { 76 | result = m; 77 | break; 78 | } 79 | } 80 | return result; 81 | } 82 | */ 83 | } 84 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/indication/Indicator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.indication; 21 | 22 | import java.lang.annotation.ElementType; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.RetentionPolicy; 25 | import java.lang.annotation.Target; 26 | 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Target(ElementType.FIELD) 29 | public @interface Indicator { 30 | // if later we want multiple indicated fields, use an int here 31 | } 32 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Advertise.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "advertise") 25 | public class Advertise extends Operation { 26 | public String topic; 27 | public String type; 28 | 29 | public Advertise() {} 30 | 31 | public Advertise(String topic, String type) { 32 | this.topic = topic; 33 | this.type = type; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Authenticate.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "auth") 25 | public class Authenticate extends Operation { 26 | public String mac; 27 | public String client; 28 | public String dest; 29 | public String rand; 30 | public int t; 31 | public String level; 32 | public int end; 33 | 34 | public Authenticate() {} 35 | 36 | public Authenticate( 37 | String mac, 38 | String client, 39 | String dest, 40 | String rand, 41 | int t, 42 | String level, 43 | int end) 44 | { 45 | this.mac = mac; 46 | this.client = client; 47 | this.dest = dest; 48 | this.rand = rand; 49 | this.t = t; 50 | this.level = level; 51 | this.end = end; 52 | 53 | this.id = null; // even though id is on EVERY OTHER operation type 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/CallService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | import com.jilk.ros.rosbridge.indication.AsArray; 25 | import com.jilk.ros.rosbridge.indication.Indicated; 26 | import com.jilk.ros.rosbridge.indication.Indicator; 27 | 28 | @MessageType(string = "call_service") 29 | public class CallService extends Operation { 30 | @Indicator public String service; 31 | @Indicated @AsArray public Message args; 32 | public Integer fragment_size; // use Integer for optional items 33 | public String compression; 34 | 35 | public CallService() {} 36 | 37 | public CallService(String service, Message args) { 38 | this.service = service; 39 | this.args = args; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Fragment.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "fragment") 25 | public class Fragment extends Operation { 26 | public String data; 27 | public int num; 28 | public int total; 29 | 30 | public Fragment() {} 31 | 32 | public Fragment(String data, int num, int total) { 33 | this.data = data; 34 | this.num = num; 35 | this.total = total; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Operation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | import com.jilk.ros.rosbridge.implementation.JSON; 25 | import com.jilk.ros.rosbridge.implementation.Registry; 26 | 27 | @MessageType(string = "operation") 28 | public class Operation extends Message { 29 | private static Long uid = 0L; 30 | 31 | public String op; 32 | public String id; 33 | 34 | public Operation() { 35 | this.op = getMessageType(getClass()); 36 | this.id = nextId(); 37 | } 38 | 39 | private static synchronized String nextId() { 40 | String result = uid.toString(); 41 | uid++; 42 | return result; 43 | } 44 | 45 | public String toJSON() { 46 | return JSON.toJSON(this); 47 | } 48 | 49 | public static Operation toOperation(String json, Registry registry) { 50 | return ((Wrapper) JSON.toMessage(json, Wrapper.class, registry)).msg; 51 | } 52 | 53 | public static void initialize(Registry registry) { 54 | initClass(registry, Advertise.class); 55 | initClass(registry, Authenticate.class); 56 | initClass(registry, CallService.class); 57 | initClass(registry, Fragment.class); 58 | initClass(registry, Operation.class); 59 | initClass(registry, PNG.class); 60 | initClass(registry, Publish.class); 61 | initClass(registry, ServiceResponse.class); 62 | initClass(registry, SetStatusLevel.class); 63 | initClass(registry, Status.class); 64 | initClass(registry, Subscribe.class); 65 | initClass(registry, Unadvertise.class); 66 | initClass(registry, Unsubscribe.class); 67 | initClass(registry, Wrapper.class); 68 | 69 | registry.register(Wrapper.class, Message.getMessageType(Publish.class), Publish.class); 70 | registry.register(Wrapper.class, Message.getMessageType(CallService.class), CallService.class); 71 | registry.register(Wrapper.class, Message.getMessageType(ServiceResponse.class), ServiceResponse.class); 72 | } 73 | 74 | private static void initClass(Registry registry, Class c) { 75 | registry.register(Message.class, Message.getMessageType(c), c); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/PNG.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "png") 25 | public class PNG extends Operation { 26 | public String data; 27 | public Integer num; // use Integer for optional items 28 | public Integer total; // use Integer for optional items 29 | 30 | public PNG() {} 31 | 32 | public PNG(String data) { 33 | this.data = data; 34 | } 35 | 36 | public PNG(String data, int num, int total) { 37 | this.data = data; 38 | this.num = num; 39 | this.total = total; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Publish.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | import com.jilk.ros.rosbridge.indication.Indicated; 25 | import com.jilk.ros.rosbridge.indication.Indicator; 26 | 27 | @MessageType(string = "publish") 28 | public class Publish extends Operation { 29 | 30 | @Indicator public String topic; 31 | @Indicated 32 | public Message msg; 33 | 34 | public Publish() {} 35 | 36 | public Publish(String topic, Message msg) { 37 | this.topic = topic; 38 | this.msg = msg; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/ServiceResponse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.Message; 23 | import com.jilk.ros.message.MessageType; 24 | import com.jilk.ros.rosbridge.indication.Indicated; 25 | import com.jilk.ros.rosbridge.indication.Indicator; 26 | 27 | @MessageType(string = "service_response") 28 | public class ServiceResponse extends Operation { 29 | @Indicator 30 | public String service; 31 | public boolean result; 32 | @Indicated public Message values; 33 | 34 | public ServiceResponse() {} 35 | 36 | public ServiceResponse(String service) { 37 | this.service = service; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/SetStatusLevel.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "set_level") 25 | public class SetStatusLevel extends Operation { 26 | public String level; 27 | 28 | public SetStatusLevel() {} 29 | 30 | public SetStatusLevel(String level) { 31 | this.level = null; 32 | if ("none".equals(level) || 33 | "warning".equals(level) || 34 | "error".equals(level) || 35 | "info".equals(level)) 36 | this.level = level; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Status.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "status") 25 | public class Status extends Operation { 26 | String level; 27 | String msg; 28 | 29 | public Status() {} 30 | 31 | public Status(String level, String msg) { 32 | this.level = level; 33 | this.msg = msg; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Subscribe.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "subscribe") 25 | public class Subscribe extends Operation { 26 | public String topic; 27 | public String type; 28 | public Integer throttle_rate; // use Integer for optional items 29 | public Integer queue_length; // use Integer for optional items 30 | public Integer fragment_size; // use Integer for optional items 31 | public String compression; 32 | 33 | public Subscribe() {} 34 | 35 | public Subscribe(String topic, String type) { 36 | this.topic = topic; 37 | this.type = type; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Unadvertise.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "unadvertise") 25 | public class Unadvertise extends Operation { 26 | public String topic; 27 | 28 | public Unadvertise() {} 29 | 30 | public Unadvertise(String topic) { 31 | this.topic = topic; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Unsubscribe.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | 24 | @MessageType(string = "unsubscribe") 25 | public class Unsubscribe extends Operation { 26 | public String topic; 27 | 28 | public Unsubscribe() {} 29 | 30 | public Unsubscribe(String topic) { 31 | this.topic = topic; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/com/jilk/ros/rosbridge/operation/Wrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014 Jilk Systems, Inc. 3 | * 4 | * This file is part of the Java ROSBridge Client. 5 | * 6 | * The Java ROSBridge Client is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * The Java ROSBridge Client is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/. 18 | * 19 | */ 20 | package com.jilk.ros.rosbridge.operation; 21 | 22 | import com.jilk.ros.message.MessageType; 23 | import com.jilk.ros.rosbridge.indication.Indicated; 24 | import com.jilk.ros.rosbridge.indication.Indicator; 25 | 26 | @MessageType(string = "wrapper") 27 | public class Wrapper extends Operation { 28 | @Indicator 29 | public String op; 30 | @Indicated 31 | public Operation msg; 32 | 33 | public Wrapper() {} 34 | } 35 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/customView/BatteryView.java: -------------------------------------------------------------------------------- 1 | package customView; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | import android.widget.Toast; 12 | 13 | import com.example.dadac.sqlitesavaname.R; 14 | 15 | 16 | /** 17 | * @author donkor 18 | * 自定义水平\垂直电池控件 19 | */ 20 | public class BatteryView extends View { 21 | private static int mPower = 101; 22 | private static int flagcharge=0; 23 | private int orientation; 24 | // FlagCharge 1 充电 0 放电 25 | 26 | private int width; 27 | private int height; 28 | private int mColor; 29 | 30 | private static int flagunchargeToast = 0; 31 | private static int flagchargeToast = 0; 32 | 33 | public BatteryView(Context context) { 34 | super(context); 35 | } 36 | 37 | public BatteryView(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.Battery); 40 | mColor = typedArray.getColor(R.styleable.Battery_batteryColor, 0xFFFFFFFF); 41 | orientation = typedArray.getInt(R.styleable.Battery_batteryOrientation, 0); 42 | flagcharge = typedArray.getInt(R.styleable.Battery_batteryCharge, 0); 43 | mPower = typedArray.getInt(R.styleable.Battery_batteryPower, 100); 44 | width = getMeasuredWidth(); 45 | height = getMeasuredHeight(); 46 | /** 47 | * recycle() :官方的解释是:回收TypedArray,以便后面重用。在调用这个函数后,你就不能再使用这个TypedArray。 48 | * 在TypedArray后调用recycle主要是为了缓存。当recycle被调用后,这就说明这个对象从现在可以被重用了。 49 | *TypedArray 内部持有部分数组,它们缓存在Resources类中的静态字段中,这样就不用每次使用前都需要分配内存。 50 | */ 51 | typedArray.recycle(); 52 | } 53 | 54 | @Override 55 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 56 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 57 | //对View上的內容进行测量后得到的View內容占据的宽度 58 | width = getMeasuredWidth(); 59 | //对View上的內容进行测量后得到的View內容占据的高度 60 | height = getMeasuredHeight(); 61 | } 62 | 63 | @Override 64 | protected void onDraw(Canvas canvas) { 65 | super.onDraw(canvas); 66 | // //判断电池方向 horizontal: 0 vertical: 1 67 | // if (orientation == 0) { 68 | // drawHorizontalBattery(canvas); 69 | // } else { 70 | // drawVerticalBattery(canvas); 71 | // } 72 | //判断充放电 charge 1 uncharge 0 73 | if (flagcharge == 0) { 74 | //放电 75 | drawHorizontalBatteryUnCharge(canvas); 76 | } 77 | if (flagcharge == 1) { 78 | //充电 79 | drawHorizontalBatteryCharge(canvas); 80 | } 81 | } 82 | 83 | /** 84 | * @param canvas 85 | * @Function: 绘制水平的充电电池的放电 86 | * @Return: 87 | */ 88 | private void drawHorizontalBatteryUnCharge(Canvas canvas) { 89 | Paint paint = new Paint(); 90 | paint.setColor(mColor); 91 | paint.setStyle(Paint.Style.STROKE); 92 | float strokeWidth = width / 20.f; 93 | float strokeWidth_2 = strokeWidth / 2; 94 | paint.setStrokeWidth(strokeWidth); 95 | RectF r1 = new RectF(strokeWidth_2, strokeWidth_2, width - strokeWidth - strokeWidth_2, height - strokeWidth_2); 96 | //设置外边框颜色为灰色 97 | paint.setColor(Color.GRAY); 98 | canvas.drawRect(r1, paint); 99 | paint.setStrokeWidth(0); 100 | paint.setStyle(Paint.Style.FILL); 101 | //画电池内矩形电量 102 | float offset = (width - strokeWidth * 2) * mPower / 100.f; 103 | RectF r2 = new RectF(strokeWidth, strokeWidth, offset, height - strokeWidth); 104 | //根据电池电量决定电池内矩形电量颜色 105 | if (mPower < 20) { 106 | flagunchargeToast++; 107 | paint.setColor(Color.RED); 108 | if (flagunchargeToast == 1) { 109 | Toast.makeText(getContext(), "电量较低,请充电", Toast.LENGTH_SHORT).show(); 110 | } 111 | } 112 | if (mPower >= 20 && mPower < 60) { 113 | paint.setColor(Color.BLUE); 114 | } 115 | if (mPower >= 60) { 116 | paint.setColor(Color.GREEN); 117 | } 118 | canvas.drawRect(r2, paint); 119 | //画电池头 120 | RectF r3 = new RectF(width - strokeWidth, height * 0.25f, width, height * 0.75f); 121 | //设置电池头颜色为黑色 122 | paint.setColor(Color.GRAY); 123 | canvas.drawRect(r3, paint); 124 | } 125 | 126 | 127 | /** 128 | * @param canvas 129 | * @Function: 绘制水平的充电电池的充电 130 | * @Return: 131 | */ 132 | private void drawHorizontalBatteryCharge(Canvas canvas) { 133 | Paint paint = new Paint(); 134 | paint.setColor(mColor); 135 | paint.setStyle(Paint.Style.STROKE); 136 | float strokeWidth = width / 20.f; 137 | float strokeWidth_2 = strokeWidth / 2; 138 | paint.setStrokeWidth(strokeWidth); 139 | RectF r1 = new RectF(strokeWidth_2, strokeWidth_2, width - strokeWidth - strokeWidth_2, height - strokeWidth_2); 140 | //设置外边框颜色为灰色 141 | paint.setColor(Color.GRAY); 142 | canvas.drawRect(r1, paint); 143 | paint.setStrokeWidth(0); 144 | paint.setStyle(Paint.Style.FILL); 145 | //画电池内矩形电量 146 | float offset = (width - strokeWidth * 2) * mPower / 100.f; 147 | RectF r2 = new RectF(strokeWidth, strokeWidth, offset, height - strokeWidth); 148 | //根据电池电量决定电池内矩形电量颜色 149 | if (mPower < 20) { 150 | flagchargeToast++; 151 | paint.setColor(Color.RED); 152 | if (flagchargeToast == 1) { 153 | Toast.makeText(getContext(), "正在充电", Toast.LENGTH_SHORT).show(); 154 | } 155 | } 156 | if (mPower >= 20 && mPower < 60) { 157 | paint.setColor(Color.BLUE); 158 | } 159 | if (mPower >= 60) { 160 | paint.setColor(Color.GREEN); 161 | } 162 | canvas.drawRect(r2, paint); 163 | //画电池头 164 | RectF r3 = new RectF(width - strokeWidth, height * 0.25f, width, height * 0.75f); 165 | //设置电池头颜色为黑色 166 | paint.setColor(Color.GRAY); 167 | canvas.drawRect(r3, paint); 168 | } 169 | 170 | 171 | /** 172 | * 绘制水平电池 173 | * 174 | * @param canvas 175 | */ 176 | private void drawHorizontalBattery(Canvas canvas) { 177 | Paint paint = new Paint(); 178 | paint.setColor(mColor); 179 | paint.setStyle(Paint.Style.STROKE); 180 | float strokeWidth = width / 20.f; 181 | float strokeWidth_2 = strokeWidth / 2; 182 | paint.setStrokeWidth(strokeWidth); 183 | RectF r1 = new RectF(strokeWidth_2, strokeWidth_2, width - strokeWidth - strokeWidth_2, height - strokeWidth_2); 184 | //设置外边框颜色为灰色 185 | paint.setColor(Color.GRAY); 186 | canvas.drawRect(r1, paint); 187 | paint.setStrokeWidth(0); 188 | paint.setStyle(Paint.Style.FILL); 189 | //画电池内矩形电量 190 | float offset = (width - strokeWidth * 2) * mPower / 100.f; 191 | RectF r2 = new RectF(strokeWidth, strokeWidth, offset, height - strokeWidth); 192 | //根据电池电量决定电池内矩形电量颜色 193 | if (mPower < 20) { 194 | paint.setColor(Color.RED); 195 | Toast.makeText(getContext(), "电量较低,请充电", Toast.LENGTH_SHORT).show(); 196 | } 197 | if (mPower >= 20 && mPower < 60) { 198 | paint.setColor(Color.BLUE); 199 | } 200 | if (mPower >= 60) { 201 | paint.setColor(Color.GREEN); 202 | } 203 | canvas.drawRect(r2, paint); 204 | //画电池头 205 | RectF r3 = new RectF(width - strokeWidth, height * 0.25f, width, height * 0.75f); 206 | //设置电池头颜色为黑色 207 | paint.setColor(Color.GRAY); 208 | canvas.drawRect(r3, paint); 209 | } 210 | 211 | /** 212 | * 绘制垂直电池 213 | * 214 | * @param canvas 215 | */ 216 | private void drawVerticalBattery(Canvas canvas) { 217 | Paint paint = new Paint(); 218 | paint.setColor(mColor); 219 | paint.setStyle(Paint.Style.STROKE); 220 | float strokeWidth = height / 20.0f; 221 | float strokeWidth2 = strokeWidth / 2; 222 | paint.setStrokeWidth(strokeWidth); 223 | int headHeight = (int) (strokeWidth + 0.5f); 224 | RectF rect = new RectF(strokeWidth2, headHeight + strokeWidth2, width - strokeWidth2, height - strokeWidth2); 225 | canvas.drawRect(rect, paint); 226 | paint.setStrokeWidth(0); 227 | float topOffset = (height - headHeight - strokeWidth) * (100 - mPower) / 100.0f; 228 | RectF rect2 = new RectF(strokeWidth, headHeight + strokeWidth + topOffset, width - strokeWidth, height - strokeWidth); 229 | paint.setStyle(Paint.Style.FILL); 230 | canvas.drawRect(rect2, paint); 231 | RectF headRect = new RectF(width / 4.0f, 0, width * 0.75f, headHeight); 232 | canvas.drawRect(headRect, paint); 233 | } 234 | 235 | /** 236 | * 设置电池电量 237 | * 238 | * @param power 239 | */ 240 | public void setPower(int power, int flagDir) { 241 | this.mPower = power; 242 | this.flagcharge = flagDir; 243 | if (mPower < 0) { 244 | mPower = 0; 245 | } 246 | if (mPower > 100) { 247 | mPower = 100; 248 | } 249 | invalidate();//刷新VIEW 250 | } 251 | 252 | /** 253 | * 设置电池颜色 254 | * 255 | * @param color 256 | */ 257 | public void setColor(int color) { 258 | this.mColor = color; 259 | invalidate(); 260 | } 261 | 262 | /** 263 | * 获取电池电量 264 | * 265 | * @return 266 | */ 267 | public int getPower() { 268 | return mPower; 269 | } 270 | } -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/customView/DialogActivity.java: -------------------------------------------------------------------------------- 1 | package customView; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.view.Display; 8 | import android.view.View; 9 | import android.view.WindowManager; 10 | import android.widget.Button; 11 | import android.widget.EditText; 12 | 13 | import com.example.dadac.sqlitesavaname.IStatus; 14 | import com.example.dadac.sqlitesavaname.R; 15 | 16 | /** 17 | * @ Create by dadac on 2018/10/31. 18 | * @Function: 19 | * @Return: 20 | */ 21 | public class DialogActivity extends Activity implements View.OnClickListener { 22 | private static final String TAG = "DialogActivity"; 23 | private EditText DC_EditTextPassWord; 24 | private Button DC_Button_unEnsure; 25 | private Button DC_Button_Ensure; 26 | 27 | @Override 28 | protected void onCreate(@Nullable Bundle savedInstanceState) { 29 | super.onCreate(savedInstanceState); 30 | setContentView(R.layout.popupdialog); 31 | //定义弹出框,防止弹出框的高度和宽度变形 32 | WindowManager m = getWindowManager(); 33 | Display d = m.getDefaultDisplay();//为获取屏幕宽、高 34 | WindowManager.LayoutParams p = getWindow().getAttributes();//获取对话框当前的参数值 35 | p.height = (int) (d.getHeight() * 1.0);//高度设置为屏幕的1.0 36 | p.width = (int) (d.getWidth() * 1.0); //宽度设置为屏幕的1.0 37 | //p.alpha = 1.0f;//设置本身透明度 38 | p.dimAmount = 0.8f; //设置黑暗度 39 | getWindow().setAttributes(p);//设置生效 40 | initView(); 41 | 42 | } 43 | 44 | private void initView() { 45 | DC_EditTextPassWord = (EditText) findViewById(R.id.DC_EditTextPassWord); 46 | DC_Button_unEnsure = (Button) findViewById(R.id.DC_Button_unEnsure); 47 | DC_Button_unEnsure.setOnClickListener(this); 48 | DC_Button_Ensure = (Button) findViewById(R.id.DC_Button_Ensure); 49 | DC_Button_Ensure.setOnClickListener(this); 50 | } 51 | 52 | 53 | @Override 54 | protected void onStart() { 55 | super.onStart(); 56 | } 57 | 58 | @Override 59 | protected void onResume() { 60 | super.onResume(); 61 | } 62 | 63 | @Override 64 | protected void onPause() { 65 | super.onPause(); 66 | } 67 | 68 | @Override 69 | protected void onStop() { 70 | super.onStop(); 71 | } 72 | 73 | @Override 74 | protected void onDestroy() { 75 | super.onDestroy(); 76 | } 77 | 78 | 79 | @Override 80 | public void onClick(View v) { 81 | switch (v.getId()) { 82 | case R.id.DC_Button_Ensure: //确定 83 | String content = DC_EditTextPassWord.getText().toString().trim(); 84 | Intent mIntent = new Intent(); 85 | mIntent.putExtra(IStatus.STATE_Intent_ContentPsd, content); 86 | // 设置结果,并进行传送 87 | setResult(IStatus.STATE_IntentResultCode_Psd, mIntent); 88 | finish(); 89 | break; 90 | case R.id.DC_Button_unEnsure: //确定 91 | Intent mIntent1 = new Intent(); 92 | mIntent1.putExtra(IStatus.STATE_Intent_ContentPsd, "a"); 93 | // 设置结果,并进行传送 94 | setResult(IStatus.STATE_IntentResultCode_Psd, mIntent1); 95 | finish(); 96 | break; 97 | default: 98 | break; 99 | } 100 | } 101 | 102 | @Override 103 | public void onPointerCaptureChanged(boolean hasCapture) { 104 | 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/customView/PopupView.java: -------------------------------------------------------------------------------- 1 | package customView; 2 | 3 | import android.app.AlertDialog; 4 | import android.content.Context; 5 | import android.content.DialogInterface; 6 | import android.util.Log; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.widget.EditText; 10 | import android.widget.Toast; 11 | 12 | import com.example.dadac.sqlitesavaname.IStatus; 13 | import com.example.dadac.sqlitesavaname.R; 14 | 15 | 16 | /** 17 | * @ Create by dadac on 2018/10/30. 18 | * @Function: 弹窗的显示 19 | * @Return: 20 | */ 21 | public class PopupView { 22 | 23 | public static void PopupWindow(Context context) { 24 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 25 | builder.setIcon(R.drawable.first); 26 | builder.setTitle("Error"); 27 | builder.setMessage("请检测 IP 是否正确!"); 28 | // 通过LayoutInflater来加载一个xml的布局文件作为一个View对象 29 | View view = LayoutInflater.from(context).inflate(R.layout.popupdialog, null); 30 | // 设置我们自己定义的布局文件作为弹出框的Content 31 | builder.setView(view); 32 | 33 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 34 | @Override 35 | public void onClick(DialogInterface dialog, int which) { 36 | 37 | } 38 | }); 39 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 40 | @Override 41 | public void onClick(DialogInterface dialog, int which) { 42 | 43 | } 44 | }); 45 | builder.show(); 46 | } 47 | 48 | /*删除导航点*/ 49 | public void DeleteNavi(Context context) { 50 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 51 | builder.setIcon(R.drawable.first); 52 | builder.setTitle("Warning"); 53 | builder.setMessage("禁止手动删除导航点,请联系开发者"); 54 | // 通过LayoutInflater来加载一个xml的布局文件作为一个View对象 55 | View view = LayoutInflater.from(context).inflate(R.layout.popupdialog, null); 56 | // 设置我们自己定义的布局文件作为弹出框的Content 57 | builder.setView(view); 58 | 59 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 60 | @Override 61 | public void onClick(DialogInterface dialog, int which) { 62 | 63 | } 64 | }); 65 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 66 | @Override 67 | public void onClick(DialogInterface dialog, int which) { 68 | 69 | } 70 | }); 71 | builder.show(); 72 | } 73 | 74 | // 如果有参数传入 则不要添加 static 75 | public String EnterPassword(View v, final Context context) { 76 | final String[] password = new String[1]; 77 | AlertDialog.Builder builder = new AlertDialog.Builder(context); 78 | builder.setIcon(R.drawable.first); 79 | builder.setTitle("请输入用户名和密码"); 80 | // 通过LayoutInflater来加载一个xml的布局文件作为一个View对象 81 | View view = LayoutInflater.from(context).inflate(R.layout.passworddialog, null); 82 | // 设置我们自己定义的布局文件作为弹出框的Content 83 | builder.setView(view); 84 | 85 | final EditText DC_EditText_EnterPassWord = (EditText) view.findViewById(R.id.DC_EditText_EnterPassWord); 86 | 87 | builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 88 | @Override 89 | public void onClick(DialogInterface dialog, int which) { 90 | password[0] = DC_EditText_EnterPassWord.getText().toString().trim(); 91 | // 将输入的用户名和密码打印出来 92 | // Toast.makeText(context, "密码: " + password[0], Toast.LENGTH_SHORT).show(); 93 | } 94 | }); 95 | builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 96 | @Override 97 | public void onClick(DialogInterface dialog, int which) { 98 | password[0] = "1"; 99 | } 100 | }); 101 | builder.show(); 102 | if (password[0] == null) { 103 | password[0] = "1"; 104 | } 105 | Log.i(IStatus.STATE_Log_Info + "Password", password[0]); 106 | return password[0]; 107 | } 108 | 109 | 110 | } 111 | 112 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/utils/BroadCastTemplate.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | 6 | /** 7 | * @ Create by dadac on 2018/10/19. 8 | * @Function: 9 | * @Return: 10 | */ 11 | public class BroadCastTemplate { 12 | 13 | public static void StartBroadCast(Context context, String setAction, String putExtraKey, String putExtraValue) { 14 | //创建Intent对象 15 | Intent intentBroadcast = new Intent(); 16 | //设置Intent的action属性 17 | intentBroadcast.setAction(setAction); 18 | intentBroadcast.putExtra(putExtraKey, putExtraValue); 19 | //发送广播 20 | context.sendBroadcast(intentBroadcast); 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/java/utils/SerialUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.StringTokenizer; 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | 9 | /** 10 | * @ Create by dadac on 2018/10/12. 11 | * @Function: 各种工具类 12 | * @Return: 13 | */ 14 | public class SerialUtils { 15 | 16 | /** 17 | * @param str 为要去除空格回车的字符串 18 | * @Function: 去除字符串中的 \s \t \r \n 格式 19 | * @Return: dest 为去除后的字符串 20 | */ 21 | public static String replaceTRNBlank(String str) { 22 | String dest = ""; 23 | if (str != null) { 24 | Pattern p = Pattern.compile("\\s*|\t|\r|\n"); 25 | Matcher m = p.matcher(str); 26 | dest = m.replaceAll(""); 27 | } 28 | return dest; 29 | } 30 | 31 | /** 32 | * @param str 指定的字符串 要去除指定的字符 33 | * def 是要去除的字符 比如说 格式 String def String "#" 34 | * @Function: 去除字符串中的指定的字符 35 | * @Return: 36 | * @attention: 注意转义字符 前面得添加 \\ 37 | */ 38 | public static String replaceStringUseDefineWord(String str, String def) { 39 | String dest = ""; 40 | if (str != null) { 41 | Pattern p = Pattern.compile(def); 42 | Matcher m = p.matcher(str); 43 | dest = m.replaceAll(""); 44 | } 45 | 46 | return dest; 47 | } 48 | 49 | /* 50 | * 按字节长度截取字符串 51 | * @param str 将要截取的字符串参数 52 | * @param toCount 截取的字节长度 53 | * @param more 字符串末尾补上的字符串 54 | * @return 返回截取后的字符串 55 | */ 56 | public static String getSubString(String str, int toCount, String more) { 57 | int reInt = 0; 58 | String reStr = ""; 59 | if (str == null) 60 | return ""; 61 | char[] tempChar = str.toCharArray(); 62 | for (int kk = 0; (kk < tempChar.length && toCount > reInt); kk++) { 63 | String s1 = str.valueOf(tempChar[kk]); 64 | byte[] b = s1.getBytes(); 65 | reInt += b.length; 66 | reStr += tempChar[kk]; 67 | } 68 | if (toCount == reInt || (toCount == reInt - 1)) 69 | reStr += more; 70 | return reStr; 71 | } 72 | 73 | /** 74 | * @param def 为分割的标志 75 | * @Function: 分割字符串 76 | * @Return: 无法使用 77 | */ 78 | public static List splitString(String str, String def) { 79 | List savevalue = new ArrayList<>(); 80 | StringTokenizer stringTokenizer = new StringTokenizer(str, "!"); 81 | String Angles = null; 82 | while (stringTokenizer.hasMoreElements()) { 83 | savevalue.add(stringTokenizer.nextToken()); 84 | } 85 | return savevalue; 86 | } 87 | 88 | /** 89 | * @Function: 例如将 String类型的 "[21,3]" 分割成 21 和 3 两个单独的字符串 90 | * @Return: 91 | * @attention: 注意转义字符 前面得添加 \\ 92 | */ 93 | public static List spliteStringPower(String data) { 94 | String a = replaceStringUseDefineWord(replaceStringUseDefineWord(data, "\\["), "\\]"); 95 | String[] b = a.split("[,]"); 96 | List c = new ArrayList(); 97 | c.add(b[0]); 98 | c.add(b[1]); 99 | return c; 100 | } 101 | 102 | /** 103 | * @Function: 判断一个字符串是否都为数字 104 | * @Return: true or false 105 | */ 106 | public static boolean isAllDigit(String strNum) { 107 | Pattern pattern = Pattern.compile("[0-9]{1,}"); 108 | Matcher matcher = pattern.matcher((CharSequence) strNum); 109 | return matcher.matches(); 110 | } 111 | 112 | // 判断一个字符串是否都为数字 113 | public static boolean isDigitRegular(String strNum) { 114 | return strNum.matches("[0-9]{1,}"); 115 | } 116 | 117 | // 判断一个字符串是否含有数字 118 | public boolean HasDigit(String content) { 119 | boolean flag = false; 120 | Pattern p = Pattern.compile(".*\\d+.*"); 121 | Matcher m = p.matcher(content); 122 | if (m.matches()) { 123 | flag = true; 124 | } 125 | return flag; 126 | } 127 | 128 | /** 129 | * @param size 为 String 保留小数点后几位 130 | * @Function: number 为输入的值 string类型 保留 double类型的小数点几位 131 | * @Return: float 类型的 小数点后 2位 要是返回的数据超过 7位 则得改用Float 132 | */ 133 | public static float savePointEndNumberFloat(String number, String size) { 134 | String result = String.format("%." + size + "f", Double.parseDouble(number)); 135 | return Float.parseFloat(result); 136 | } 137 | 138 | //保留小数点后几位 139 | public static double savePointEndNumberDouble(String number, String size) { 140 | String result = String.format("%." + size + "f", Double.parseDouble(number)); 141 | return Double.parseDouble(result); 142 | } 143 | 144 | /** 145 | * @param angle 语音唤醒的 angle 146 | * @Function: 将语音的唤醒值0-360 转变成 惯导的类型 147 | * 语音唤醒为0--360 148 | * 惯导 机器人左边为 0 --- -180 机器人 左转 + x=0 y=0 z>0 不要太大 多少弧度每秒 149 | * 右边为 0 --- +180 机器人 右转 - z<0 150 | * @Return: 惯导的 angle 151 | * 但是用不着 152 | */ 153 | public static int WakeUpToINSAngle(String angle) { 154 | int WakeToINS = Integer.parseInt(angle); 155 | if (WakeToINS <= 180) { 156 | if (WakeToINS == 180) 157 | WakeToINS = 179; 158 | WakeToINS = -WakeToINS; 159 | } 160 | if (WakeToINS > 180) { 161 | WakeToINS = 360 - WakeToINS; 162 | if(WakeToINS==360) 163 | WakeToINS=0; 164 | } 165 | if (WakeToINS == 180) WakeToINS = 179; 166 | return WakeToINS; 167 | } 168 | 169 | } 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/background.jpg -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/first.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/ico_robot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/ico_robot.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_down.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_down_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_down_press.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_left.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_left_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_left_press.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_right.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_right_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_right_press.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_up.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/move_up_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KEYD111/RemoteControlAndroidROS/79b8096874227aaa248fe07b04da8a2fae9ebe4e/HandControlLongBtn/app/src/main/res/drawable/move_up_press.png -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/xml_move_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/xml_move_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/xml_move_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/drawable/xml_move_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /HandControlLongBtn/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 19 | 20 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 48 | 49 | 50 | 51 | 52 | 53 | 59 | 60 | 66 | 67 | 74 | 75 | 81 | 82 | 89 | 90 | 91 | 92 | 93 | 98 | 99 |