...
- 打开VirtualTrackWithOA工程,检查libs路径下是否有 slamware_sdk_android.jar 文件,以及jinLibs路径下是否有 librpsdk.so 文件,若想尝试其他版本的SDK,请直接将这两个文件替换。
到 Project Structure --> app --> Dependencies 检查Slamware SDK是否添加到工程中。
将以下代码段的"10.0.130.71"修改为底盘的IP地址,默认情况下为192.168.11.1,当WIFI处于Station模式下请将PC与底盘使用Ethenet连接后查看。方法说明:AbstractSlamwarePlatform connect(String host, int port),其中host为底盘IP,port为网络端口号,返回值为底盘的实例对象。
Code Block language java theme Midnight /* 与底盘连接 */ AbstractSlamwarePlatform robotPlatform = DeviceManager.connect("10.0.130.71", 1445);
Android设备连接底盘发射出的WIFI或连入底盘的同一网络,按下shift + F10 运行
Info 本例程仅仅用作最简单SDK类和方法的演示,故没有设计Android界面
- 虚拟轨道和机器人的运动状态可以在Robostudio上查看
View filemultimedia name VirtualTrackWithOA.mp4 height 250
...
代码描述
画一条机器人当前位置x轴方向正向的,长6米的轨道,然后沿轨道走到目标点
Code Block language java theme Midnight title 导航到目标点 linenumbers true /* 与底盘连接 */ final AbstractSlamwarePlatform robotPlatform = DeviceManager.connect("10.0.130.71", 1445); try { //draw a 6 meter virtual track Pose pose = robotPlatform.getPose(); Line line = new Line(new PointF(pose.getX(), pose.getY()), new PointF(pose.getX()+6, pose.getY())); robotPlatform.addLine(ArtifactUsageVirtualTrack, line); IMoveAction action = robotPlatform.getCurrentAction(); if (action != null) action.cancel(); MoveOption moveOption = new MoveOption(); moveOption.setTrackWithOA(true); action = robotPlatform.moveTo(new Location(7, 0, 0), moveOption, 0); action.waitUntilDone(); if (action.getStatus() == ERROR) Log.d(TAG, "Action Failed"); } catch (ConnectionTimeOutException e) { /* Exception Handle code*/ .... }