Skip to content
Snippets Groups Projects
Commit f6e6550a authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

Separate declaration and definition of Robot

parent a90c6d1f
No related branches found
No related tags found
No related merge requests found
......@@ -20,10 +20,11 @@
#ifndef HPP_MANIPULATION_ROBOT_HH
# define HPP_MANIPULATION_ROBOT_HH
# include <hpp/manipulation/handle.hh>
# include <hpp/manipulation/object.hh>
# include <hpp/model/device.hh>
# include "hpp/manipulation/fwd.hh"
# include "hpp/manipulation/config.hh"
namespace hpp {
namespace manipulation {
/// Robot holding one or several objects.
......@@ -58,68 +59,33 @@ namespace hpp {
vectorIn_t fullVelocity);
/// Get robot manipulating objects
const Devices_t& robots () const
{
return robots_;
}
const Devices_t& robots () const;
/// Get objects manipulated by the robot
const Objects_t& objects () const
{
return objects_;
}
const Objects_t& objects () const;
/// Get joint of this corresponding to joint of original object or robot.
const JointPtr_t& joint (const JointConstPtr_t& original)
{
return jointMap_ [original];
}
const JointPtr_t& joint (const JointConstPtr_t& original);
/// \name Composite robot handles
/// \{
/// Add a handle
void addHandle (const std::string& name, const HandlePtr_t& handle)
{
handles_ [name] = handle;
}
void addHandle (const std::string& name, const HandlePtr_t& handle);
/// Return the handle named name
const HandlePtr_t& handle (const std::string& name) const
{
Handles_t::const_iterator it = handles_.find (name);
if (it == handles_.end ())
throw std::runtime_error ("no handle with name " + name);
return it->second;
}
const HandlePtr_t& handle (const std::string& name) const;
/// \}
/// Add a gripper
void addGripper (const std::string& name, const GripperPtr_t& gripper)
{
grippers_ [name] = gripper;
}
void addGripper (const std::string& name, const GripperPtr_t& gripper);
/// Return the gripper named name
const GripperPtr_t& gripper (const std::string& name) const
{
Grippers_t::const_iterator it = grippers_.find (name);
if (it == grippers_.end ())
throw std::runtime_error ("no gripper with name " + name);
return it->second;
}
const GripperPtr_t& gripper (const std::string& name) const;
/// Get Device names in the same order than the compositeRobot has been
/// build
std::vector<std::string> getDeviceNames()
{
std::vector<std::string> deviceNames;
for ( Devices_t::iterator itDevice = robots_.begin() ; itDevice !=
robots_.end() ; itDevice++ ) {
deviceNames.push_back((*itDevice)->name());
}
for ( Objects_t::iterator itObject = objects_.begin() ; itObject !=
objects_.end() ; itObject++ ) {
deviceNames.push_back((*itObject)->name());
}
return deviceNames;
}
std::vector<std::string> getDeviceNames();
/// Print object in a stream
virtual std::ostream& print (std::ostream& os) const;
......
......@@ -18,10 +18,13 @@
// <http://www.gnu.org/licenses/>.
#include <hpp/util/debug.hh>
#include <hpp/manipulation/fwd.hh>
#include <hpp/model/object-factory.hh>
#include <hpp/manipulation/robot.hh>
#include <hpp/model/gripper.hh>
#include <hpp/model/object-factory.hh>
#include "hpp/manipulation/fwd.hh"
#include "hpp/manipulation/handle.hh"
#include "hpp/manipulation/object.hh"
#include "hpp/manipulation/robot.hh"
namespace hpp {
namespace manipulation {
......@@ -29,6 +32,61 @@ namespace hpp {
typedef std::map <std::string, GripperPtr_t> Grippers_t;
typedef std::vector<JointPtr_t> JointVector_t;
const Devices_t& Robot::robots () const
{
return robots_;
}
const Objects_t& Robot::objects () const
{
return objects_;
}
const JointPtr_t& Robot::joint (const JointConstPtr_t& original)
{
return jointMap_ [original];
}
void Robot::addHandle (const std::string& name, const HandlePtr_t& handle)
{
handles_ [name] = handle;
}
const HandlePtr_t& Robot::handle (const std::string& name) const
{
Handles_t::const_iterator it = handles_.find (name);
if (it == handles_.end ())
throw std::runtime_error ("no handle with name " + name);
return it->second;
}
void Robot::addGripper (const std::string& name, const GripperPtr_t& gripper)
{
grippers_ [name] = gripper;
}
const GripperPtr_t& Robot::gripper (const std::string& name) const
{
Grippers_t::const_iterator it = grippers_.find (name);
if (it == grippers_.end ())
throw std::runtime_error ("no gripper with name " + name);
return it->second;
}
std::vector<std::string> Robot::getDeviceNames()
{
std::vector<std::string> deviceNames;
for ( Devices_t::iterator itDevice = robots_.begin() ; itDevice !=
robots_.end() ; itDevice++ ) {
deviceNames.push_back((*itDevice)->name());
}
for ( Objects_t::iterator itObject = objects_.begin() ; itObject !=
objects_.end() ; itObject++ ) {
deviceNames.push_back((*itObject)->name());
}
return deviceNames;
}
void Robot::copyKinematicChain (const JointPtr_t& parentJoint,
const JointConstPtr_t& joint)
{
......@@ -86,7 +144,7 @@ namespace hpp {
for (model::JointVector_t::const_iterator itJoint = joints.begin() ;
itJoint != joints.end() ; itJoint++ ) {
gripper->addDisabledCollision(jointMap_[*itJoint]);
}
}
addGripper (gripper->name (), gripper);
}
}
......@@ -200,7 +258,7 @@ namespace hpp {
"," << joint2->name() << ")");
hpp::model::Device::addCollisionPairs (joint1, joint2,
hpp::model::COLLISION);
hpp::model::Device::addCollisionPairs (joint1, joint2,
hpp::model::Device::addCollisionPairs (joint1, joint2,
hpp::model::DISTANCE);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment