Prechádzať zdrojové kódy

add:通过rosbridge获取机器人状态位置信息并开放http接口

miloma93@163.com 4 mesiacov pred
rodič
commit
ba312980fe

+ 12 - 0
src/main/java/com/sw/patroleditor/controller/PTZController.java

@@ -1,11 +1,13 @@
 package com.sw.patroleditor.controller;
 
 import com.sw.patroleditor.common.ResultData;
+import com.sw.patroleditor.component.rosBridge.RobotDataCallBack;
 import com.sw.patroleditor.domain.model.PTZData;
 import com.sw.patroleditor.domain.model.Position3D;
 import com.sw.patroleditor.service.PTZCtrlService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -18,6 +20,8 @@ public class PTZController {
 
     @Resource
     private PTZCtrlService ptzCtrlService;
+    @Resource
+    private RobotDataCallBack robotDataCallBack;
 
     @ApiOperation(value = "云台转动/递进")
     @PutMapping("/ptz/move")
@@ -31,4 +35,12 @@ public class PTZController {
     public ResultData position3D(@RequestBody Position3D position3D) {
         return ptzCtrlService.position3DCtrl(position3D);
     }
+
+    @ApiOperation(value = "机器人信息")
+    @GetMapping("/robot/data")
+    public ResultData getRobotData() {
+        // 获取机器人数据
+        return ResultData.success(robotDataCallBack.getRobotDataModel());
+    }
+
 }

+ 18 - 18
src/main/resources/application-dev.properties

@@ -1,42 +1,42 @@
-### Mysql数据库配置信息(用户数据持久化存储)
+### Mysql\u6570\u636E\u5E93\u914D\u7F6E\u4FE1\u606F\uFF08\u7528\u6237\u6570\u636E\u6301\u4E45\u5316\u5B58\u50A8\uFF09
 spring.datasource.drive-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.url=jdbc:mysql://192.168.1.144:3306/bird_db_v1?serverTimezone=GMT%2B8&characterSetResults=UTF-8&characterEncoding=UTF-8&useUnicode=yes&useSSL=false
-#数据库账号
+#\u6570\u636E\u5E93\u8D26\u53F7
 spring.datasource.username=root
-#数据库访问密码
+#\u6570\u636E\u5E93\u8BBF\u95EE\u5BC6\u7801
 spring.datasource.password=pass123
 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
-
-#############连接池的配置信息
-# 初始化大小,最小,最大
+#############\u8FDE\u63A5\u6C60\u7684\u914D\u7F6E\u4FE1\u606F
+# \u521D\u59CB\u5316\u5927\u5C0F\uFF0C\u6700\u5C0F\uFF0C\u6700\u5927
 spring.datasource.initialSize=5
 spring.datasource.minIdle=5
 spring.datasource.maxActive=20
-# 配置获取连接等待超时的时间
+# \u914D\u7F6E\u83B7\u53D6\u8FDE\u63A5\u7B49\u5F85\u8D85\u65F6\u7684\u65F6\u95F4
 spring.datasource.maxWait=60000
-# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+# \u914D\u7F6E\u95F4\u9694\u591A\u4E45\u624D\u8FDB\u884C\u4E00\u6B21\u68C0\u6D4B\uFF0C\u68C0\u6D4B\u9700\u8981\u5173\u95ED\u7684\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
 spring.datasource.timeBetweenEvictionRunsMillis=60000
-# 配置一个连接在池中最小生存的时间,单位是毫秒
+# \u914D\u7F6E\u4E00\u4E2A\u8FDE\u63A5\u5728\u6C60\u4E2D\u6700\u5C0F\u751F\u5B58\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D\u662F\u6BEB\u79D2
 spring.datasource.minEvictableIdleTimeMillis=300000
-# 配置自动检测一些连接是否有效
+# \u914D\u7F6E\u81EA\u52A8\u68C0\u6D4B\u4E00\u4E9B\u8FDE\u63A5\u662F\u5426\u6709\u6548
 spring.datasource.validationQuery=SELECT 1 FROM DUAL
 spring.datasource.testWhileIdle=true
 spring.datasource.testOnBorrow=false
 spring.datasource.testOnReturn=false
-# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙(不推荐加上)
+# \u914D\u7F6E\u76D1\u63A7\u7EDF\u8BA1\u62E6\u622A\u7684filters\uFF0C\u53BB\u6389\u540E\u76D1\u63A7\u754C\u9762sql\u65E0\u6CD5\u7EDF\u8BA1\uFF0C'wall'\u7528\u4E8E\u9632\u706B\u5899\uFF08\u4E0D\u63A8\u8350\u52A0\u4E0A\uFF09
 spring.datasource.filters=stat,log4j
-# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+# \u901A\u8FC7connectProperties\u5C5E\u6027\u6765\u6253\u5F00mergeSql\u529F\u80FD\uFF1B\u6162SQL\u8BB0\u5F55
 #spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
-# 合并多个DruidDataSource的监控数据
+# \u5408\u5E76\u591A\u4E2ADruidDataSource\u7684\u76D1\u63A7\u6570\u636E
 spring.datasource.useGlobalDataSourceStat=true
-
-############# 配置参数
+############# \u914D\u7F6E\u53C2\u6570
 robot.id=0
 robot.ip=192.168.1.75
 robot.port=9091
-
-
-
+############# RosBridge\u63A5\u53E3\u4FE1\u606F
+##\u673A\u5668\u4EBA\u4FE1\u606F
+ros.ip=192.168.1.75
+ros.topic.robot.data.name=interface_robot_data
+ros.topic.robot.data.type=user_msgs/robot_data