Added proper javadoc comments to the View code.
This commit is contained in:
8
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
8
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ADDITIONAL_TAGS" value="brief" />
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
@@ -50,7 +50,7 @@ public class Car{
|
|||||||
//With all the views that the car has, get their point list
|
//With all the views that the car has, get their point list
|
||||||
void updateScan(PointGraph map){
|
void updateScan(PointGraph map){
|
||||||
for(View view : views){
|
for(View view : views){
|
||||||
view.look(map);
|
view.calculatePointScan(map);
|
||||||
slam.RANSAC(view);
|
slam.RANSAC(view);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,16 +5,22 @@ import java.util.ArrayList;
|
|||||||
import ScanGraph.ScanPoint;
|
import ScanGraph.ScanPoint;
|
||||||
|
|
||||||
public class View {
|
public class View {
|
||||||
Vector pose;
|
Vector position;
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
float FOV;
|
float FOV;
|
||||||
ArrayList<Ray> rays = new ArrayList<>();
|
ArrayList<Ray> rays = new ArrayList<>();
|
||||||
private static PApplet proc;
|
private static PApplet proc;
|
||||||
|
|
||||||
//the x,y position of the view, what angle it's looking at and its FOV
|
/**
|
||||||
|
* @brief Constructor for the View class
|
||||||
|
* @param processing The PApplet that the view will be drawn on
|
||||||
|
* @param newPose The position of the view
|
||||||
|
* @param numberOfRays The number of rays that the view will have
|
||||||
|
* @param FOV The field of view of the view
|
||||||
|
*/
|
||||||
View(PApplet processing, Vector newPose, int numberOfRays, float FOV) {
|
View(PApplet processing, Vector newPose, int numberOfRays, float FOV) {
|
||||||
proc = processing;
|
proc = processing;
|
||||||
this.pose = newPose;
|
this.position = newPose;
|
||||||
this.FOV = FOV;
|
this.FOV = FOV;
|
||||||
this.setRayNum(numberOfRays, FOV, this.angle);
|
this.setRayNum(numberOfRays, FOV, this.angle);
|
||||||
}
|
}
|
||||||
@@ -25,34 +31,42 @@ public class View {
|
|||||||
rays.clear();
|
rays.clear();
|
||||||
float angle = (float) (angleOffset); //the 0.01 fixes some bugs
|
float angle = (float) (angleOffset); //the 0.01 fixes some bugs
|
||||||
for (int i = 0; i < numberOfRays; i++) {
|
for (int i = 0; i < numberOfRays; i++) {
|
||||||
Ray ray = new Ray(pose, angle);
|
Ray ray = new Ray(position, angle);
|
||||||
angle = angle + rayStep;
|
angle = angle + rayStep;
|
||||||
rays.add(ray);
|
rays.add(ray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//sees if the ray will collide with the walls in the wall list
|
/**
|
||||||
public void look(PointGraph map) {
|
* @brief Calculates the points of intersection of the rays with the map
|
||||||
|
* @param map The map that the view is looking at
|
||||||
|
*/
|
||||||
|
public void calculatePointScan(PointGraph map) {
|
||||||
for (Ray ray : rays) {
|
for (Ray ray : rays) {
|
||||||
ray.castRay(map);
|
ray.castRay(map);
|
||||||
if(ray.hasCollided()){
|
if(ray.hasCollided()){
|
||||||
ray.getPoint().draw(proc);
|
ray.getPoint().draw(proc);
|
||||||
// ray.drawRay(proc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//changes the position of the view
|
/**
|
||||||
public void setPos(Vector newPose) {
|
* @brief Sets the position of the view
|
||||||
pose = newPose;
|
* @param newPosition The new position of the view
|
||||||
|
*/
|
||||||
|
public void setPos(Vector newPosition) {
|
||||||
|
position = newPosition;
|
||||||
for (Ray ray : rays) {
|
for (Ray ray : rays) {
|
||||||
ray.setPos(pose);
|
ray.setPos(position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//changes the angle of the view
|
/**
|
||||||
public void setAngle(float angle) {
|
* @brief Sets the angle of the view
|
||||||
this.angle = angle;
|
* @param newAngle The new angle of the view
|
||||||
|
*/
|
||||||
|
public void setAngle(float newAngle) {
|
||||||
|
this.angle = newAngle;
|
||||||
for(Ray ray : rays){
|
for(Ray ray : rays){
|
||||||
float angleOffset = ray.getAngle() - this.angle;
|
float angleOffset = ray.getAngle() - this.angle;
|
||||||
ray.setAngle(this.angle+angleOffset);
|
ray.setAngle(this.angle+angleOffset);
|
||||||
@@ -65,23 +79,38 @@ public class View {
|
|||||||
this.setRayNum(this.rays.size(), this.FOV, this.angle);
|
this.setRayNum(this.rays.size(), this.FOV, this.angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The position of the view
|
||||||
|
*/
|
||||||
public Vector getPos() {
|
public Vector getPos() {
|
||||||
return pose;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The angle of the view
|
||||||
|
*/
|
||||||
public float getAngle() {
|
public float getAngle() {
|
||||||
return this.angle;
|
return this.angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The field of view of the view
|
||||||
|
*/
|
||||||
public float getFOV() {
|
public float getFOV() {
|
||||||
return this.FOV;
|
return this.FOV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The number of rays that the view has
|
||||||
|
*/
|
||||||
public int getRayNum() {
|
public int getRayNum() {
|
||||||
return this.rays.size();
|
return this.rays.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//gets the point that each ray has collided with
|
/**
|
||||||
|
* @brief Get the most recent scan from the view
|
||||||
|
* @return A ScanPoint object containing the position, angle and points of the view
|
||||||
|
*/
|
||||||
public ScanPoint getScan() {
|
public ScanPoint getScan() {
|
||||||
ArrayList<Vector> points = new ArrayList<>();
|
ArrayList<Vector> points = new ArrayList<>();
|
||||||
|
|
||||||
@@ -93,7 +122,7 @@ public class View {
|
|||||||
points.add(point);
|
points.add(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ScanPoint(this.pose,this.angle, points);
|
return new ScanPoint(this.position,this.angle, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user