import com.vividsolutions.jts.geom.Geometry; //導入方法依賴的package包/類

/**

* Get the path index beyond which a robot should not navigate, given the {@link TrajectoryEnvelope} of another robot.

* @param te1 The {@link TrajectoryEnvelope} of the leading robot.

* @param te2 The {@link TrajectoryEnvelope} of the yielding robot.

* @param currentPIR1 The current path index of the leading robot.

* @param te1Start The path index

* @param te1End

* @param te2Start

* @return

*/

public int getCriticalPoint(int yieldingRobotID, CriticalSection cs, int leadingRobotCurrentPathIndex) {

//Number of additional path points robot 2 should stay behind robot 1

int TRAILING_PATH_POINTS = 3;

int leadingRobotStart = -1;

int yieldingRobotStart = -1;

int leadingRobotEnd = -1;

int yieldingRobotEnd = -1;

if (cs.getTe1().getRobotID() == yieldingRobotID) {

leadingRobotStart = cs.getTe2Start();

yieldingRobotStart = cs.getTe1Start();

leadingRobotEnd = cs.getTe2End();

yieldingRobotEnd = cs.getTe1End();

}

else {

leadingRobotStart = cs.getTe1Start();

yieldingRobotStart = cs.getTe2Start();

leadingRobotEnd = cs.getTe1End();

yieldingRobotEnd = cs.getTe2End();

}

TrajectoryEnvelope leadingRobotTE = null;

TrajectoryEnvelope yieldingRobotTE = null;

if (cs.getTe1().getRobotID() == yieldingRobotID) {

leadingRobotTE = cs.getTe2();

yieldingRobotTE = cs.getTe1();

}

else {

leadingRobotTE = cs.getTe1();

yieldingRobotTE = cs.getTe2();

}

if (leadingRobotCurrentPathIndex <= leadingRobotStart) {

return Math.max(0, yieldingRobotStart-TRAILING_PATH_POINTS);

}

//Compute sweep of robot 1's footprint from current position to LOOKAHEAD

Pose leadingRobotPose = leadingRobotTE.getTrajectory().getPose()[leadingRobotCurrentPathIndex];

Geometry leadingRobotInPose = TrajectoryEnvelope.getFootprint(leadingRobotTE.getFootprint(), leadingRobotPose.getX(), leadingRobotPose.getY(), leadingRobotPose.getTheta());

for (int i = leadingRobotCurrentPathIndex+1; i <= leadingRobotEnd; i++) {

Pose leadingRobotNextPose = leadingRobotTE.getTrajectory().getPose()[i];

leadingRobotInPose = leadingRobotInPose.union(TrajectoryEnvelope.getFootprint(leadingRobotTE.getFootprint(), leadingRobotNextPose.getX(), leadingRobotNextPose.getY(), leadingRobotNextPose.getTheta()));

}

//Return pose at which yielding robot should stop given driving robot's projected sweep

for (int i = yieldingRobotStart; i < yieldingRobotEnd; i++) {

Pose yieldingRobotPose = yieldingRobotTE.getTrajectory().getPose()[i];

Geometry yieldingRobotInPose = TrajectoryEnvelope.getFootprint(yieldingRobotTE.getFootprint(), yieldingRobotPose.getX(), yieldingRobotPose.getY(), yieldingRobotPose.getTheta());

if (leadingRobotInPose.intersects(yieldingRobotInPose)) {

return Math.max(0, i-TRAILING_PATH_POINTS);

}

}

//The only situation where the above has not returned is when robot 2 should

//stay "parked", therefore wait at index 0

return Math.max(0, yieldingRobotStart-TRAILING_PATH_POINTS);

}

java union方法参数_Java Geometry.union方法代碼示例相关推荐

  1. java中的terminated_Java State.TERMINATED屬性代碼示例

    本文整理匯總了Java中java.lang.Thread.State.TERMINATED屬性的典型用法代碼示例.如果您正苦於以下問題:Java State.TERMINATED屬性的具體用法?Jav ...

  2. Java如何封装参数_java规范(一)------方法设计---返回多参数的方法怎么封装

    假如我们有2个变量count和content需要经过一个方法里改变它的值我们可以用下面的方法: main{ int count=0; String content=""; chan ...

  3. java intfunction_Java IntFunction類代碼示例

    本文整理匯總了Java中java.util.function.IntFunction類的典型用法代碼示例.如果您正苦於以下問題:Java IntFunction類的具體用法?Java IntFunct ...

  4. java中reject方法作用_Java BindingResult.rejectValue方法代碼示例

    本文整理匯總了Java中org.springframework.validation.BindingResult.rejectValue方法的典型用法代碼示例.如果您正苦於以下問題:Java Bind ...

  5. java touch创建文件_Java FileUtils.touch方法代碼示例

    本文整理匯總了Java中org.apache.commons.io.FileUtils.touch方法的典型用法代碼示例.如果您正苦於以下問題:Java FileUtils.touch方法的具體用法? ...

  6. java使用drawtext重叠_Java Graphics.drawText方法代碼示例

    本文整理匯總了Java中org.eclipse.draw2d.Graphics.drawText方法的典型用法代碼示例.如果您正苦於以下問題:Java Graphics.drawText方法的具體用法 ...

  7. java getitem方法_Java Datasource.getItem方法代碼示例

    本文整理匯總了Java中com.haulmont.cuba.gui.data.Datasource.getItem方法的典型用法代碼示例.如果您正苦於以下問題:Java Datasource.getI ...

  8. java fileitem 识别图片大小_Java FileItem.getSize方法代碼示例

    本文整理匯總了Java中org.apache.commons.fileupload.FileItem.getSize方法的典型用法代碼示例.如果您正苦於以下問題:Java FileItem.getSi ...

  9. java nio keyiterator.remove()_Java SelectionKey.isValid方法代碼示例

    本文整理匯總了Java中java.nio.channels.SelectionKey.isValid方法的典型用法代碼示例.如果您正苦於以下問題:Java SelectionKey.isValid方法 ...

最新文章

  1. 消费者关注的 Win8 问题汇总(下)
  2. 运维中心建设--数据管理
  3. 论文笔记 《Maxout Networks》 《Network In Network》
  4. Java 8系列之Stream的强大工具Collector
  5. getaway网关转发去前缀_为什么微服务一定要有网关?
  6. HTML5获取autofocus 属性:输入文字点定位到该位置
  7. 2020 q5l使用手册电子版_关于2020下半年自考本科毕业生论文预答辩题目查询的通知...
  8. AspNetCore中使用Ocelot之 IdentityServer4(1)
  9. GIS应用技巧之定义图框样式
  10. ckplayer php,ckplayer播放器
  11. 如何在服务器替换apk文件,如何修改apk文件的服务器地址
  12. Scan Context回环检测解读和使用
  13. 11度青春之《老男孩》
  14. c语言编程一个数的质子求出来,量子力学第一章课外练习题
  15. linux 安装Docker
  16. 2014暑假ACM13级一批集训内容
  17. python爬虫微信e校园签到,用Python爬虫的request方式实现自动签到!
  18. android获取手机流量使用情况
  19. [转]浅谈缓冲区溢出之栈溢出
  20. 会声会影2022VideoStudio中文旗舰版

热门文章

  1. ubuntu下文件名乱码的解决办法
  2. Python与C之间的相互调用
  3. [云炬商业计划书阅读分享] 养生保健
  4. 吐血整理!10 个机器学习教程汇总,爱可可推荐!
  5. zepto的ajax使用,Ajax的实现及使用-zepto
  6. 32 六角oled驱动_Alienware下半年开售55英寸OLED显示器,4K120Hz、95%DCI-P3
  7. 3DSlicer5:开发者必晓ABC
  8. 独立成分分析 ( ICA ) 与主成分分析 ( PCA ) 的区别
  9. opengl从入门到精通
  10. SYSCALL_DEFINE含义