Skip to content

Commit

Permalink
Spam v2.0 - new software design to separate hypothesis-based planning…
Browse files Browse the repository at this point in the history
… from the core libs. App libs are alike Grasp lib.
  • Loading branch information
memnone committed Nov 20, 2015
1 parent 8598cdc commit 80b200f
Show file tree
Hide file tree
Showing 64 changed files with 3,081 additions and 8,076 deletions.
545 changes: 416 additions & 129 deletions CMakeLists.txt

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
Spam
====

Spam
# Spam-2.0
Simultaneous Perception and Manipulation version 2.0
91 changes: 91 additions & 0 deletions include/Spam/App/PosePlanner/Data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//------------------------------------------------------------------------------
// Simultaneous Perception And Manipulation (SPAM)
//------------------------------------------------------------------------------
//
// Copyright (c) 2010 University of Birmingham.
// All rights reserved.
//
// Intelligence Robot Lab.
// School of Computer Science
// University of Birmingham
// Edgbaston, Brimingham. UK.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// with the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimers.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimers in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the names of the Simultaneous Perception And Manipulation
// (SPAM), University of Birmingham, nor the names of its contributors
// may be used to endorse or promote products derived from this Software
// without specific prior written permission.
//
// The software is provided "as is", without warranty of any kind, express or
// implied, including but not limited to the warranties of merchantability,
// fitness for a particular purpose and noninfringement. In no event shall the
// contributors or copyright holders be liable for any claim, damages or other
// liability, whether in an action of contract, tort or otherwise, arising
// from, out of or in connection with the software or the use of other dealings
// with the software.
//
//------------------------------------------------------------------------------
//! @Author: Claudio Zito
//! @Date: 25/03/2014
//------------------------------------------------------------------------------
#pragma once
#ifndef _SPAM_POSEPLANNER_DATA_H_
#define _SPAM_POSEPLANNER_DATA_H_

//------------------------------------------------------------------------------

#include <Spam/HBPlan/Belief.h>
#include <Spam/HBPlan/Heuristic.h>
#include <Spam/HBPlan/GraphPlanner.h>

//------------------------------------------------------------------------------

namespace grasp {
namespace data {

//------------------------------------------------------------------------------

/** Initialises handler.
* (Optionally) Implemented by Handler.
*/
class HandlerBelief {
public:
/** Sets planner and controllers. */
virtual void set() = 0;
};

/** Trajectory collection and tools.
* (Optionally) Implemented by Item.
*/
class Belief {
public:
/** Returns command trajectory with velocity profile. */
virtual void createBelief() = 0;
};

//------------------------------------------------------------------------------

}; // namespace
}; // namespace

//namespace golem {
//
//template <> void Stream::read(spam::Data &data) const;
//template <> void Stream::write(const spam::Data &data);
//
//}; // namespace


#endif /*_GRASP_POSEPLANNER_POSEPLANNER_H_*/
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,10 @@
//------------------------------------------------------------------------------

#include <Grasp/App/Player/Player.h>

#include <Grasp/Core/Ctrl.h>
#include <Grasp/Contact/Model.h>
#include <Grasp/Contact/Query.h>
#include <Grasp/Contact/Manipulator.h>

#include <Spam/Spam/GraphPlanner.h>
#include <Spam/Spam/Heuristic.h>
//#include <Golem/Phys/Application.h>
#include <Spam/App/PosePlanner/Data.h>

//------------------------------------------------------------------------------

Expand Down
65 changes: 65 additions & 0 deletions include/Spam/App/R2GPlanner/Data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//------------------------------------------------------------------------------
// Simultaneous Perception And Manipulation (SPAM)
//------------------------------------------------------------------------------
//
// Copyright (c) 2010 University of Birmingham.
// All rights reserved.
//
// Intelligence Robot Lab.
// School of Computer Science
// University of Birmingham
// Edgbaston, Brimingham. UK.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// with the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimers.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimers in
// the documentation and/or other materials provided with the
// distribution.
// * Neither the names of the Simultaneous Perception And Manipulation
// (SPAM), University of Birmingham, nor the names of its contributors
// may be used to endorse or promote products derived from this Software
// without specific prior written permission.
//
// The software is provided "as is", without warranty of any kind, express or
// implied, including but not limited to the warranties of merchantability,
// fitness for a particular purpose and noninfringement. In no event shall the
// contributors or copyright holders be liable for any claim, damages or other
// liability, whether in an action of contract, tort or otherwise, arising
// from, out of or in connection with the software or the use of other dealings
// with the software.
//
//------------------------------------------------------------------------------
//! @Author: Claudio Zito
//! @Date: 27/10/2012
//------------------------------------------------------------------------------
#pragma once
#ifndef _SPAM_RAGPLANNER_DATA_H_
#define _SPAM_RAGPLANNER_DATA_H_

//------------------------------------------------------------------------------

#include <Spam/HBPlan/Belief.h>
#include <Spam/HBPlan/Heuristic.h>
#include <Spam/HBPlan/GraphPlanner.h>

//------------------------------------------------------------------------------

namespace grasp {
namespace data {
//------------------------------------------------------------------------------


//------------------------------------------------------------------------------

}; // namespace
}; // namespace

#endif /*_SPAM_RAGPLANNER_DATA_H_*/
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@

//------------------------------------------------------------------------------

#include <Spam/PosePlanner/PosePlanner.h>
#include <Spam/App/PosePlanner/PosePlanner.h>
#include <Spam/App/R2GPlanner/Data.h>
#include <Grasp/ActiveCtrl/ArmHandForce/ArmHandForce.h>

//------------------------------------------------------------------------------
Expand All @@ -65,15 +66,15 @@ namespace spam {
Based on Platt R. et al. "A hypothesis-based algorithm for planning and
control in non-Gaussian belief spaces", 2011.
*/
class RagPlanner : public PosePlanner, protected golem::Profile::CallbackDist {
class R2GPlanner : public PosePlanner, protected golem::Profile::CallbackDist {
public:
/** Force reader. Overwrite the ActiveCtrl reader. this retrieves the triggered joints */
typedef std::function<void(const golem::Controller::State&, grasp::RealSeq&, std::vector<golem::Configspace::Index>&)> GuardsReader;

/** Data */
class Data : public PosePlanner::Data {
public:
friend class RagPlanner;
friend class R2GPlanner;

/** Data bundle description */
class Desc : public PosePlanner::Data::Desc {
Expand All @@ -95,7 +96,7 @@ class RagPlanner : public PosePlanner, protected golem::Profile::CallbackDist {

protected:
/** Demo */
RagPlanner* owner;
R2GPlanner* owner;

/** Load from xml context */
virtual void load(const std::string& prefix, const golem::XMLContext* xmlcontext, const grasp::data::Handler::Map& handlerMap);
Expand All @@ -110,7 +111,7 @@ class RagPlanner : public PosePlanner, protected golem::Profile::CallbackDist {

class Desc : public PosePlanner::Desc {
protected:
GRASP_CREATE_FROM_OBJECT_DESC1(RagPlanner, golem::Object::Ptr, golem::Scene&)
GRASP_CREATE_FROM_OBJECT_DESC1(R2GPlanner, golem::Object::Ptr, golem::Scene&)

public:
/** Smart pointer */
Expand Down Expand Up @@ -212,9 +213,9 @@ class RagPlanner : public PosePlanner, protected golem::Profile::CallbackDist {
// gaussian filter mask
grasp::RealSeq mask;
// computes gaussian
template <typename _Real> inline _Real N(const _Real mean, const _Real stdev) {
template <typename _Real> inline _Real N(const _Real x, const _Real stdev) {
const _Real norm = golem::numeric_const<_Real>::ONE / (stdev*Math::sqrt(2 * golem::numeric_const<_Real>::PI));
return norm*golem::Math::exp(-.5*Math::sqr(_Real(mean) / _Real(stdev))); // gaussian
return norm*golem::Math::exp(-.5*Math::sqr(_Real(x) / _Real(stdev))); // gaussian
}
// computes guassian on a vector
template <typename _Ptr, typename _Real> inline std::vector<_Real> N(_Ptr begin, _Ptr end, const size_t dim, const _Real stdev) {
Expand Down Expand Up @@ -393,8 +394,8 @@ class RagPlanner : public PosePlanner, protected golem::Profile::CallbackDist {
virtual void render() const;
void renderHand(const golem::Controller::State &state, const golem::Bounds::Seq &bounds, bool clear = true);

RagPlanner(golem::Scene &scene);
~RagPlanner();
R2GPlanner(golem::Scene &scene);
~R2GPlanner();
bool create(const Desc& desc);
};

Expand Down
Loading

0 comments on commit 80b200f

Please sign in to comment.