Skip to content

Commit 140b8dd

Browse files
Add KinematicsInformation class and modify srdf model class
1 parent c52c1d5 commit 140b8dd

File tree

25 files changed

+573
-364
lines changed

25 files changed

+573
-364
lines changed

tesseract/tesseract_environment/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ add_code_coverage_all_targets(EXCLUDE ${COVERAGE_EXCLUDE})
3434
tesseract_variables()
3535

3636
# Create interface for core
37-
add_library(${PROJECT_NAME}_core src/core/environment.cpp src/manipulator_manager/manipulator_manager.cpp)
37+
add_library(${PROJECT_NAME}_core src/core/environment.cpp src/core/manipulator_manager.cpp)
3838
target_link_libraries(${PROJECT_NAME}_core PUBLIC
3939
tesseract::tesseract_common
4040
tesseract::tesseract_collision_core

tesseract/tesseract_environment/include/tesseract_environment/core/commands.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
3737
#include <tesseract_scene_graph/joint.h>
3838
#include <tesseract_scene_graph/link.h>
3939
#include <tesseract_scene_graph/graph.h>
40+
#include <tesseract_scene_graph/kinematics_information.h>
4041

4142
namespace tesseract_environment
4243
{
@@ -57,7 +58,8 @@ enum class CommandType
5758
ADD_SCENE_GRAPH = 12,
5859
CHANGE_JOINT_POSITION_LIMITS = 13,
5960
CHANGE_JOINT_VELOCITY_LIMITS = 14,
60-
CHANGE_JOINT_ACCELERATION_LIMITS = 15
61+
CHANGE_JOINT_ACCELERATION_LIMITS = 15,
62+
ADD_KINEMATICS_INFORMATION = 16
6163
};
6264

6365
class Command
@@ -290,6 +292,23 @@ class AddSceneGraphCommand : public Command
290292
std::string prefix_;
291293
};
292294

295+
class AddKinematicsInformationCommand : public Command
296+
{
297+
public:
298+
AddKinematicsInformationCommand(tesseract_scene_graph::KinematicsInformation kinematics_information)
299+
: Command(CommandType::ADD_KINEMATICS_INFORMATION), kinematics_information_(std::move(kinematics_information))
300+
{
301+
}
302+
303+
const tesseract_scene_graph::KinematicsInformation& getKinematicsInformation() const
304+
{
305+
return kinematics_information_;
306+
}
307+
308+
private:
309+
tesseract_scene_graph::KinematicsInformation kinematics_information_;
310+
};
311+
293312
class ChangeJointPositionLimitsCommand : public Command
294313
{
295314
public:

tesseract/tesseract_environment/include/tesseract_environment/core/environment.h

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
3535

3636
#include <tesseract_environment/core/types.h>
3737
#include <tesseract_environment/core/commands.h>
38+
#include <tesseract_environment/core/state_solver.h>
39+
#include <tesseract_environment/core/manipulator_manager.h>
3840
#include <tesseract_collision/core/discrete_contact_manager.h>
3941
#include <tesseract_collision/core/discrete_contact_manager_factory.h>
4042
#include <tesseract_collision/core/continuous_contact_manager.h>
4143
#include <tesseract_collision/core/continuous_contact_manager_factory.h>
4244
#include <tesseract_scene_graph/graph.h>
43-
#include <tesseract_environment/core/state_solver.h>
44-
#include <tesseract_environment/manipulator_manager/manipulator_manager.h>
45+
#include <tesseract_scene_graph/utils.h>
4546

4647
namespace tesseract_environment
4748
{
@@ -70,7 +71,7 @@ class Environment
7071
*/
7172
template <typename S>
7273
bool init(const tesseract_scene_graph::SceneGraph& scene_graph,
73-
tesseract_scene_graph::SRDFModel::Ptr srdf_model = nullptr)
74+
const tesseract_scene_graph::SRDFModel::ConstPtr& srdf_model = nullptr)
7475
{
7576
initialized_ = false;
7677
revision_ = 0;
@@ -88,6 +89,9 @@ class Environment
8889
return false;
8990
}
9091

92+
if (srdf_model != nullptr)
93+
processSRDFAllowedCollisions(*scene_graph_, *srdf_model);
94+
9195
// Add this to the command history. This should always the the first thing in the command history
9296
++revision_;
9397
commands_.push_back(std::make_shared<AddSceneGraphCommand>(scene_graph, nullptr, ""));
@@ -111,15 +115,22 @@ class Environment
111115
return false;
112116
}
113117

118+
manipulator_manager_ = std::make_shared<ManipulatorManager>();
114119
if (!srdf_model)
115120
{
116121
CONSOLE_BRIDGE_logDebug("Environment is being initialized without an SRDF Model. Manipulators will not be "
117122
"registered");
118-
srdf_model = std::make_shared<tesseract_scene_graph::SRDFModel>();
119-
srdf_model->getName() = scene_graph_->getName();
123+
manipulator_manager_->init(scene_graph_, tesseract_scene_graph::KinematicsInformation());
124+
}
125+
else
126+
{
127+
manipulator_manager_->init(scene_graph_, srdf_model->getKinematicsInformation());
120128
}
121-
manipulator_manager_ = std::make_shared<ManipulatorManager>();
122-
manipulator_manager_->init(scene_graph_, srdf_model);
129+
130+
// Add this to the command history.
131+
++revision_;
132+
commands_.push_back(
133+
std::make_shared<AddKinematicsInformationCommand>(manipulator_manager_->getKinematicsInformation()));
123134

124135
is_contact_allowed_fn_ = std::bind(&tesseract_scene_graph::SceneGraph::isCollisionAllowed,
125136
scene_graph_,
@@ -175,13 +186,13 @@ class Environment
175186
* @brief Get the current revision number
176187
* @return Revision number
177188
*/
178-
int getRevision() const { return revision_; }
189+
int getRevision() const;
179190

180191
/**
181192
* @brief Get Environment command history post initialization
182193
* @return List of commands
183194
*/
184-
const Commands& getCommandHistory() const { return commands_; }
195+
const Commands& getCommandHistory() const;
185196

186197
/**
187198
* @brief Applies the commands to the environment
@@ -211,25 +222,44 @@ class Environment
211222
* @brief Check if environment has been initialized
212223
* @return True if initialized otherwise false
213224
*/
214-
virtual bool checkInitialized() const { return initialized_; }
225+
virtual bool checkInitialized() const;
215226

216227
/**
217228
* @brief Get the Scene Graph
218229
* @return SceneGraphConstPtr
219230
*/
220-
virtual const tesseract_scene_graph::SceneGraph::ConstPtr& getSceneGraph() const { return scene_graph_const_; }
231+
virtual const tesseract_scene_graph::SceneGraph::ConstPtr& getSceneGraph() const;
221232

222-
ManipulatorManager::Ptr getManipulatorManager() { return manipulator_manager_; }
223-
ManipulatorManager::ConstPtr getManipulatorManager() const { return manipulator_manager_; }
233+
/**
234+
* @brief Get the manipulator manager
235+
* @todo This should go away and should expose methods for adding and removing objects from the manager and storing
236+
* as commands
237+
* @warning Changes made to the manager are not capture in the command history.
238+
* @return The manipulator manager
239+
*/
240+
virtual ManipulatorManager::Ptr getManipulatorManager();
241+
242+
/**
243+
* @brief Get the manipulator manager const
244+
* @return The manipulator manager const
245+
*/
246+
virtual ManipulatorManager::ConstPtr getManipulatorManager() const;
247+
248+
/**
249+
* @brief Add kinematics information to the environment
250+
* @param kin_info The kinematics information
251+
* @return true if successful, otherwise false
252+
*/
253+
virtual bool addKinematicsInformation(const tesseract_scene_graph::KinematicsInformation& kin_info);
224254

225255
/** @brief Give the environment a name */
226-
virtual void setName(const std::string& name) { scene_graph_->setName(name); }
256+
virtual void setName(const std::string& name);
227257

228258
/** @brief Get the name of the environment
229259
*
230260
* This may be empty, if so check urdf name
231261
*/
232-
virtual const std::string& getName() const { return scene_graph_->getName(); }
262+
virtual const std::string& getName() const;
233263

234264
/**
235265
* @brief Set the current state of the environment
@@ -258,7 +288,7 @@ class Environment
258288
const Eigen::Ref<const Eigen::VectorXd>& joint_values) const;
259289

260290
/** @brief Get the current state of the environment */
261-
virtual EnvState::ConstPtr getCurrentState() const { return current_state_; }
291+
virtual EnvState::ConstPtr getCurrentState() const;
262292

263293
/**
264294
* @brief Adds a link to the environment
@@ -531,12 +561,7 @@ class Environment
531561
virtual bool setActiveDiscreteContactManager(const std::string& name);
532562

533563
/** @brief Get a copy of the environments active discrete contact manager */
534-
virtual tesseract_collision::DiscreteContactManager::Ptr getDiscreteContactManager() const
535-
{
536-
if (!discrete_manager_)
537-
return nullptr;
538-
return discrete_manager_->clone();
539-
}
564+
virtual tesseract_collision::DiscreteContactManager::Ptr getDiscreteContactManager() const;
540565

541566
/** @brief Get a copy of the environments available discrete contact manager by name */
542567
virtual tesseract_collision::DiscreteContactManager::Ptr getDiscreteContactManager(const std::string& name) const;
@@ -549,12 +574,7 @@ class Environment
549574
virtual bool setActiveContinuousContactManager(const std::string& name);
550575

551576
/** @brief Get a copy of the environments active continuous contact manager */
552-
virtual tesseract_collision::ContinuousContactManager::Ptr getContinuousContactManager() const
553-
{
554-
if (!continuous_manager_)
555-
return nullptr;
556-
return continuous_manager_->clone();
557-
}
577+
virtual tesseract_collision::ContinuousContactManager::Ptr getContinuousContactManager() const;
558578

559579
/** @brief Get a copy of the environments available continuous contact manager by name */
560580
virtual tesseract_collision::ContinuousContactManager::Ptr getContinuousContactManager(const std::string& name) const;
@@ -566,10 +586,7 @@ class Environment
566586
* in the environment.
567587
*/
568588
bool registerDiscreteContactManager(const std::string& name,
569-
tesseract_collision::DiscreteContactManagerFactory::CreateMethod create_function)
570-
{
571-
return discrete_factory_.registar(name, std::move(create_function));
572-
}
589+
tesseract_collision::DiscreteContactManagerFactory::CreateMethod create_function);
573590

574591
/**
575592
* @brief Set the discrete contact manager
@@ -579,10 +596,7 @@ class Environment
579596
*/
580597
bool
581598
registerContinuousContactManager(const std::string& name,
582-
tesseract_collision::ContinuousContactManagerFactory::CreateMethod create_function)
583-
{
584-
return continuous_factory_.registar(name, std::move(create_function));
585-
}
599+
tesseract_collision::ContinuousContactManagerFactory::CreateMethod create_function);
586600

587601
/** @brief Merge a graph into the current environment
588602
* @param scene_graph Const ref to the graph to be merged (said graph will be copied)
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3333
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3434

3535
#include <tesseract_scene_graph/srdf_model.h>
36-
#include <tesseract_scene_graph/srdf/types.h>
3736
#include <tesseract_kinematics/core/forward_kinematics_factory.h>
3837
#include <tesseract_kinematics/core/inverse_kinematics_factory.h>
3938

@@ -52,7 +51,8 @@ class ManipulatorManager
5251
ManipulatorManager(ManipulatorManager&&) = default;
5352
ManipulatorManager& operator=(ManipulatorManager&&) = default;
5453

55-
bool init(tesseract_scene_graph::SceneGraph::ConstPtr scene_graph, tesseract_scene_graph::SRDFModel::Ptr srdf_model);
54+
bool init(tesseract_scene_graph::SceneGraph::ConstPtr scene_graph,
55+
tesseract_scene_graph::KinematicsInformation kinematics_information);
5656

5757
/**
5858
* @brief Updates all of the stored solvers
@@ -66,8 +66,11 @@ class ManipulatorManager
6666
*/
6767
ManipulatorManager::Ptr clone(tesseract_scene_graph::SceneGraph::ConstPtr scene_graph) const;
6868

69-
/** @brief Get the SRDF Model */
70-
tesseract_scene_graph::SRDFModel::ConstPtr getSRDFModel() const;
69+
/** @brief Kinematics Information */
70+
bool addKinematicsInformation(const tesseract_scene_graph::KinematicsInformation& kinematics_information);
71+
72+
/** @brief Get the kinematics information */
73+
const tesseract_scene_graph::KinematicsInformation& getKinematicsInformation() const;
7174

7275
/** @brief Get Group Names */
7376
const tesseract_scene_graph::GroupNames& getGroupNames() const;
@@ -122,12 +125,6 @@ class ManipulatorManager
122125
const tesseract_scene_graph::GroupTCPs& getGroupTCPs() const;
123126
bool hasGroupTCP(const std::string& group_name, const std::string& tcp_name) const;
124127

125-
// This is exposed for the SRDF editor should not use in normal applications
126-
void addAllowedCollision(const std::string& link_1, const std::string& link_2, const std::string& reason);
127-
void removeAllowedCollision(const std::string& link_1, const std::string& link_2);
128-
void clearAllowedCollisions();
129-
const tesseract_scene_graph::AllowedCollisionMatrix& getAllowedCollisionMatrix() const;
130-
131128
/**
132129
* @brief Register a forward kinematics factory
133130
* @param factory The factory to register
@@ -301,7 +298,7 @@ class ManipulatorManager
301298
tesseract_kinematics::InverseKinematics::Ptr getInvKinematicSolver(const std::string& manipulator) const;
302299

303300
private:
304-
tesseract_scene_graph::SRDFModel::Ptr srdf_model_;
301+
tesseract_scene_graph::KinematicsInformation kinematics_information_;
305302
tesseract_scene_graph::SceneGraph::ConstPtr scene_graph_;
306303
tesseract_kinematics::ForwardKinematicsFactory::ConstPtr fwd_kin_chain_default_factory_;
307304
tesseract_kinematics::ForwardKinematicsFactory::ConstPtr fwd_kin_tree_default_factory_;

0 commit comments

Comments
 (0)