如何在 MultiBodyPlant 上声明抽象端口
How do you declare an abstract port on a MultiBodyPlant
我想声明一个 AbstractOutputPort,这样我就可以在我的控制器中使用来自抽象端口的计算。
我是不是认为 MultiBodyPlants 错了,我应该定义创建我自己的 LeafSystem
void outputGeometryPose(
const drake::systems::Context<double>& context,
drake::geometry::FramePoseVector<double>* poses) {
}
// I also tried
// void outputGeometryPose(
// const drake::systems::Context<double>& context,
// drake::geometry::FrameKinematicsVector<drake::math::RigidTransform<double> >* ) {
// }
MultibodyPlant<double>* dp = builder.AddSystem<MultibodyPlant<double>>(max_time_step);
dp->set_name("plant");
dp->RegisterAsSourceForSceneGraph(&scene_graph);
Parser parser(dp);
parser.AddModelFromFile(kDoublePendulumSdfPath);
dp->DeclareAbstractOutputPort("geometry_pose", outputGeometryPose);
这就是我正在尝试的,但我收到以下编译错误
bazel-out/k8-opt/bin/external/drake/systems/framework/_virtual_includes/leaf_system/drake/systems/framework/leaf_system.h:1573:3: note: candidate template ignored: could not match 'void (MySystem::*)(const Context<double> &, OutputType *) const' against 'void (*)(const drake::systems::Context<double> &, drake::geometry::FrameKinematicsVector<drake::math::RigidTransform<double> > *)'
DeclareAbstractOutputPort(const OutputType& model_value,
A LeafSystem
(如MultibodyPlant
)负责在内部创建自己的输入/输出端口。您不能从外部向 MultibodyPlant
添加其他端口。
但我认为 MultibodyPlant
已经为您需要的任何多体相关量提供了输出端口。如果您能多告诉我们一些您想要实现的目标,我们可能会建议一个架构。
我想声明一个 AbstractOutputPort,这样我就可以在我的控制器中使用来自抽象端口的计算。
我是不是认为 MultiBodyPlants 错了,我应该定义创建我自己的 LeafSystem
void outputGeometryPose(
const drake::systems::Context<double>& context,
drake::geometry::FramePoseVector<double>* poses) {
}
// I also tried
// void outputGeometryPose(
// const drake::systems::Context<double>& context,
// drake::geometry::FrameKinematicsVector<drake::math::RigidTransform<double> >* ) {
// }
MultibodyPlant<double>* dp = builder.AddSystem<MultibodyPlant<double>>(max_time_step);
dp->set_name("plant");
dp->RegisterAsSourceForSceneGraph(&scene_graph);
Parser parser(dp);
parser.AddModelFromFile(kDoublePendulumSdfPath);
dp->DeclareAbstractOutputPort("geometry_pose", outputGeometryPose);
这就是我正在尝试的,但我收到以下编译错误
bazel-out/k8-opt/bin/external/drake/systems/framework/_virtual_includes/leaf_system/drake/systems/framework/leaf_system.h:1573:3: note: candidate template ignored: could not match 'void (MySystem::*)(const Context<double> &, OutputType *) const' against 'void (*)(const drake::systems::Context<double> &, drake::geometry::FrameKinematicsVector<drake::math::RigidTransform<double> > *)'
DeclareAbstractOutputPort(const OutputType& model_value,
A LeafSystem
(如MultibodyPlant
)负责在内部创建自己的输入/输出端口。您不能从外部向 MultibodyPlant
添加其他端口。
但我认为 MultibodyPlant
已经为您需要的任何多体相关量提供了输出端口。如果您能多告诉我们一些您想要实现的目标,我们可能会建议一个架构。