diff --git a/Bindings/Java/Matlab/tests/testConnectorsInputsOutputs.m b/Bindings/Java/Matlab/tests/testConnectorsInputsOutputs.m
index 0604c0bc06..ef8ddf40e9 100644
--- a/Bindings/Java/Matlab/tests/testConnectorsInputsOutputs.m
+++ b/Bindings/Java/Matlab/tests/testConnectorsInputsOutputs.m
@@ -53,7 +53,8 @@
body = Body.safeDownCast(joint.getConnectee('child_frame'));
assert(body.getMass() == 2);
-% Connect a connector.
+% Connect a connector. Try the different methods to ensure they all work.
+offset.connectConnector_parent(ground);
offset.updConnector('parent').connect(ground);
assert(strcmp(offset.getConnector('parent').getConnecteeName(), '../ground'));
diff --git a/Bindings/Python/tests/test_connectors_inputs_outputs.py b/Bindings/Python/tests/test_connectors_inputs_outputs.py
index 73cc9bc423..65eba6a3b9 100644
--- a/Bindings/Python/tests/test_connectors_inputs_outputs.py
+++ b/Bindings/Python/tests/test_connectors_inputs_outputs.py
@@ -84,11 +84,11 @@ def test_connecting(self):
j1 = osim.PinJoint()
j1.setName("j1")
j1.updConnector("parent_frame").connect(model.getGround())
- j1.updConnector("child_frame").connect(b1)
+ j1.connectConnector_child_frame(b1)
j2 = osim.PinJoint()
j2.setName("j2")
- j2.updConnector("parent_frame").connect(b1)
+ j2.connectConnector_parent_frame(b1)
j2.updConnector("child_frame").connect(b2)
model.addBody(b1)
diff --git a/OpenSim/Actuators/BodyActuator.cpp b/OpenSim/Actuators/BodyActuator.cpp
index fe4adbe585..7195ebe208 100644
--- a/OpenSim/Actuators/BodyActuator.cpp
+++ b/OpenSim/Actuators/BodyActuator.cpp
@@ -93,7 +93,7 @@ const std::string& BodyActuator::getBodyName() const
*/
void BodyActuator::setBody(const Body& body)
{
- updConnector
("body").connect(body);
+ connectConnector_body(body);
}
/**
diff --git a/OpenSim/Common/ComponentConnector.h b/OpenSim/Common/ComponentConnector.h
index 6c2b9bf118..4b53e3652a 100644
--- a/OpenSim/Common/ComponentConnector.h
+++ b/OpenSim/Common/ComponentConnector.h
@@ -848,16 +848,25 @@ class Input : public AbstractInput {
/** In an XML file, you can set this Connector's connectee name */ \
/** via the \ element. */ \
/** This connector was generated with the */ \
- /** #OpenSim_DECLARE_CONNECTOR macro. */ \
+ /** #OpenSim_DECLARE_CONNECTOR macro; */ \
+ /** see AbstractConnector for more information. */ \
+ /** @connectormethods connectConnector_##cname##() */ \
OpenSim_DOXYGEN_Q_PROPERTY(T, cname) \
/** @} */ \
/** @cond */ \
PropertyIndex PropertyIndex_connector_##cname##_connectee_name { \
this->template constructConnector(#cname, \
- "Path to a Component to satisfy the Connector '" \
+ "Path to a Component that satisfies the Connector '" \
#cname "' of type " #T " (description: " comment ").") \
}; \
- /** @endcond */
+ /** @endcond */ \
+ /** @name Connector-related functions */ \
+ /** @{ */ \
+ /** Connect the '##cname##' Connector to an object of type T##. */ \
+ void connectConnector_##cname(const Object& object) { \
+ this->updConnector(#cname).connect(object); \
+ } \
+ /** @} */
// The following doxygen-like description does NOT actually appear in doxygen.
/* Preferably, use the #OpenSim_DECLARE_CONNECTOR macro. Only use this macro
@@ -914,6 +923,8 @@ class Input : public AbstractInput {
/** comment */ \
/** In an XML file, you can set this Connector's connectee name */ \
/** via the \ element. */ \
+ /** See AbstractConnector for more information. */ \
+ /** @connectormethods connectConnector_##cname##() */ \
OpenSim_DOXYGEN_Q_PROPERTY(T, cname) \
/** @} */ \
/** @cond */ \
@@ -925,7 +936,14 @@ class Input : public AbstractInput {
PropertyIndex constructConnector_##cname(); \
/* Remember the provided type so we can use it in the DEFINE macro. */ \
typedef T _connector_##cname##_type; \
- /** @endcond */
+ /** @endcond */ \
+ /** @name Connector-related functions */ \
+ /** @{ */ \
+ /** Connect the '##cname##' Connector to an object of type T##. */ \
+ void connectConnector_##cname(const Object& object) { \
+ this->updConnector(#cname).connect(object); \
+ } \
+ /** @} */
// The following doxygen-like description does NOT actually appear in doxygen.
/* When specifying a Connector to a forward-declared type (using
@@ -950,7 +968,7 @@ PropertyIndex Class::constructConnector_##cname() { \
using T = _connector_##cname##_type; \
std::string typeStr = T::getClassName(); \
return this->template constructConnector(#cname, \
- "Path to a Component to satisfy the Connector '" \
+ "Path to a Component that satisfies the Connector '" \
#cname "' of type " + typeStr + "."); \
}
/// @}
diff --git a/OpenSim/Common/Test/testComponentInterface.cpp b/OpenSim/Common/Test/testComponentInterface.cpp
index c49b86b4cf..4e73490ef3 100644
--- a/OpenSim/Common/Test/testComponentInterface.cpp
+++ b/OpenSim/Common/Test/testComponentInterface.cpp
@@ -480,7 +480,7 @@ void testMisc() {
//Configure the connector to look for its dependency by this name
//Will get resolved and connected automatically at Component connect
bar.updConnector("parentFoo").setConnecteeName(foo.getAbsolutePathName());
- bar.updConnector("childFoo").connect(foo);
+ bar.connectConnector_childFoo(foo);
// add a subcomponent
// connect internals
@@ -527,7 +527,7 @@ void testMisc() {
SimTK_TEST(!theWorld.hasComponent("Nonexistant"));
- bar.updConnector("childFoo").connect(foo2);
+ bar.connectConnector_childFoo(foo2);
string connectorName = bar.updConnector("childFoo").getName();
// Bar should connect now
@@ -675,7 +675,7 @@ void testMisc() {
bar2.updConnector("parentFoo")
.setConnecteeName(compFoo.getRelativePathName(bar2));
- bar2.updConnector("childFoo").connect(foo);
+ bar2.connectConnector_childFoo(foo);
compFoo.upd_Foo1().updInput("input1")
.connect(bar2.getOutput("PotentialEnergy"));
@@ -864,7 +864,7 @@ void testListConnectors() {
// Ensure that calling connect() on bar's "parentFoo" doesn't increase
// its number of connectees.
- bar.updConnector("parentFoo").connect(foo);
+ bar.connectConnector_parentFoo(foo);
// TODO The "Already connected to 'foo'" is caught by `connect()`.
SimTK_TEST(bar.getConnector("parentFoo").getNumConnectees() == 1);
@@ -1001,9 +1001,8 @@ void testComponentPathNames()
ASSERT(&foo1inA == foo1);
// This bar2 that belongs to A and connects the two foo2s
- bar2->updConnector("parentFoo").connect(*foo2);
- bar2->updConnector("childFoo")
- .connect(F->getComponent("Foo2"));
+ bar2->connectConnector_parentFoo(*foo2);
+ bar2->connectConnector_childFoo(F->getComponent("Foo2"));
// auto& foo2inF = bar2->getComponent("../../F/Foo2");
@@ -1012,7 +1011,7 @@ void testComponentPathNames()
auto& fbar2 = F->updComponent("Bar2");
ASSERT(&fbar2 != bar2);
- fbar2.updConnector("parentFoo").connect(*foo1);
+ fbar2.connectConnector_parentFoo(*foo1);
fbar2.updConnector("childFoo")
.setConnecteeName("../Foo1");
@@ -1031,8 +1030,8 @@ void testInputOutputConnections()
foo1->setName("foo1");
foo2->setName("foo2");
bar->setName("bar");
- bar->updConnector("parentFoo").connect(*foo1);
- bar->updConnector("childFoo").connect(*foo2);
+ bar->connectConnector_parentFoo(*foo1);
+ bar->connectConnector_childFoo(*foo2);
world.add(foo1);
world.add(foo2);
diff --git a/OpenSim/Examples/ExampleHopperDevice/buildDeviceModel_answers.cpp b/OpenSim/Examples/ExampleHopperDevice/buildDeviceModel_answers.cpp
index 95d03c50af..e8d999e0b4 100644
--- a/OpenSim/Examples/ExampleHopperDevice/buildDeviceModel_answers.cpp
+++ b/OpenSim/Examples/ExampleHopperDevice/buildDeviceModel_answers.cpp
@@ -85,7 +85,7 @@ Device* buildDevice() {
// frame will be connected in exampleHopperDevice.cpp.
#pragma region Step2_TaskC_solution
- anchorA->updConnector("child_frame").connect(*cuffA);
+ anchorA->connectConnector_child_frame(*cuffA);
#pragma endregion
@@ -103,7 +103,7 @@ Device* buildDevice() {
auto anchorB = new WeldJoint();
anchorB->setName("anchorB");
- anchorB->updConnector("child_frame").connect(*cuffB);
+ anchorB->connectConnector_child_frame(*cuffB);
device->addComponent(anchorB);
#pragma endregion
@@ -124,7 +124,7 @@ Device* buildDevice() {
//TODO: Connect the controller's "actuator" Connector to pathActuator.
#pragma region Step2_TaskC_solution
- controller->updConnector("actuator").connect(*pathActuator);
+ controller->connectConnector_actuator(*pathActuator);
#pragma endregion
diff --git a/OpenSim/Examples/ExampleHopperDevice/exampleHopperDevice_answers.cpp b/OpenSim/Examples/ExampleHopperDevice/exampleHopperDevice_answers.cpp
index 7ca3867172..47b0c06530 100644
--- a/OpenSim/Examples/ExampleHopperDevice/exampleHopperDevice_answers.cpp
+++ b/OpenSim/Examples/ExampleHopperDevice/exampleHopperDevice_answers.cpp
@@ -114,9 +114,9 @@ void connectDeviceToModel(OpenSim::Device& device, OpenSim::Model& model,
#pragma region Step2_TaskD_solution
const auto& frameA = model.getComponent(modelFrameAname);
- anchorA.updConnector("parent_frame").connect(frameA);
+ anchorA.connectConnector_parent_frame(frameA);
const auto& frameB = model.getComponent(modelFrameBname);
- anchorB.updConnector("parent_frame").connect(frameB);
+ anchorB.connectConnector_parent_frame(frameB);
#pragma endregion
diff --git a/OpenSim/Simulation/Model/ConditionalPathPoint.cpp b/OpenSim/Simulation/Model/ConditionalPathPoint.cpp
index f1c8df16c4..b442dfd0bb 100644
--- a/OpenSim/Simulation/Model/ConditionalPathPoint.cpp
+++ b/OpenSim/Simulation/Model/ConditionalPathPoint.cpp
@@ -94,7 +94,7 @@ void ConditionalPathPoint::constructProperties()
*/
void ConditionalPathPoint::setCoordinate(const Coordinate& coordinate)
{
- updConnector("coordinate").connect(coordinate);
+ connectConnector_coordinate(coordinate);
}
bool ConditionalPathPoint::hasCoordinate() const
diff --git a/OpenSim/Simulation/Model/ContactGeometry.cpp b/OpenSim/Simulation/Model/ContactGeometry.cpp
index 4f1cb4b1a7..fe55860210 100644
--- a/OpenSim/Simulation/Model/ContactGeometry.cpp
+++ b/OpenSim/Simulation/Model/ContactGeometry.cpp
@@ -101,7 +101,7 @@ const PhysicalFrame& ContactGeometry::getFrame() const
void ContactGeometry::setFrame(const PhysicalFrame& frame)
{
- updConnector("frame").connect(frame);
+ connectConnector_frame(frame);
}
const PhysicalFrame& ContactGeometry::getBody() const
diff --git a/OpenSim/Simulation/Model/MovingPathPoint.cpp b/OpenSim/Simulation/Model/MovingPathPoint.cpp
index 3ef310f0a7..8f27e91561 100644
--- a/OpenSim/Simulation/Model/MovingPathPoint.cpp
+++ b/OpenSim/Simulation/Model/MovingPathPoint.cpp
@@ -98,15 +98,15 @@ const Coordinate& MovingPathPoint::getZCoordinate() const
void MovingPathPoint::setXCoordinate(const Coordinate& coordinate)
{
- updConnector("x_coordinate").connect(coordinate);
+ connectConnector_x_coordinate(coordinate);
}
void MovingPathPoint::setYCoordinate(const Coordinate& coordinate)
{
- updConnector("y_coordinate").connect(coordinate);
+ connectConnector_y_coordinate(coordinate);
}
void MovingPathPoint::setZCoordinate(const Coordinate& coordinate)
{
- updConnector("z_coordinate").connect(coordinate);
+ connectConnector_z_coordinate(coordinate);
}
void MovingPathPoint::extendConnectToModel(Model& model)
diff --git a/OpenSim/Simulation/Model/OffsetFrame.h b/OpenSim/Simulation/Model/OffsetFrame.h
index 7b1205be8c..f6815c8cbd 100644
--- a/OpenSim/Simulation/Model/OffsetFrame.h
+++ b/OpenSim/Simulation/Model/OffsetFrame.h
@@ -292,7 +292,7 @@ calcAccelerationInGround(const SimTK::State& state) const
template
void OffsetFrame::setParentFrame(const C& parent)
{
- this->template updConnector("parent").connect(parent);
+ this->connectConnector_parent(parent);
}
template
diff --git a/OpenSim/Simulation/Model/PointToPointSpring.cpp b/OpenSim/Simulation/Model/PointToPointSpring.cpp
index d864534ac9..a349948945 100644
--- a/OpenSim/Simulation/Model/PointToPointSpring.cpp
+++ b/OpenSim/Simulation/Model/PointToPointSpring.cpp
@@ -91,12 +91,12 @@ void PointToPointSpring::constructProperties()
void PointToPointSpring::setBody1(const PhysicalFrame& body)
{
- updConnector("body1").connect(body);
+ connectConnector_body1(body);
}
void PointToPointSpring::setBody2(const PhysicalFrame& body)
{
- updConnector("body2").connect(body);
+ connectConnector_body2(body);
}
const PhysicalFrame& PointToPointSpring::getBody1() const
diff --git a/OpenSim/Simulation/Model/PrescribedForce.cpp b/OpenSim/Simulation/Model/PrescribedForce.cpp
index ebd8a5505a..67db03b1b2 100644
--- a/OpenSim/Simulation/Model/PrescribedForce.cpp
+++ b/OpenSim/Simulation/Model/PrescribedForce.cpp
@@ -51,7 +51,7 @@ PrescribedForce::PrescribedForce(const std::string& name, const PhysicalFrame& f
PrescribedForce()
{
setName(name);
- updConnector("frame").connect(frame);
+ connectConnector_frame(frame);
}
//_____________________________________________________________________________
diff --git a/OpenSim/Simulation/Model/Station.cpp b/OpenSim/Simulation/Model/Station.cpp
index 0240cc97d0..e846216818 100644
--- a/OpenSim/Simulation/Model/Station.cpp
+++ b/OpenSim/Simulation/Model/Station.cpp
@@ -98,7 +98,7 @@ const PhysicalFrame& Station::getParentFrame() const
*/
void Station::setParentFrame(const OpenSim::PhysicalFrame& aFrame)
{
- updConnector("parent_frame").connect(aFrame);
+ connectConnector_parent_frame(aFrame);
}
SimTK::Vec3 Station::findLocationInFrame(const SimTK::State& s,
diff --git a/OpenSim/Simulation/Model/TwoFrameLinker.h b/OpenSim/Simulation/Model/TwoFrameLinker.h
index 56f5e1afc1..8aad2699ec 100644
--- a/OpenSim/Simulation/Model/TwoFrameLinker.h
+++ b/OpenSim/Simulation/Model/TwoFrameLinker.h
@@ -306,8 +306,8 @@ TwoFrameLinker::TwoFrameLinker(const std::string &name,
int ix2 = append_frames(frame2Offset);
this->finalizeFromProperties();
- this->template updConnector("frame1").connect(get_frames(ix1));
- this->template updConnector("frame2").connect(get_frames(ix2));
+ this->connectConnector_frame1(get_frames(ix1));
+ this->connectConnector_frame2(get_frames(ix2));
static_cast(upd_frames(ix1)).setParentFrame(frame1);
static_cast(upd_frames(ix2)).setParentFrame(frame2);
@@ -333,8 +333,8 @@ TwoFrameLinker::TwoFrameLinker(const std::string &name,
int ix2 = append_frames(frame2Offset);
this->finalizeFromProperties();
- this->template updConnector("frame1").connect(get_frames(ix1));
- this->template updConnector("frame2").connect(get_frames(ix2));
+ this->connectConnector_frame1(get_frames(ix1));
+ this->connectConnector_frame2(get_frames(ix2));
}
template
diff --git a/OpenSim/Simulation/SimbodyEngine/Joint.cpp b/OpenSim/Simulation/SimbodyEngine/Joint.cpp
index fd59fc5511..3a1de29867 100644
--- a/OpenSim/Simulation/SimbodyEngine/Joint.cpp
+++ b/OpenSim/Simulation/SimbodyEngine/Joint.cpp
@@ -70,8 +70,8 @@ Joint::Joint(const std::string &name, const PhysicalFrame& parent,
setName(name);
set_reverse(reverse);
- updConnector("parent_frame").connect(parent);
- updConnector("child_frame").connect(child);
+ connectConnector_parent_frame(parent);
+ connectConnector_child_frame(child);
}
/* Convenience Constructor*/
@@ -130,8 +130,8 @@ Joint::Joint(const std::string &name,
static_cast(upd_frames(pix)).setParentFrame(parent);
static_cast(upd_frames(cix)).setParentFrame(child);
- updConnector("parent_frame").connect(upd_frames(pix));
- updConnector("child_frame").connect(upd_frames(cix));
+ connectConnector_parent_frame(upd_frames(pix));
+ connectConnector_child_frame(upd_frames(cix));
}
//=============================================================================
diff --git a/OpenSim/Simulation/SimbodyEngine/WeldConstraint.cpp b/OpenSim/Simulation/SimbodyEngine/WeldConstraint.cpp
index 9ce28854fb..7bd1dc34fd 100644
--- a/OpenSim/Simulation/SimbodyEngine/WeldConstraint.cpp
+++ b/OpenSim/Simulation/SimbodyEngine/WeldConstraint.cpp
@@ -158,7 +158,7 @@ void WeldConstraint::
_internalOffset1.reset(new PhysicalOffsetFrame(frame1, in1));
_internalOffset1->setName("internal_" + frame1.getName());
updProperty_frames().adoptAndAppendValue(_internalOffset1.get());
- updConnector("frame1").connect(*_internalOffset1);
+ connectConnector_frame1(*_internalOffset1);
}
else { // otherwise it is already "wired" up so just update
_internalOffset1->setOffsetTransform(in1);
@@ -168,7 +168,7 @@ void WeldConstraint::
_internalOffset2.reset(new PhysicalOffsetFrame(frame2, in2));
_internalOffset2->setName("internal_" + frame2.getName());
updProperty_frames().adoptAndAppendValue(_internalOffset2.get());
- updConnector("frame2").connect(*_internalOffset2);
+ connectConnector_frame2(*_internalOffset2);
}
else {
_internalOffset2->setOffsetTransform(in2);
diff --git a/OpenSim/Simulation/Test/testNestedModelComponents.cpp b/OpenSim/Simulation/Test/testNestedModelComponents.cpp
index 819b7a4745..e7058c6066 100644
--- a/OpenSim/Simulation/Test/testNestedModelComponents.cpp
+++ b/OpenSim/Simulation/Test/testNestedModelComponents.cpp
@@ -81,11 +81,11 @@ void testPendulumModelWithNestedJoints()
// Create WeldJoints to anchor cuff Bodies to the pendulum.
auto* anchorA = new WeldJoint();
anchorA->setName("anchorA");
- anchorA->updConnector("child_frame").connect(*cuffA);
+ anchorA->connectConnector_child_frame(*cuffA);
auto* anchorB = new WeldJoint();
anchorB->setName("anchorB");
- anchorB->updConnector("child_frame").connect(*cuffB);
+ anchorB->connectConnector_child_frame(*cuffB);
// add anchors to the Device
device->addComponent(anchorA);
@@ -97,8 +97,8 @@ void testPendulumModelWithNestedJoints()
// Connect the device to bodies of the pendulum
const auto& rod1 = pendulum->getComponent("rod1");
const auto& rod2 = pendulum->getComponent("rod2");
- anchorA->updConnector("parent_frame").connect(rod1);
- anchorB->updConnector("parent_frame").connect(rod2);
+ anchorA->connectConnector_parent_frame(rod1);
+ anchorB->connectConnector_parent_frame(rod2);
State& s = pendulum->initSystem();
}
diff --git a/doc/doxyfile_shared.in b/doc/doxyfile_shared.in
index 35f8ddbd17..39323fd154 100644
--- a/doc/doxyfile_shared.in
+++ b/doc/doxyfile_shared.in
@@ -204,8 +204,9 @@ TAB_SIZE = 4
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
-ALIASES = "propmethods=\par Methods related to this property\n" \
- "inputmethods=\par Methods related to this input\n"
+ALIASES = "propmethods=\par Methods related to this property\n" \
+ "inputmethods=\par Methods related to this input\n" \
+ "connectormethods=\par Methods related to this connector\n"
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding