Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding noether_simulator #51

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

trentwall
Copy link

Adding the noether_simulator package required minor modifications to existing packages.

@@ -0,0 +1,182 @@
#include <ros/ros.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me this looks like a piece of code for testing. At least put in a comment block that describes what it does and how to use it.

return points;
}

int main (int argc, char **argv)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a more compelling demo if it also allowed the user to add a mesh from a file in addition to those meshes you auto-generate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will start working on it.

}

#endif // NOETHER_SIMULATOR_H

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you have both doxygen and good naming conventions!

<name>noether_simulator</name>
<version>0.0.0</version>
<description>The noether_simulator package</description>
<maintainer email="[email protected]">alex</maintainer>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not alex goins

void NoetherSimulator::runSimulation()
{

cout << "starting simulation\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use one of the logging functions instead of cout directly so that output can be turned on and off level by level. (e.g. ROS_ERROR, ROS_INFO, and ROS_DEBUG)

cylinder->SetResolution(20);
cylinder->Update();

//vtkSmartPointer<vtkOBBTree> tree = vtkSmartPointer<vtkOBBTree>::New();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out lines. You can add a real comment, if you want to remind yourself of the other options

vtkSmartPointer<vtkPoints> test_pts = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkPoints> integration_pts = vtkSmartPointer<vtkPoints>::New();

//test_pts->SetNumberOfPoints(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more commented out code


// TODO: the test currently uses a cylinder source, with the y-axis as the major axis
// for correct visualization, need to set the norm vector (u) to the y-axis
Eigen::Affine3d epose = Eigen::Affine3d::Identity();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why, but I believe Affine3d is depricated for Isometry3d. I don't know the difference.
I also forgot that you copied this code from an old version created by alex goins.


//add tool
tool_path_planner::ProcessTool tool;
tool.pt_spacing = 0.5;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get all these parameters from the ros parameter server, but use these values as default if not set on ros-p-server

@@ -196,10 +196,13 @@ noether_msgs::ToolPathConfig toTppMsg(const tool_path_planner::ProcessTool& tool
tpp_config_msg.line_spacing = tool_config.line_spacing;
tpp_config_msg.tool_offset = tool_config.tool_offset;
tpp_config_msg.intersecting_plane_height = tool_config.intersecting_plane_height;
tpp_config_msg.nearest_neighbors = tool_config.nearest_neighbors;//Trent added
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Trent added not necessary since we use git to record all commits

vtkSmartPointer<vtkPolyData> cut = vtkSmartPointer<vtkPolyData>::New();
cut = vtk_viewer::cutMesh(data, points2, false);

cout << "cutter points: " << cut->GetPoints()->GetNumberOfPoints() << "\n";
cout << "cutter lines: " << cut->GetNumberOfLines() << "\n";



vtk_viewer::VTKViewer viz;
std::vector<float> color(3);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trentwall please make suggested changes, and ping me for a final review before merge

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have finished all the changes that you and mat requested.

Copy link
Contributor

@mpowelson mpowelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw Chris looked at this, so I did not look too much at how it actually works. I also did not test it. I did note some things about the structure of the package.

#define NOETHER_SIMULATOR_H

/*
* Copyright (c) 2016, Southwest Research Institute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Apache 2 license like in #45. Here's an example.

/**
 * Copyright (c) 2016, Southwest Research Institute	 * @file mesh_segmenter.h
 * All rights reserved.	 * @copyright Copyright (c) 2019, Southwest Research Institute
 *	 *
 * @par License
 * Software License Agreement (Apache License)
 * @par
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * @par
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */	 */

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trentwall Add the license to all your headers

color[2] = 0.2;
viz.addPolyNormalsDisplay(paths[i].derivatives, color, scale);
}
viz.renderDisplay();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be in a #ifndef NDEBUG. If not, CI will hang and fail. See the unit tests in segmentation or one of the other packages

@@ -6,6 +6,7 @@

#include <limits>
#include <cmath>
#include <stdio.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<package>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of noether is package.xml format 2. We should convert this to 2 as well.

<version>0.0.0</version>
<description>The noether_simulator package</description>
<maintainer email="[email protected]">alex</maintainer>
<license>Proprietary</license>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apache 2!

genmsg
actionlib
actionlib_msgs
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know some of this can be removed, I suspect a lot of it. Just taking a guess, after removing the ROS node these can probably be removed.

    message_generation
    mesh_segmenter
    path_sequence_planner
    sensor_msgs
    geometry_msgs
    roscpp
    pcl_msgs
    std_srvs
    pcl_conversions
    dynamic_reconfigure
    genmsg
    actionlib
    actionlib_msgs

I see that you need some of them for the tests. In that case you can add them below.

${PCL_LIBRARIES}
)

#Test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add test depends here similar to


#############
## Testing ##
#############
if(CATKIN_ENABLE_TESTING)
  find_package(catkin REQUIRED COMPONENTS vtk_viewer)
  include_directories(
    include
    ${catkin_INCLUDE_DIRS}
  )
  catkin_add_gtest(${PROJECT_NAME}-test
    test/utest.cpp
  )
  target_link_libraries(${PROJECT_NAME}-test
    ${PROJECT_NAME}
    ${catkin_LIBRARIES}
  )
endif()

There's also a TEST_DEPEND flag in the package.xml you can use.

noether_simulator/cfg/NoetherSimulator.cfg Show resolved Hide resolved
actionlib_msgs
)

generate_messages(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this.

<name>noether_simulator</name>
<version>0.0.0</version>
<description>The noether_simulator package</description>
<maintainer email="[email protected]">alex</maintainer>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be format 2 package.xml to match everything else.

Maintainer should probably be Jorge

License is definitely Apache 2!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed all the requested changes.

* If the mesh is sufficently painted the bool corasponding to that mesh in the painted[]
* is set to true, the mesh is excluded from future iterations, and the path is added to the reuqiredPaths[] unless,
* it has already been added.
* once all the meshes have been evaluated using the first path, the simulator moves on to the second path.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once should be Once

* The simulator evaluates the remaining meshes with the second path and so on until all meshes have the coraspoinding
* bool value in painted[] set to true, or all paths have been tried.
*
* To use roslauch to launch the thick_sim.launch file. Then, in a seperate termial window use rosrun to run the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about
usage:
roslaunch noether_examples thick_sim.launch & rosrun noether_simuator noether_simulator

Give the user something they can cut and paste and try. Test it to make sure it works

*
*/

//make modified meshes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use doxygen style comments (e.g. @brief This is a helper function to create test meshes

@@ -0,0 +1,10 @@
#goal definition - Input Mesh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be thought of as simulating the work function. One might use Noether for sanding, grinding, power washing, applying paint, chemicals, laser paint removal, sand blasting etc. A similar simulation applies to all. The results should be work_complete rather than painted. Or perhaps coverage would be a better term.

*/
void setTool(tool_path_planner::ProcessTool tool){tool_ = tool;}

void runSimulation();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add doxygen to every public function


double NoetherSimulator::integral(double pt[3])
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the integral x^3/3 + z^3/3? Put some comments in here to help us understand what's going on

vtkSmartPointer<vtkMatrix4x4> NoetherSimulator::createMatrix(double pt[3], double norm[3], double derv[3])
{
// Get the point normal and derivative for creating the 3x3 transform
//double* norm = paths[j].line->GetPointData()->GetNormals()->GetTuple(k);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more commented out code. Remove it.

derivatives_->GetPointData()->SetNormals(deriv_normals);
path.derivatives = derivatives_;

vtkSmartPointer<vtkPolyData> inter_ = vtkSmartPointer<vtkPolyData>::New();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just adding empty pointers as place holders?

nh_.param("/noether_simulator/pt_spacing",tool.pt_spacing, 0.5);
nh_.param("/nnoether_simulator/line_spacing",tool.line_spacing,0.75);
nh_.param("/noether_simulator/tool_offset",tool.tool_offset, 0.0);
nh_.param("/noether_simulator/intersecting_plane_hiehgt",tool.intersecting_plane_height,0.15);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spelling

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drchrislewis I have made the requested changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hiehgt is not a correct spelling

Copy link
Member

@drchrislewis drchrislewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trentwall Just a few more comments to address. Ping when done

@@ -3,7 +3,7 @@ pcl_msgs/PolygonMesh[] input_mesh
noether_msgs/ToolRasterPath[] path
---
#result definition - are messhes painted enough
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change name of action to simulateCoverage.action

@@ -50,15 +50,17 @@ namespace noether_simulator
simulation_points_ = vtkSmartPointer<vtkPolyData>::New();
}

//Integrate in x^2 and z^2
Copy link
Member

@drchrislewis drchrislewis Aug 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too terse to remember what's going on.
This is a definite integral of the function (x^2 + z^2)/10 from one point pt1 to another point pt2.
The factor of one 10th stems from the subsampling of the surface at a 10x density.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants