Compare commits
No commits in common. '6a708f9eb5eb921cd1db15c4c11344acf43c92af' and '51f29639b8787158012e0bc77bfcc09c4764b399' have entirely different histories.
6a708f9eb5
...
51f29639b8
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 9.1 KiB |
Before Width: | Height: | Size: 9.8 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 9.0 KiB |
@ -1,20 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.example.logistics",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<script type="text/javascript" type="text/javascript">
|
||||
|
||||
function callJS(){
|
||||
var ros = new ROSLIB.Ros({
|
||||
url : 'ws://192.168.43.164:9090'
|
||||
});
|
||||
|
||||
ros.on('connection', function() {
|
||||
console.log('Connected to websocket server.');
|
||||
});
|
||||
|
||||
ros.on('error', function(error) {
|
||||
console.log('Error connecting to websocket server: ', error);
|
||||
});
|
||||
|
||||
ros.on('close', function() {
|
||||
console.log('Connection to websocket server closed.');
|
||||
});
|
||||
|
||||
// 发布一个话题
|
||||
|
||||
|
||||
|
||||
var move_base= new ROSLIB.ActionClient({
|
||||
ros : ros,
|
||||
serverName : '/move_base',
|
||||
actionName : 'move_base_msgs/MoveBaseAction'
|
||||
});
|
||||
|
||||
var currentTime = new Date();
|
||||
var secs = Math.floor(currentTime.getTime()/1000)
|
||||
var nsecs = Math.round(1000000000*(currentTime.getTime()/1000-secs))
|
||||
|
||||
var goal = new ROSLIB.Goal({
|
||||
actionClient: move_base,
|
||||
goalMessage:{
|
||||
target_pose:{
|
||||
header:{
|
||||
frame_id:'map',
|
||||
stamp:{
|
||||
secs: secs,
|
||||
nsecs:nsecs
|
||||
}
|
||||
},
|
||||
pose:{
|
||||
position:{
|
||||
x:-3.97, //-0.743 -0.0273 取件点
|
||||
y:1.68, //3.00 -0.09
|
||||
z:0.000
|
||||
},
|
||||
orientation:{
|
||||
x:0.000,
|
||||
y:0.000,
|
||||
z:0.000,
|
||||
w:1.000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
goal.on('feedback', function(feedback) {
|
||||
console.log('Feedback: ' + feedback.sequence);
|
||||
});
|
||||
|
||||
goal.on('result', function(result) {
|
||||
console.log('Final Result: ' + result.sequence);
|
||||
});
|
||||
|
||||
ros.on('connection', function() {
|
||||
console.log('Connected to websocket server.');
|
||||
});
|
||||
|
||||
ros.on('error', function(error) {
|
||||
console.log('Error connecting to websocket server: ', error);
|
||||
});
|
||||
|
||||
ros.on('close', function() {
|
||||
console.log('Connection to websocket server closed.');
|
||||
});
|
||||
|
||||
goal.send();
|
||||
|
||||
/*var cmdVel = new ROSLIB.Topic({
|
||||
ros : ros,
|
||||
name : '/cmd_vel_mux/input/navi',
|
||||
messageType : 'geometry_msgs/Twist'
|
||||
});
|
||||
|
||||
var twist = new ROSLIB.Message({
|
||||
linear : {
|
||||
x : 0.2,
|
||||
y : 0.0,
|
||||
z : 0.0
|
||||
},
|
||||
angular : {
|
||||
x : 0.0,
|
||||
y : 0.0,
|
||||
z : 0.0
|
||||
}
|
||||
});
|
||||
cmdVel.publish(twist);*/
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Simple roslib Example</h1>
|
||||
<p>Check your Web Console for output.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,106 +0,0 @@
|
||||
package com.example.logistics.dao;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.example.logistics.entity.User;
|
||||
import com.example.logistics.tools.DBOpenHelper;
|
||||
import com.example.logistics.tools.MD5Utils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class operationDao {
|
||||
private static final String TAG = "operationDao";
|
||||
|
||||
public boolean add(String pickupcode, String phonenum){
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
Connection connection = DBOpenHelper.getConn();
|
||||
try{
|
||||
SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
||||
|
||||
Date date = new Date();
|
||||
|
||||
String time = format1.format(date);
|
||||
|
||||
String sql = "insert into operations(pickupcode, phonenum, time) values (?,?,?)";
|
||||
|
||||
if(connection != null){
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
|
||||
if(ps != null){
|
||||
ps.setString(1, pickupcode);
|
||||
ps.setString(2, phonenum);
|
||||
ps.setString(3, time);
|
||||
|
||||
int rs = ps.executeUpdate();
|
||||
if(rs > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "异常 add operation");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> history(String phonenum){
|
||||
|
||||
Connection connection = DBOpenHelper.getConn();
|
||||
|
||||
List<Map<String, Object>> datalist;
|
||||
datalist = new ArrayList<Map<String, Object>>();
|
||||
try{
|
||||
String sql = "select * from operations where phonenum = ?";
|
||||
|
||||
if(connection != null){
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
if(ps != null){
|
||||
Log.e(TAG, "phonenum: " + phonenum);
|
||||
ps.setString(1,phonenum);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
int count = rs.getMetaData().getColumnCount();
|
||||
while(rs.next()){
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
for(int i = 1; i <= count; i++){
|
||||
String field = rs.getMetaData().getColumnName(i);
|
||||
if(field.equals("pickupcode")){
|
||||
map.put(field, rs.getString(field));
|
||||
}
|
||||
if(field.equals("time")) {
|
||||
map.put(field, rs.getString(field));
|
||||
}
|
||||
}
|
||||
datalist.add(map);
|
||||
}
|
||||
connection.close();
|
||||
ps.close();
|
||||
}else{
|
||||
Log.e(TAG, "ps is null");
|
||||
}
|
||||
}else{
|
||||
Log.e(TAG, "connection is null");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, "search bug: " + e.getMessage());
|
||||
}
|
||||
return datalist;
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package com.example.logistics.entity;
|
||||
|
||||
import android.provider.ContactsContract;
|
||||
|
||||
public class Operation {
|
||||
private int id;
|
||||
private String pickUpCode;
|
||||
private String phoneNum;
|
||||
private String time;
|
||||
|
||||
public Operation(){
|
||||
|
||||
}
|
||||
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getPickUpCode(){
|
||||
return pickUpCode;
|
||||
}
|
||||
|
||||
public void setPickUpCode(String PickUpCode){
|
||||
this.pickUpCode = PickUpCode;
|
||||
}
|
||||
|
||||
public String getPhoneNum(){
|
||||
return phoneNum;
|
||||
}
|
||||
|
||||
public void setPhoneNum(String PhoneNum){
|
||||
this.phoneNum = PhoneNum;
|
||||
}
|
||||
|
||||
public String getTime(){
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time){
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.example.logistics.tools;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.jilk.ros.rosbridge.ROSBridgeClient;
|
||||
|
||||
/**
|
||||
* @ Create by dadac on 2018/10/8.
|
||||
* @Function:
|
||||
* @Return:
|
||||
*/
|
||||
public class RCApplication extends Application {
|
||||
|
||||
|
||||
ROSBridgeClient client;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTerminate() {
|
||||
if (client != null)
|
||||
client.disconnect();
|
||||
super.onTerminate();
|
||||
|
||||
}
|
||||
|
||||
public ROSBridgeClient getRosClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public void setRosClient(ROSBridgeClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,123 +0,0 @@
|
||||
package com.example.logistics.ui;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.media.Image;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.logistics.R;
|
||||
import com.example.logistics.dao.goodDao;
|
||||
import com.example.logistics.dao.operationDao;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class HistoryActivity extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
|
||||
|
||||
private String TAG = "HistoryActivity";
|
||||
private ListView lv_history;
|
||||
private ArrayAdapter<String> arr_adapter;
|
||||
private SimpleAdapter simp_adapter;
|
||||
private String phonenum;
|
||||
private List<Map<String, Object>> dataList;
|
||||
private ImageButton sync_his;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_history);
|
||||
sync_his = (ImageButton) findViewById(R.id.sync_his);
|
||||
dataList=new ArrayList<Map<String,Object>>();
|
||||
lv_history = (ListView) findViewById(R.id.lv_history);
|
||||
|
||||
simp_adapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"pickupcode","time"}, new int[]{R.id.np_id,R.id.np_time});
|
||||
lv_history.setAdapter(simp_adapter);
|
||||
lv_history.setOnItemClickListener(this);
|
||||
lv_history.setOnScrollListener(this);
|
||||
sync_his.setOnClickListener(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
phonenum = intent.getStringExtra("user");
|
||||
|
||||
sync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
String text=lv_history.getItemAtPosition(position)+"";
|
||||
Toast.makeText(this, "position="+position+" text="+text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
switch(v.getId()){
|
||||
case R.id.sync_his:
|
||||
sync();
|
||||
Toast.makeText(this, "同步成功", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState){
|
||||
// TODO Auto-generated method stub
|
||||
switch(scrollState){
|
||||
case SCROLL_STATE_FLING:
|
||||
Log.i(TAG, "用户在手指离开屏幕之前,由于用力划了一下,试图仍依靠惯性继续滑动");
|
||||
break;
|
||||
case SCROLL_STATE_IDLE:
|
||||
Log.i(TAG, "视图已经停止滑动");
|
||||
break;
|
||||
case SCROLL_STATE_TOUCH_SCROLL:
|
||||
Log.i(TAG, "手指没有离开屏幕,视图正在滑动");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int arg1, int arg2, int arg3){
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void sync(){
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
operationDao operationDao = new operationDao();
|
||||
dataList = operationDao.history(phonenum);
|
||||
|
||||
int msg = 1;
|
||||
hand1.sendEmptyMessage(msg);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
final Handler hand1 = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg){
|
||||
if(msg.what == 1){
|
||||
simp_adapter=new SimpleAdapter(HistoryActivity.this, dataList, R.layout.item, new String[]{"pickupcode","time"}, new int[]{R.id.np_id,R.id.np_time});
|
||||
lv_history.setAdapter(simp_adapter);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
package com.example.logistics.ui;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.logistics.R;
|
||||
import com.example.logistics.dao.goodDao;
|
||||
import com.example.logistics.dao.userDao;
|
||||
import com.example.logistics.entity.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class NoPickActivity extends Activity implements OnItemClickListener, OnScrollListener, View.OnClickListener {
|
||||
|
||||
private String TAG = "NoPickActivity";
|
||||
private ListView lv_nopick;
|
||||
private ArrayAdapter<String> arr_adapter;
|
||||
private SimpleAdapter simp_adapter;
|
||||
private String phonenum;
|
||||
private List<Map<String, Object>> dataList;
|
||||
private ImageButton sync_np;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_no_pick);
|
||||
|
||||
dataList=new ArrayList<Map<String,Object>>();
|
||||
lv_nopick = (ListView) findViewById(R.id.lv_nopick);
|
||||
sync_np = (ImageButton) findViewById(R.id.sync_np);
|
||||
|
||||
simp_adapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"id","time"}, new int[]{R.id.np_id,R.id.np_time});
|
||||
lv_nopick.setAdapter(simp_adapter);
|
||||
lv_nopick.setOnItemClickListener(this);
|
||||
lv_nopick.setOnScrollListener(this);
|
||||
sync_np.setOnClickListener(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
phonenum = intent.getStringExtra("user");
|
||||
|
||||
sync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
String text=lv_nopick.getItemAtPosition(position)+"";
|
||||
Toast.makeText(this, "position="+position+" text="+text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v){
|
||||
switch(v.getId()){
|
||||
case R.id.sync_np:
|
||||
sync();
|
||||
Toast.makeText(this, "同步成功", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState){
|
||||
// TODO Auto-generated method stub
|
||||
switch(scrollState){
|
||||
case SCROLL_STATE_FLING:
|
||||
Log.i(TAG, "用户在手指离开屏幕之前,由于用力划了一下,试图仍依靠惯性继续滑动");
|
||||
break;
|
||||
case SCROLL_STATE_IDLE:
|
||||
Log.i(TAG, "视图已经停止滑动");
|
||||
break;
|
||||
case SCROLL_STATE_TOUCH_SCROLL:
|
||||
Log.i(TAG, "手指没有离开屏幕,视图正在滑动");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int arg1, int arg2, int arg3){
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
public void sync(){
|
||||
new Thread(){
|
||||
@Override
|
||||
public void run(){
|
||||
goodDao goodDao = new goodDao();
|
||||
dataList = goodDao.nopick(phonenum);
|
||||
|
||||
int msg = 1;
|
||||
hand1.sendEmptyMessage(msg);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@SuppressLint("HandlerLeak")
|
||||
final Handler hand1 = new Handler(){
|
||||
@Override
|
||||
public void handleMessage(Message msg){
|
||||
if(msg.what == 1){
|
||||
simp_adapter=new SimpleAdapter(NoPickActivity.this, dataList, R.layout.item, new String[]{"id","time"}, new int[]{R.id.np_id,R.id.np_time});
|
||||
lv_nopick.setAdapter(simp_adapter);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros;
|
||||
|
||||
import com.jilk.ros.message.Clock;
|
||||
import com.jilk.ros.message.Log;
|
||||
import com.jilk.ros.rosapi.message.Empty;
|
||||
import com.jilk.ros.rosapi.message.GetTime;
|
||||
import com.jilk.ros.rosapi.message.MessageDetails;
|
||||
import com.jilk.ros.rosapi.message.Type;
|
||||
import com.jilk.ros.rosbridge.ROSBridgeClient;
|
||||
|
||||
public class Example {
|
||||
|
||||
public Example() {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ROSBridgeClient client = new ROSBridgeClient("ws://162.243.238.80:9090");
|
||||
client.connect();
|
||||
//testTopic(client);
|
||||
try {
|
||||
testService(client);
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public static void testService(ROSBridgeClient client) {
|
||||
try {
|
||||
Service<Empty, GetTime> timeService =
|
||||
new Service<Empty, GetTime>("/rosapi/get_time", Empty.class, GetTime.class, client);
|
||||
timeService.verify();
|
||||
//System.out.println("Time (secs): " + timeService.callBlocking(new Empty()).time.sec);
|
||||
|
||||
Service<com.jilk.ros.rosapi.message.Service, Type> serviceTypeService =
|
||||
new Service<com.jilk.ros.rosapi.message.Service, Type>("/rosapi/service_type",
|
||||
com.jilk.ros.rosapi.message.Service.class, Type.class, client);
|
||||
serviceTypeService.verify();
|
||||
String type = serviceTypeService.callBlocking(new com.jilk.ros.rosapi.message.Service("/rosapi/service_response_details")).type;
|
||||
|
||||
Service<Type, MessageDetails> serviceDetails =
|
||||
new Service<Type, MessageDetails>("/rosapi/service_response_details",
|
||||
Type.class, MessageDetails.class, client);
|
||||
serviceDetails.verify();
|
||||
//serviceDetails.callBlocking(new Type(type)).print();
|
||||
|
||||
Topic<Log> logTopic =
|
||||
new Topic<Log>("/rosout", Log.class, client);
|
||||
logTopic.verify();
|
||||
|
||||
/*
|
||||
System.out.println("Nodes");
|
||||
for (String s : client.getNodes())
|
||||
System.out.println(" " + s);
|
||||
System.out.println("Topics");
|
||||
for (String s : client.getTopics()) {
|
||||
System.out.println(s + ":");
|
||||
client.getTopicMessageDetails(s).print();
|
||||
}
|
||||
System.out.println("Services");
|
||||
for (String s : client.getServices()) {
|
||||
System.out.println(s + ":");
|
||||
client.getServiceRequestDetails(s).print();
|
||||
System.out.println("-----------------");
|
||||
client.getServiceResponseDetails(s).print();
|
||||
}
|
||||
*/
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
System.out.println("Process was interrupted.");
|
||||
}
|
||||
/*
|
||||
Service<Empty, Topics> topicService =
|
||||
new Service<Empty, Topics>("/rosapi/topics", Empty.class, Topics.class, client);
|
||||
Service<Topic, Type> typeService =
|
||||
new Service<Topic, Type>("/rosapi/topic_type", Topic.class, Type.class, client);
|
||||
Service<Type, MessageDetails> messageService =
|
||||
new Service<Type, MessageDetails>("/rosapi/message_details", Type.class, MessageDetails.class, client);
|
||||
try {
|
||||
Topics topics = topicService.callBlocking(new Empty());
|
||||
for (String topicString : topics.topics) {
|
||||
Topic topic = new Topic();
|
||||
topic.topic = topicString;
|
||||
Type type = typeService.callBlocking(topic);
|
||||
MessageDetails details = messageService.callBlocking(type);
|
||||
System.out.println("Topic: " + topic.topic + " Type: " + type.type);
|
||||
details.print();
|
||||
System.out.println();
|
||||
}
|
||||
Type type = new Type();
|
||||
type.type = "time";
|
||||
System.out.print("Single type check on \'time\': ");
|
||||
messageService.callBlocking(type).print();
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
System.out.println("testService: process was interrupted.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public static void testTopic(ROSBridgeClient client) {
|
||||
Topic<Clock> clockTopic = new Topic<Clock>("/clock", Clock.class, client);
|
||||
clockTopic.subscribe();
|
||||
try {
|
||||
Thread.sleep(20000);} catch(InterruptedException ex) {}
|
||||
Clock cl = null;
|
||||
try {
|
||||
cl = clockTopic.take(); // just gets one
|
||||
}
|
||||
catch (InterruptedException ex) {}
|
||||
cl.print();
|
||||
cl.clock.nsecs++;
|
||||
clockTopic.unsubscribe();
|
||||
clockTopic.advertise();
|
||||
clockTopic.publish(cl);
|
||||
clockTopic.unadvertise();
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
|
||||
public interface MessageHandler<T extends Message> {
|
||||
public void onMessage(T message);
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.rosapi.message.TypeDef;
|
||||
import com.jilk.ros.rosbridge.FullMessageHandler;
|
||||
import com.jilk.ros.rosbridge.ROSBridgeClient;
|
||||
import com.jilk.ros.rosbridge.operation.Operation;
|
||||
|
||||
public abstract class ROSClient {
|
||||
|
||||
public ROSClient() {}
|
||||
|
||||
public static ROSClient create(String uriString) {
|
||||
// if we ever implement other ROSClient types, we'll key off the URI protocol (e.g., ws://)
|
||||
// we'd also have to abstract out Topic and Service since they depend on the ROSBridge operations
|
||||
return new ROSBridgeClient(uriString);
|
||||
}
|
||||
|
||||
public abstract boolean connect();
|
||||
public abstract boolean connect(ConnectionStatusListener listener);
|
||||
public abstract void disconnect();
|
||||
public abstract void send(Operation operation);
|
||||
public abstract void send(String json);
|
||||
public abstract void register(Class<? extends Operation> c,
|
||||
String s,
|
||||
Class<? extends Message> m,
|
||||
FullMessageHandler h);
|
||||
public abstract void unregister(Class<? extends Operation> c, String s);
|
||||
public abstract void setDebug(boolean debug);
|
||||
public abstract String[] getNodes() throws InterruptedException;
|
||||
public abstract String[] getTopics() throws InterruptedException;
|
||||
public abstract String[] getServices() throws InterruptedException;
|
||||
public abstract TypeDef getTopicMessageDetails(String topic) throws InterruptedException;
|
||||
public abstract TypeDef[] getTopicMessageList(String topic) throws InterruptedException;
|
||||
public abstract TypeDef getServiceRequestDetails(String service) throws InterruptedException;
|
||||
public abstract TypeDef[] getServiceRequestList(String service) throws InterruptedException;
|
||||
public abstract TypeDef getServiceResponseDetails(String service) throws InterruptedException;
|
||||
public abstract TypeDef[] getServiceResponseList(String service) throws InterruptedException;
|
||||
public abstract TypeDef getTypeDetails(String type) throws InterruptedException;
|
||||
public abstract TypeDef[] getTypeList(String type) throws InterruptedException;
|
||||
public abstract void typeMatch(TypeDef t, Class<? extends Message> c) throws InterruptedException;
|
||||
public abstract Object getUnderlyingClient(); // for debugging
|
||||
|
||||
public interface ConnectionStatusListener {
|
||||
public void onConnect();
|
||||
public void onDisconnect(boolean normal, String reason, int code);
|
||||
public void onError(Exception ex);
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.rosbridge.FullMessageHandler;
|
||||
import com.jilk.ros.rosbridge.operation.CallService;
|
||||
import com.jilk.ros.rosbridge.operation.ServiceResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class Service<CallType extends Message, ResponseType extends Message> extends Message implements FullMessageHandler {
|
||||
private String service;
|
||||
private Class<? extends ResponseType> responseType;
|
||||
private Class<? extends CallType> callType;
|
||||
private ROSClient client;
|
||||
private Map<String, CallRecord> calls;
|
||||
|
||||
public Service(String service, Class<? extends CallType> callType,
|
||||
Class<? extends ResponseType> responseType, ROSClient client) {
|
||||
this.service = service;
|
||||
this.client = client;
|
||||
this.responseType = responseType;
|
||||
this.callType = callType;
|
||||
calls = new HashMap<String, CallRecord>();
|
||||
}
|
||||
|
||||
// A result can only be returned once; it is cleared from the hash before
|
||||
// being sent/returned. This is to ensure that results do not accumulate
|
||||
// indefinitely. If callers need to keep these around they can set up their
|
||||
// own hash.
|
||||
|
||||
@Override
|
||||
public void onMessage(String id, Message response) {
|
||||
//System.out.print("Service.onMessage: ");
|
||||
//response.print();
|
||||
CallRecord call = calls.get(id);
|
||||
if(call == null) {
|
||||
System.out.print("No caller service response");
|
||||
return;
|
||||
}
|
||||
if (call.handler != null) {
|
||||
calls.remove(id);
|
||||
call.handler.onMessage((ResponseType) response);
|
||||
}
|
||||
else {
|
||||
call.result = (ResponseType) response;
|
||||
call.latch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
public String call(CallType args) {
|
||||
return callImpl(args, null);
|
||||
}
|
||||
|
||||
public void callWithHandler(CallType args, MessageHandler<ResponseType> responseHandler) {
|
||||
callImpl(args, responseHandler);
|
||||
}
|
||||
|
||||
public ResponseType callBlocking(CallType args) throws InterruptedException {
|
||||
return take(call(args));
|
||||
}
|
||||
|
||||
private String callImpl(CallType args, MessageHandler<ResponseType> responseHandler) {
|
||||
client.register(ServiceResponse.class, service, responseType, this); // do this once on creation?
|
||||
CallService messageCallService = new CallService(service, args);
|
||||
String id = messageCallService.id;
|
||||
CallRecord callRecord = new CallRecord(responseHandler);
|
||||
calls.put(id, callRecord);
|
||||
client.send(messageCallService);
|
||||
return id;
|
||||
}
|
||||
|
||||
public ResponseType poll(String id) {
|
||||
CallRecord call = calls.get(id);
|
||||
if (call.result != null)
|
||||
calls.remove(id);
|
||||
return call.result;
|
||||
}
|
||||
|
||||
public ResponseType take(String id) throws InterruptedException {
|
||||
CallRecord call = calls.get(id);
|
||||
call.latch.await();
|
||||
calls.remove(id);
|
||||
return call.result;
|
||||
}
|
||||
|
||||
public void verify() throws InterruptedException {
|
||||
|
||||
boolean hasService = false;
|
||||
for (String s : client.getServices()) {
|
||||
if (s.equals(service)) {
|
||||
hasService = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasService)
|
||||
throw new RuntimeException("Service \'" + service + "\' not available.");
|
||||
|
||||
client.typeMatch(client.getServiceRequestDetails(service), callType);
|
||||
client.typeMatch(client.getServiceResponseDetails(service), responseType);
|
||||
}
|
||||
|
||||
private class CallRecord {
|
||||
public ResponseType result;
|
||||
public CountDownLatch latch;
|
||||
public MessageHandler<ResponseType> handler;
|
||||
|
||||
public CallRecord(MessageHandler<ResponseType> handler) {
|
||||
this.result = null;
|
||||
this.latch = new CountDownLatch(1);
|
||||
this.handler = handler;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.rosbridge.FullMessageHandler;
|
||||
import com.jilk.ros.rosbridge.operation.Advertise;
|
||||
import com.jilk.ros.rosbridge.operation.Operation;
|
||||
import com.jilk.ros.rosbridge.operation.Publish;
|
||||
import com.jilk.ros.rosbridge.operation.Subscribe;
|
||||
import com.jilk.ros.rosbridge.operation.Unadvertise;
|
||||
import com.jilk.ros.rosbridge.operation.Unsubscribe;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
|
||||
public class Topic<T extends Message> extends LinkedBlockingQueue<T> implements FullMessageHandler {
|
||||
protected String topic;
|
||||
private Class<? extends T> type;
|
||||
private String messageType;
|
||||
private ROSClient client;
|
||||
private Thread handlerThread;
|
||||
|
||||
public Topic(String topic, Class<? extends T> type, ROSClient client) {
|
||||
this.topic = topic;
|
||||
this.client = client;
|
||||
this.type = type;
|
||||
messageType = Message.getMessageType(type);
|
||||
handlerThread = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String id, Message message) {
|
||||
add((T) message);
|
||||
}
|
||||
|
||||
|
||||
// warning: there is a delay between the completion of this method and
|
||||
// the completion of the subscription; it takes longer than
|
||||
// publishing multiple other messages, for example.
|
||||
public void subscribe(MessageHandler<T> handler) {
|
||||
startRunner(handler);
|
||||
subscribe();
|
||||
}
|
||||
|
||||
public void subscribe() {
|
||||
client.register(Publish.class, topic, type, this);
|
||||
send(new Subscribe(topic, messageType));
|
||||
}
|
||||
|
||||
public void unsubscribe() {
|
||||
// need to handle race conditions in incoming message handler
|
||||
// so that once unsubscribe has happened the handler gets no more
|
||||
// messages
|
||||
send(new Unsubscribe(topic));
|
||||
client.unregister(Publish.class, topic);
|
||||
stopRunner();
|
||||
}
|
||||
|
||||
private void startRunner(MessageHandler<T> handler) {
|
||||
stopRunner();
|
||||
handlerThread = new Thread(new MessageRunner(handler));
|
||||
handlerThread.setName("Message handler for " + topic);
|
||||
handlerThread.start();
|
||||
}
|
||||
|
||||
private void stopRunner() {
|
||||
if (handlerThread != null) {
|
||||
handlerThread.interrupt();
|
||||
clear();
|
||||
handlerThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void advertise() {
|
||||
send(new Advertise(topic, messageType));
|
||||
}
|
||||
|
||||
public void publish(T message) {
|
||||
send(new Publish(topic, message));
|
||||
}
|
||||
|
||||
public void unadvertise() {
|
||||
send(new Unadvertise(topic));
|
||||
}
|
||||
|
||||
private void send(Operation operation) {
|
||||
client.send(operation);
|
||||
}
|
||||
|
||||
public void verify() throws InterruptedException {
|
||||
|
||||
boolean hasTopic = false;
|
||||
for (String s : client.getTopics()) {
|
||||
if (s.equals(topic)) {
|
||||
hasTopic = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasTopic)
|
||||
throw new RuntimeException("Topic \'" + topic + "\' not available.");
|
||||
|
||||
client.typeMatch(client.getTopicMessageDetails(topic), type);
|
||||
}
|
||||
|
||||
private class MessageRunner implements Runnable {
|
||||
private MessageHandler<T> handler;
|
||||
|
||||
public MessageRunner(MessageHandler<T> handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (!Thread.interrupted()) {
|
||||
try {
|
||||
handler.onMessage(take());
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.jilk.ros.message;
|
||||
|
||||
/**
|
||||
* Created by xxhong on 16-11-17.
|
||||
*/
|
||||
@MessageType(string = "std_msgs/Int16MultiArray")
|
||||
public class AudioMsg extends Message {
|
||||
public short[] data;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "rosgraph_msgs/Clock")
|
||||
public class Clock extends Message {
|
||||
public TimePrimitive clock;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "std_msgs/Duration")
|
||||
public class Duration extends DurationPrimitive {
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "duration")
|
||||
public class DurationPrimitive extends TimePrimitive {
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "std_srvs/Empty")
|
||||
public class Empty extends Message {
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "std_msgs/Header")
|
||||
public class Header extends Message {
|
||||
public long seq;
|
||||
public TimePrimitive stamp;
|
||||
public String frame_id;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "rosgraph_msgs/Log")
|
||||
public class Log extends Message {
|
||||
public Header header;
|
||||
public byte level;
|
||||
public String name;
|
||||
public String msg;
|
||||
public String file;
|
||||
public String function;
|
||||
public long line;
|
||||
public String[] topics;
|
||||
}
|
@ -1,202 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@MessageType(string = "message")
|
||||
public abstract class Message {
|
||||
|
||||
// Some requirements about message types:
|
||||
// - It must have a MessageType declaration to be recognized on inbound messages
|
||||
// - Every field must be explicitly designated as public
|
||||
// - Every field that is not a primitive or near-primitive must be another Message class
|
||||
// - If there is a non-empty constructor, you must also have an empty constructor
|
||||
// - If it is set up as an inner class, it needs an explicit nullary constructor
|
||||
// (note: I have seen an inner class otherwise fail, I have not tested it with the explicit constructor)
|
||||
|
||||
public static void register(Class c, Map<String, Class> messageClasses) {
|
||||
try {
|
||||
typecheck(c);
|
||||
|
||||
// Must register the class and not have duplicate
|
||||
// This is not recursive because only the top level message class
|
||||
// needs to be determined from the string - others are top-down.
|
||||
String messageString = getMessageType(c);
|
||||
Class existingClass = messageClasses.get(messageString);
|
||||
if (existingClass != null && !existingClass.equals(c))
|
||||
throw new MessageException("Message String \'" + messageString +
|
||||
"\' is assigned to two different classes (" +
|
||||
c.getName() + " and " + existingClass.getName() + ")");
|
||||
messageClasses.put(messageString, c);
|
||||
}
|
||||
catch (MessageException ex) {
|
||||
// should be changed to be a hooked method to give library user control
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMessageType(Class c) {
|
||||
return ((MessageType) c.getAnnotation(MessageType.class)).string();
|
||||
}
|
||||
|
||||
// this has never been used or tested but kind of belongs here
|
||||
// commented out because it uses ReflectiveOperationException which is not available on Android
|
||||
/*
|
||||
public static Message newInstance(String className) {
|
||||
try {
|
||||
Class messageClass = Class.forName(className);
|
||||
if (Message.class.isAssignableFrom(messageClass))
|
||||
return (Message) messageClass.newInstance();
|
||||
else throw new ClassCastException();
|
||||
}
|
||||
catch (ReflectiveOperationException ex) {
|
||||
throw new RuntimeException("Unable to create message of class \'" + className + "\'.", ex);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Could probably do more checking here, but not sure what right now
|
||||
private static void typecheck(Class c) throws MessageException {
|
||||
|
||||
// Must inherit from Message
|
||||
if (!Message.class.isAssignableFrom(c))
|
||||
throw new MessageException("Class \'" + c.getName() +
|
||||
"\' does not extend Message");
|
||||
|
||||
// Must have the MessageType annotation
|
||||
if (getMessageType(c) == null)
|
||||
throw new MessageException("Class \'" + c.getName() +
|
||||
"\' is missing the MessageType annotation");
|
||||
|
||||
// All fields must also be valid Message classes
|
||||
// Note that this also serves to force-load all the message classes
|
||||
// so that they get registered
|
||||
for (Field f : c.getFields()) {
|
||||
Class fc = f.getType();
|
||||
if (fc.isArray()) {
|
||||
Class ac = fc.getComponentType();
|
||||
if (!isPrimitive(ac))
|
||||
typecheck(ac);
|
||||
}
|
||||
else if (!isPrimitive(fc))
|
||||
typecheck(fc);
|
||||
}
|
||||
}
|
||||
|
||||
public void print() {
|
||||
printMessage(this, "");
|
||||
}
|
||||
|
||||
private static void printMessage(Object o, String indent) {
|
||||
for (Field f : o.getClass().getFields()) {
|
||||
Class c = f.getType();
|
||||
Object fieldObject = getFieldObject(f, o);
|
||||
if (fieldObject != null) {
|
||||
if (isPrimitive(c))
|
||||
System.out.println(indent + f.getName() + ": " + fieldObject);
|
||||
else if (c.isArray()) {
|
||||
System.out.println(indent + f.getName() + ": [");
|
||||
printArray(fieldObject, indent + " ");
|
||||
System.out.println(indent + "]");
|
||||
}
|
||||
else {
|
||||
System.out.println(indent + f.getName() + ":");
|
||||
printMessage(fieldObject, indent + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void printArray(Object array, String indent) {
|
||||
Class arrayClass = array.getClass().getComponentType();
|
||||
for (int i = 0; i < Array.getLength(array); i++) {
|
||||
Object elementObject = Array.get(array, i);
|
||||
if (elementObject != null) {
|
||||
if (isPrimitive(arrayClass))
|
||||
System.out.println(indent + i + ": " + elementObject);
|
||||
else if (arrayClass.isArray()) { // this is not actually allowed in ROS
|
||||
System.out.println(indent + i + ": [");
|
||||
printArray(elementObject, indent + " ");
|
||||
System.out.println(indent + "]");
|
||||
}
|
||||
else {
|
||||
System.out.println(indent + i + ":");
|
||||
printMessage(elementObject, indent + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
// remember to print array indices
|
||||
}
|
||||
|
||||
public static boolean isPrimitive(Class c) {
|
||||
return (c.isPrimitive() ||
|
||||
c.equals(String.class) ||
|
||||
Number.class.isAssignableFrom(c) ||
|
||||
c.equals(Boolean.class));
|
||||
}
|
||||
|
||||
|
||||
// Copied from com.jilk.ros.rosbridge.JSON
|
||||
private static Object getFieldObject(Field f, Object o) {
|
||||
Object fo = null;
|
||||
try {
|
||||
fo = f.get(o);
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return fo;
|
||||
}
|
||||
|
||||
public void copyFrom(Message source) {
|
||||
try {
|
||||
if (source.getClass() != getClass())
|
||||
throw new RuntimeException("Attempt to copy non-matching classes");
|
||||
for (Field f : getClass().getFields()) {
|
||||
Class fc = f.getType();
|
||||
if (fc.isArray())
|
||||
throw new RuntimeException("copyFrom - array types not implemented");
|
||||
else if (!isPrimitive(fc))
|
||||
((Message) f.get(this)).copyFrom((Message) f.get(source));
|
||||
else {
|
||||
Object value = f.get(source);
|
||||
f.set(this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new RuntimeException("copyFrom error", ex);
|
||||
}
|
||||
catch (ClassCastException ex) {
|
||||
throw new RuntimeException("copyFrom error", ex);
|
||||
}
|
||||
// ReflectiveOperationException is not available on Android (Java 1.6)
|
||||
/*
|
||||
catch (ReflectiveOperationException ex) {
|
||||
throw new RuntimeException ("copyFrom error", ex);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
public class MessageException extends Exception {
|
||||
|
||||
public MessageException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MessageException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface MessageType {
|
||||
String string() default "";
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package com.jilk.ros.message;
|
||||
|
||||
/**
|
||||
* Created by xxhong on 16-11-17.
|
||||
*/
|
||||
@MessageType(string = "std_msgs/String")
|
||||
public class SemanticRequest extends Message {
|
||||
public SemanticRequest(String args) {
|
||||
jsonStr = args;
|
||||
}
|
||||
|
||||
public String jsonStr;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.jilk.ros.message;
|
||||
|
||||
/**
|
||||
* Created by xxhong on 16-11-17.
|
||||
*/
|
||||
@MessageType(string = "std_msgs/String")
|
||||
public class SemanticResponse extends Message {
|
||||
public String result;
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.jilk.ros.message;
|
||||
|
||||
/**
|
||||
* Created by xxhong on 16-11-17.
|
||||
*/
|
||||
@MessageType(string = "std_msgs/String")
|
||||
public class StdMsg extends Message {
|
||||
public String data;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "std_msgs/Time")
|
||||
public class Time extends TimePrimitive {
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.message;
|
||||
|
||||
@MessageType(string = "time")
|
||||
public class TimePrimitive extends Message {
|
||||
public int secs; // when requesting this format from ROSbridge, it uses 'sec' (no 's')
|
||||
public int nsecs; // when requesting this format from ROSbridge, it uses 'nsec'
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "std_msgs/Empty")
|
||||
public class Empty extends Message {
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
import com.jilk.ros.message.TimePrimitive;
|
||||
|
||||
|
||||
@MessageType(string = "rosapi/GetTimeResponse")
|
||||
public class GetTime extends Message {
|
||||
public TimePrimitive time;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/MessageDetails")
|
||||
public class MessageDetails extends Message {
|
||||
public TypeDef[] typedefs;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/Nodes")
|
||||
public class Nodes extends Message {
|
||||
public String[] nodes;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/Service")
|
||||
public class Service extends Message {
|
||||
public String service;
|
||||
|
||||
public Service() {}
|
||||
|
||||
public Service(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/Services")
|
||||
public class Services extends Message {
|
||||
public String[] services;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/Topic")
|
||||
public class Topic extends Message {
|
||||
public String topic;
|
||||
|
||||
public Topic() {}
|
||||
|
||||
public Topic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/Topics")
|
||||
public class Topics extends Message {
|
||||
public String[] topics;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/Type")
|
||||
public class Type extends Message {
|
||||
public String type;
|
||||
|
||||
public Type() {}
|
||||
|
||||
public Type(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Jilk Systems, Inc.
|
||||
*
|
||||
* This file is part of the Java ROSBridge Client.
|
||||
*
|
||||
* The Java ROSBridge Client is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Java ROSBridge Client is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with the Java ROSBridge Client. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
*/
|
||||
package com.jilk.ros.rosapi.message;
|
||||
|
||||
import com.jilk.ros.message.Message;
|
||||
import com.jilk.ros.message.MessageType;
|
||||
|
||||
@MessageType(string = "rosapi/TypeDef")
|
||||
public class TypeDef extends Message {
|
||||
public String type;
|
||||
public String[] fieldnames;
|
||||
public String[] fieldtypes;
|
||||
public int[] fieldarraylen;
|
||||
public String[] examples;
|
||||
|
||||
public static boolean match(String type, Class c) {
|
||||
boolean result = false;
|
||||
if (
|
||||
(type.equals("bool") && ((boolean.class.equals(c)) || (Boolean.class.equals(c)))) ||
|
||||
(type.equals("int8") && ((byte.class.equals(c)) || (Byte.class.equals(c)))) ||
|
||||
(type.equals("byte") && ((byte.class.equals(c)) || (Byte.class.equals(c)))) || // deprecated
|
||||
(type.equals("uint8") && ((short.class.equals(c)) || (Short.class.equals(c)))) ||
|
||||
(type.equals("char") && ((short.class.equals(c)) || (Short.class.equals(c)))) || // deprecated
|
||||
(type.equals("int16") && ((short.class.equals(c)) || (Short.class.equals(c)))) ||
|
||||
(type.equals("uint16") && ((int.class.equals(c)) || (Integer.class.equals(c)))) ||
|
||||
(type.equals("int32") && ((int.class.equals(c)) || (Integer.class.equals(c)))) ||
|
||||
(type.equals("uint32") && ((long.class.equals(c)) || (Long.class.equals(c)))) ||
|
||||
(type.equals("int64") && ((long.class.equals(c)) || (Long.class.equals(c)))) ||
|
||||
(type.equals("float32") && ((float.class.equals(c)) || (Float.class.equals(c)))) ||
|
||||
(type.equals("float64") && ((double.class.equals(c)) || (Double.class.equals(c)))) ||
|
||||
(type.equals("uint64") && (java.math.BigInteger.class.equals(c))) ||
|
||||
(type.equals("string") && (String.class.equals(c)))
|
||||
)
|
||||
result = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|