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

Disney gui #27

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.swo
*.swp
*.pyc
*.*~
.idea/
thirdparty/
3 changes: 3 additions & 0 deletions ecto_rbo_pcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ ectomodule(ecto_rbo_pcl INSTALL
src/ecto_rbo_pcl/WrapInVector.cpp
src/ecto_rbo_pcl/CreateTF.cpp
src/ecto_rbo_pcl/PCDReader.cpp
src/ecto_rbo_pcl/BroadcastIfcoSpecifications.cpp
src/ecto_rbo_pcl/MultiObjectDetection.cpp
src/ecto_rbo_pcl/FilterObjects.cpp
)

link_ecto(ecto_rbo_pcl
Expand Down
99 changes: 99 additions & 0 deletions ecto_rbo_pcl/src/ecto_rbo_pcl/BroadcastIfcoSpecifications.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Copyright 2016-2017 Robotics and Biology Lab, TU Berlin. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project.
*/

#include <ecto_rbo_pcl/common.h>

#include <ros/ros.h>
#include <ros/console.h>

#include <tf_conversions/tf_eigen.h>
#include <eigen_conversions/eigen_msg.h>

#include <pcl/common/eigen.h>
#include <pcl/ModelCoefficients.h>


using namespace ecto;

namespace ecto_rbo_pcl
{

typedef Eigen::Transform<float,3,Eigen::Affine,Eigen::DontAlign> UnalignedAffine3f;

struct BroadcastIfcoSpecifications
{

ros::NodeHandle nh_;

// params
spore<double> ifco_length_;
spore<double> ifco_width_;
spore<double> ifco_height_;
spore< std::vector<double> > ec_wall_offset_;

// outputs
spore<double> ifco_length__;
spore<double> ifco_width__;
spore<double> ifco_height__;
spore< std::vector<double> > ec_wall_offset__;

static void declare_params(tendrils& params)
{

std::vector<double> ec_wall_offset_default;
ec_wall_offset_default.push_back(0.0);

params.declare<double>("ifco_length", "Size of the long IFCO edge", 0.0);
params.declare<double>("ifco_width", "Size of the short IFCO edge", 0.0);
params.declare<double>("ifco_height", "Depth of the ifco", 0.0);
params.declare< std::vector<double> >("ec_wall_offset", "The space that is occupied by the ec.", ec_wall_offset_default);
}

static void declare_io(const tendrils& params, tendrils& inputs, tendrils& outputs)
{
outputs.declare<double>("ifco_length", "Size of the long IFCO edge", 0.0);
outputs.declare<double>("ifco_width", "Size of the short IFCO edge", 0.0);
outputs.declare<double>("ifco_height", "Depth of the ifco", 0.0);
outputs.declare<std::vector<double> >("ec_wall_offset", "The space that is occupied by the ec.");
}

void configure(const tendrils& params, const tendrils& inputs, const tendrils& outputs)
{
// params
ifco_length_ = params["ifco_length"];
ifco_width_ = params["ifco_width"];
ifco_height_ = params["ifco_height"];
ec_wall_offset_ = params["ec_wall_offset"];

// outputs
ifco_length__ = outputs["ifco_length"];
ifco_width__ = outputs["ifco_width"];
ifco_height__ = outputs["ifco_height"];
ec_wall_offset__ = outputs["ec_wall_offset"];
}

int process(const tendrils& inputs, const tendrils& outputs)
{
(*ifco_length__) = *ifco_length_;
(*ifco_width__) = *ifco_width_;
(*ifco_height__) = *ifco_height_;

(*ec_wall_offset__) = *ec_wall_offset_;

return ecto::OK;
}
};

}

ECTO_CELL(ecto_rbo_pcl, ecto_rbo_pcl::BroadcastIfcoSpecifications, "BroadcastIfcoSpecifications", "Broadcast ifco specifics.");
161 changes: 161 additions & 0 deletions ecto_rbo_pcl/src/ecto_rbo_pcl/FilterObjects.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
Copyright 2016-2017 Robotics and Biology Lab, TU Berlin. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project.
*/
#include <ecto_rbo_pcl/common.h>

#include <ros/ros.h>
#include <ros/console.h>

#include <tf_conversions/tf_eigen.h>
#include <eigen_conversions/eigen_msg.h>

#include <pcl/common/eigen.h>
#include <pcl/ModelCoefficients.h>

#include "object_segmentation/object_pose.h"

#include "tf/transform_broadcaster.h"
#include "tf/transform_listener.h"
#include <tf_conversions/tf_eigen.h>
#include <tf/transform_datatypes.h>
#include <geometry_msgs/PoseArray.h>
#include <std_msgs/Float32MultiArray.h>
#include <boost/thread/mutex.hpp>
#include <visualization_msgs/MarkerArray.h>
#include "ifco_pose_estimator/ifco_pose.h"


using namespace ecto;
using namespace ecto::pcl;

namespace ecto_rbo_pcl
{

typedef Eigen::Matrix<float, 3, 1, Eigen::DontAlign> UnalignedVector3f;
typedef Eigen::Transform<float,3,Eigen::Affine,Eigen::DontAlign> UnalignedAffine3f;
typedef Eigen::Matrix<float, 4, 1, Eigen::DontAlign> UnalignedVector4f;


// ======================================================================================================================
// ======================================================================================================================
struct FilterObjects
{
ros::NodeHandle nh_;

// inputs
spore<std::vector<UnalignedAffine3f> > object_poses_;
spore<std::vector<UnalignedVector3f> > object_sizes_;
spore<std::vector<UnalignedVector4f> > centroids_;

// parameters
spore<bool> filter_method_;

// outputs
spore<std::vector<UnalignedAffine3f> > object_poses__;
spore<std::vector<UnalignedVector3f> > object_sizes__;
spore<std::vector<UnalignedVector4f> > centroids__;


// ======================================================================================================================
static void declare_params(tendrils& params)
{

params.declare<bool>("filter_method", "0: first object, 1: biggest object,...", 0);

}

// ======================================================================================================================
static void declare_io(const tendrils& params, tendrils& inputs, tendrils& outputs)
{
inputs.declare<std::vector<UnalignedAffine3f> >("transforms", "A vector of 4x4 affine transformations for the objects.");
inputs.declare<std::vector<UnalignedVector3f> >("sizes", "A vector of 3d sizes for the bounding boxes.");
inputs.declare<std::vector<UnalignedVector4f> >("centroids", "A vector of object centroids");

outputs.declare<std::vector<UnalignedAffine3f> >("transforms", "A vector of 4x4 affine transformations for the objects.");
outputs.declare<std::vector<UnalignedVector3f> >("sizes", "A vector of 3d sizes for the bounding boxes.");
outputs.declare<std::vector<UnalignedVector4f> >("centroids", "A vector of object centroids");
}

// ======================================================================================================================
void configure(const tendrils& params, const tendrils& inputs, const tendrils& outputs)
{
// inputs
object_poses_ = inputs["transforms"];
object_sizes_ = inputs["sizes"];
centroids_ = inputs["centroids"];

//prams
filter_method_ = params["filter_method"];

// outputs
object_poses__ = outputs["transforms"];
object_sizes__ = outputs["sizes"];
centroids__ = outputs["centroids"];
}





// ==========================================================================================
int process(const tendrils& inputs, const tendrils& outputs)
{

// here can be implemented any filter method that returns just one of the objects from the input tendrils

object_poses__->clear();
object_sizes__->clear();
centroids__->clear();

switch (*filter_method_)
{
case 0: // keep only 1 object -> first in list
{
object_poses__->push_back(object_poses_->front());
object_sizes__->push_back(object_sizes_->front());
centroids__->push_back(centroids_->front());
break;
}
case 1: // keep only 1 object -> biggest volume
{
// compute object sizes
std::vector<float> volumes;
for(std::vector<UnalignedVector3f>::iterator it = object_sizes_->begin(); it != object_sizes_->end(); ++it)
{
float size_x = (*it)(0);
float size_y = (*it)(1);
float size_z = (*it)(2);

float obj_volume = size_x * size_y * size_z;
volumes.push_back(obj_volume);
}

std::vector<float>::iterator result = std::max_element(volumes.begin(), volumes.end());

object_poses__->push_back(object_poses_->at(std::distance(volumes.begin(), result)));
object_sizes__->push_back(object_sizes_->at(std::distance(volumes.begin(), result)));
centroids__->push_back(centroids_->at(std::distance(volumes.begin(), result)));
break;
}
}




return ecto::OK;
}

};

}

ECTO_CELL(ecto_rbo_pcl, ecto_rbo_pcl::FilterObjects, "FilterObjects", "Returns the first object in a list of objects");
Loading