Skip to content

Make Frame frame_geometry a member subcomponent. #2338

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

Closed
wants to merge 60 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
bd02997
Introduce Model::finalizeConnections(void).
chrisdembia Oct 4, 2018
a218b36
Rename extendConnect() to extendFinalizeConnections().
chrisdembia Oct 4, 2018
8080798
First pass at delaying setting the connectee name property.
chrisdembia Oct 6, 2018
88d90fe
Partial implementation of delaying connectee name before backtracking.
chrisdembia Oct 11, 2018
1decde3
Use reference if it's set.
chrisdembia Oct 15, 2018
bffc2b1
Merge branch 'master' of github.com:opensim-org/opensim-core into del…
chrisdembia Oct 16, 2018
1f7f236
Fix multiple test cases.
chrisdembia Oct 16, 2018
6e91433
Add debug output to Object::operator==().
chrisdembia Oct 16, 2018
8def8fa
Fix updateFromXMLNode() for sets being components.
chrisdembia Oct 16, 2018
a42e331
Intermediate progress on testJoints.
chrisdembia Oct 16, 2018
e7e76a1
Fix updateFromXMLNode() for sets being components
chrisdembia Oct 16, 2018
20793d0
Fix some test cases.
chrisdembia Oct 16, 2018
e4c96f4
Fix bindings
chrisdembia Oct 17, 2018
bc530aa
Merge remote-tracking branch 'opensim-org/master' into delay_connecte…
chrisdembia Oct 17, 2018
ab0b5f9
Fix incorrect paths that were silently allowed previously.
chrisdembia Oct 17, 2018
94afc29
Rename findAndConnect() to finalizeConnection().
chrisdembia Oct 17, 2018
8aaf684
Fix bug with slave bodies.
chrisdembia Oct 17, 2018
7b50c03
Fix testJoints.
chrisdembia Oct 17, 2018
67ad06b
Fix fallout from strict connectee name enforcement.
chrisdembia Oct 18, 2018
1429d0d
Revert subject01_adjusted_spring.osim
chrisdembia Oct 18, 2018
46a2687
Miscellaneous cleanup.
chrisdembia Oct 18, 2018
f630059
Object::warnBeforePrint().
chrisdembia Oct 18, 2018
6de3ee3
Edit comments for macro-generated connect() functions.
chrisdembia Oct 18, 2018
c415baa
Revert arm26 model to 30000 model file version.
aseth1 Oct 18, 2018
18ab88f
Fix test failures from warnBeforePrint()
chrisdembia Oct 18, 2018
cd62c37
Remove TODOs and stale code.
chrisdembia Oct 18, 2018
066914a
Register channels to avoid stale pointers to channels.
chrisdembia Oct 18, 2018
1eba774
Merge branch 'delay_connectee_name' of github.com:opensim-org/opensim…
chrisdembia Oct 19, 2018
bcdc46c
Respond to some PR feedback.
chrisdembia Oct 19, 2018
3482ef4
Rename connectee name -> connectee path.
chrisdembia Oct 19, 2018
4dc7604
Revert Input::isConnected().
chrisdembia Oct 19, 2018
6b62b39
Remove model name from absolute paths.
chrisdembia Oct 19, 2018
8f68d84
Do not clear registeredChannels.
chrisdembia Oct 19, 2018
e0d5956
Add reset() in Component::updateFromXMLNode()
chrisdembia Oct 20, 2018
083ea97
Merge branch 'delay_connectee_name' of github.com:opensim-org/opensim…
chrisdembia Oct 20, 2018
729fbd6
Remove model name from absolute paths.
chrisdembia Oct 20, 2018
65b37d2
Address some of @aymanhab's comments.
chrisdembia Oct 22, 2018
b41d9cf
Create utility function for updating connectee paths.
chrisdembia Oct 23, 2018
8691a15
Remove model name from absolute paths.
chrisdembia Oct 19, 2018
dec688b
Remove model name from absolute paths.
chrisdembia Oct 20, 2018
19d0390
Only use absolute paths for connectee if ".."
chrisdembia Oct 22, 2018
c37e46b
Use absolute connectee paths in updateFromXMLNode.
chrisdembia Oct 23, 2018
b1e296f
Merge remote-tracking branch 'opensim-org/remove_model_name_from_abs_…
chrisdembia Oct 23, 2018
7c47a0a
prependToConnecteePath().
chrisdembia Oct 23, 2018
31be52b
Make prependToConnecteePath() protected.
chrisdembia Oct 23, 2018
8fd17cb
Remove depth argument.
chrisdembia Oct 23, 2018
9f58804
Make Component::prependToConnecteePath() public.
chrisdembia Oct 23, 2018
3480aa7
Fix calls to updateConnecteePath30517().
chrisdembia Oct 23, 2018
e64c94d
Make prependToConnectee() public, actually.
chrisdembia Oct 23, 2018
baa9125
Fix typo.
carmichaelong Oct 24, 2018
99e425d
Fix typo.
carmichaelong Oct 24, 2018
816c963
Remove lines that are now unnecessary.
chrisdembia Oct 24, 2018
a3c778b
Merge remote-tracking branch 'opensim-org/remove_model_name_from_abs_…
chrisdembia Oct 24, 2018
cb7945f
Separate getRelativePath() and getRelativePathString().
chrisdembia Oct 24, 2018
1f32f0d
prependComponentPathToConnecteePath().
chrisdembia Oct 24, 2018
7a1b9ff
Merge pull request #2326 from opensim-org/remove_model_name_from_abs_…
chrisdembia Oct 24, 2018
cfb033b
Merge branch 'master' of github.com:opensim-org/opensim-core into del…
chrisdembia Oct 25, 2018
0749df8
setSocketConnecteePath(): disconnect().
chrisdembia Oct 25, 2018
ecb7c33
Merge branch 'master' of github.com:opensim-org/opensim-core into del…
chrisdembia Oct 25, 2018
cbafc76
Make Frame frame_geometry a member subcomponent.
chrisdembia Oct 29, 2018
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,331 changes: 1,252 additions & 1,079 deletions Applications/Analyze/test/arm26.osim

Large diffs are not rendered by default.

4,335 changes: 2,256 additions & 2,079 deletions Applications/Analyze/test/subject01_adjusted_spring.osim

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
reporter = TableReporterVec3();
reporter.setName('reporter');
reporter.set_report_time_interval(0.1);

% Report the position of the origin of the body.
reporter.addToReport(body.getOutput('position'));
% For comparison, we will also get the center of mass position from the
Expand All @@ -64,6 +65,9 @@

model.addComponent(reporter);

% We must finalize connections to save the input-output connections in the
% model file.
model.finalizeConnections();
model.print(modelFilename);


Expand All @@ -78,7 +82,7 @@
% We can access the names of the outputs that the reporter is connected to.
disp('Outputs connected to the reporter:');
for i = 0:(reporter.getInput('inputs').getNumConnectees() - 1)
disp(reporter.getInput('inputs').getConnecteeName(i));
disp(reporter.getInput('inputs').getConnecteePath(i));
end

% Simulate the model.
Expand Down
13 changes: 7 additions & 6 deletions Bindings/Java/Matlab/tests/testConnectorsInputsOutputs.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


% Sockets
% ==========
% =======

% Access (and iterate through) a component's AbstractSockets, using names.
names = joint.getSocketNames();
Expand All @@ -56,7 +56,8 @@
% Connect a socket. Try the different methods to ensure they all work.
offset.connectSocket_parent(ground);
offset.updSocket('parent').connect(ground);
assert(strcmp(offset.getSocket('parent').getConnecteeName(), '../ground'));
model.finalizeConnections()
assert(strcmp(offset.getSocket('parent').getConnecteePath(), '/ground'));



Expand All @@ -81,7 +82,7 @@
% --------
% Access AbstractChannels.
assert(strcmp(coord.getOutput('speed').getChannel('').getPathName(), ...
'/leg/jointset/pin/pin_coord_0|speed'));
'/jointset/pin/pin_coord_0|speed'));

% Access the value of a concrete Channel.
% TODO Concrete channels are not wrapped yet.
Expand All @@ -99,16 +100,16 @@
rep.addToReport(source.getOutput('column').getChannel('c1'));
rep.updInput('inputs').connect(source.getOutput('column').getChannel('c2'), ...
'second_col');

model.finalizeConnections()

% Inputs
% ======

% Access (and iterate through) the AbstractInputs, using names.
names = rep.getInputNames();
expectedAliases = {'', 'target', '', 'second_col'};
expectedLabels = {'/leg/jointset/pin/pin_coord_0|value', 'target', ...
'/leg/source|column:c1', 'second_col'};
expectedLabels = {'/jointset/pin/pin_coord_0|value', 'target', ...
'/source|column:c1', 'second_col'};
for i = 0:(names.size() - 1)
% Actually, there is only one Input, named 'inputs'.
% We connected it to 4 channels.
Expand Down
7 changes: 4 additions & 3 deletions Bindings/Java/OpenSimJNI/OpenSimContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ void OpenSimContext::restoreStateFromCachedModel()
this->realizePosition();
}

void OpenSimContext::setSocketConnecteeName(AbstractSocket& socket,
void OpenSimContext::setSocketConnecteePath(AbstractSocket& socket,
const std::string& componentPathName) {
// Since some socket changes can form an invalid system
// we will make the change in a more conservative manner, by:
Expand All @@ -448,7 +448,7 @@ void OpenSimContext::setSocketConnecteeName(AbstractSocket& socket,
const Component& comp = socket.getOwner();
Component& componentInClone = clonedModel->updComponent(comp.getAbsolutePath());
auto& clonesocket = componentInClone.updSocket(socket.getName());
clonesocket.setConnecteeName(componentPathName);
clonesocket.setConnecteePath(componentPathName);
// The following line either succeeds or throws, if the latter happens then
// neither model or socket are changed and the message will be caught by GUI
try {
Expand All @@ -462,7 +462,8 @@ void OpenSimContext::setSocketConnecteeName(AbstractSocket& socket,
throw OpenSim::Exception(message);
}
// if we made it to this line then the change is safe, redo in actual model/comp/socket
socket.setConnecteeName(componentPathName);
socket.disconnect();
socket.setConnecteePath(componentPathName);
restoreStateFromCachedModel();
}
} // namespace
3 changes: 2 additions & 1 deletion Bindings/Java/OpenSimJNI/OpenSimContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ OpenSim_DECLARE_CONCRETE_OBJECT(OpenSimContext, Object);

void cacheModelAndState();
void restoreStateFromCachedModel() SWIG_DECLARE_EXCEPTION;
void setSocketConnecteeName(AbstractSocket& socket, const std::string& newValue ) SWIG_DECLARE_EXCEPTION;
void setSocketConnecteePath(AbstractSocket& socket,
const std::string& newValue) SWIG_DECLARE_EXCEPTION;
//=============================================================================
// DATA
//=============================================================================
Expand Down
4 changes: 2 additions & 2 deletions Bindings/Java/OpenSimJNI/Test/testContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ int main()
try {
// create an invalid model where joint connects two frames on ground,
// the test will verify the connectee has not been changed
context->setSocketConnecteeName(socket, "ground");
context->setSocketConnecteePath(socket, "ground");
}
catch (const std::exception& e) {
// Expect meaningful error message explaining why initsystem failed
Expand All @@ -243,7 +243,7 @@ int main()
try {
// Try to create an invalid model again, this call should leave the
// model untouched since change invalidates psocket
context->setSocketConnecteeName(psocket, "r_ulna_radius_hand");
context->setSocketConnecteePath(psocket, "r_ulna_radius_hand");

}
catch (const std::exception& e) {
Expand Down
2 changes: 1 addition & 1 deletion Bindings/Java/tests/TestEditMarkers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void main(String[] args) {
Marker newMarker = new Marker();
newMarker.setName(newMarkerName);
newMarker.set_location(offset);
newMarker.setParentFrameName(body.getName());
newMarker.setParentFrame(body);
context.cacheModelAndState();
model.addMarker(newMarker);
try {
Expand Down
16 changes: 8 additions & 8 deletions Bindings/Java/tests/TestReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public static void test_TableReporter_1() throws java.io.IOException {

assert table.getColumnLabels().size() == 2;
assert table.getColumnLabel(0).
equals("/model/table_source|column:col1");
equals("/table_source|column:col1");
assert table.getColumnLabel(1).
equals("/model/table_source|column:col2");
equals("/table_source|column:col2");
assert table.getNumRows() == 3;
assert table.getNumColumns() == 2;
assert table.getRowAtIndex(0).get(0) == 1;
Expand All @@ -66,17 +66,17 @@ public static void test_TableReporter_1() throws java.io.IOException {
assert table.getNumColumns() == 0;
assert table.getColumnLabels().size() == 2;
assert table.getColumnLabel(0).
equals("/model/table_source|column:col1");
equals("/table_source|column:col1");
assert table.getColumnLabel(1).
equals("/model/table_source|column:col2");
equals("/table_source|column:col2");
// Make sure the table reference is still valid.
assert table.getNumRows() == 0;
assert table.getNumColumns() == 0;
assert table.getColumnLabels().size() == 2;
assert table.getColumnLabel(0).
equals("/model/table_source|column:col1");
equals("/table_source|column:col1");
assert table.getColumnLabel(1).
equals("/model/table_source|column:col2");
equals("/table_source|column:col2");

state = model.initSystem();
state.setTime(0.1);
Expand All @@ -88,9 +88,9 @@ public static void test_TableReporter_1() throws java.io.IOException {

assert table.getColumnLabels().size() == 2;
assert table.getColumnLabel(0).
equals("/model/table_source|column:col1");
equals("/table_source|column:col1");
assert table.getColumnLabel(1).
equals("/model/table_source|column:col2");
equals("/table_source|column:col2");
assert table.getNumRows() == 3;
assert table.getNumColumns() == 2;
assert table.getRowAtIndex(0).get(0) == 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ def print_model():
# one-body system. The (optional) second argument is an alias for the name
# of the output; it is used as the column label in the table.
reporter.addToReport(model.getOutput('com_position'), 'com_pos')

model.addComponent(reporter)
model.finalizeConnections()

# Display what input-output connections look like in XML (in .osim files).
print("Reporter input-output connections in XML:\n" + reporter.dump())

model.addComponent(reporter)

model.printToXML(model_filename)

Expand All @@ -79,7 +81,7 @@ def print_model():
# We can access the names of the outputs that the reporter is connected to.
print('Outputs connected to the reporter:')
for i in range(reporter.getInput('inputs').getNumConnectees()):
print(reporter.getInput('inputs').getConnecteeName(i))
print(reporter.getInput('inputs').getConnecteePath(i))

# Simulate the model.
manager = osim.Manager(deserialized_model)
Expand All @@ -104,5 +106,3 @@ def print_model():





13 changes: 8 additions & 5 deletions Bindings/Python/tests/test_sockets_inputs_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_output_values(self):
# AbstractChannel.
coord = model.getCoordinateSet().get(0)
self.assertEquals(coord.getOutput('speed').getChannel('').getPathName(),
'/arm26/jointset/r_shoulder/r_shoulder_elev|speed')
'/jointset/r_shoulder/r_shoulder_elev|speed')

# Access the value of a concrete Channel.
# TODO Concrete channels are not wrapped yet.
Expand Down Expand Up @@ -211,8 +211,8 @@ def test_connecting_and_iterate_inputs(self):
s = m.initSystem()

# Access and iterate through AbstractInputs, using names.
expectedLabels = ['/model/jointset/pin/pin_coord_0|value', 'spd',
'/model/source|column:col1', 'second_col']
expectedLabels = ['/jointset/pin/pin_coord_0|value', 'spd',
'/source|column:col1', 'second_col']
i = 0
for name in rep.getInputNames():
# Actually, there is only one input, which we connected to 4
Expand Down Expand Up @@ -255,16 +255,19 @@ def print_model():
reporter = osim.TableReporterVec3()
reporter.setName('reporter')
reporter.set_report_time_interval(0.1)

reporter.addToReport(model.getOutput('com_position'))

model.addComponent(reporter)
model.finalizeConnections()

reporter.getInput('inputs').setAlias(0, 'com_pos')

# Display what input-output connections look like in XML
# (in .osim files).
print("Reporter input-output connections in XML:\n" + \
reporter.dump())

model.addComponent(reporter)

model.printToXML(model_filename)

# Create and print the model file.
Expand Down
4 changes: 2 additions & 2 deletions OpenSim/Actuators/BodyActuator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ void BodyActuator::constructProperties()

void BodyActuator::setBodyName(const std::string& name)
{
updSocket<Body>("body").setConnecteeName(name);
updSocket<Body>("body").setConnecteePath(name);
}

const std::string& BodyActuator::getBodyName() const
{
return getSocket<Body>("body").getConnecteeName();
return getSocket<Body>("body").getConnecteePath();
}

//=============================================================================
Expand Down
2 changes: 2 additions & 0 deletions OpenSim/Actuators/Test/testActuators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ void testTorqueActuator()

//model->addProbe(powerProbe);

model->finalizeConnections();
model->print("TestTorqueActuatorModel.osim");
model->setUseVisualizer(false);

Expand Down Expand Up @@ -355,6 +356,7 @@ void testClutchedPathSpring()
controller->prescribeControlForActuator("clutch_spring", controlfunc);
model->addController(controller);

model->finalizeConnections();
model->print("ClutchedPathSpringModel.osim");

//Test deserialization
Expand Down
Loading