-
Notifications
You must be signed in to change notification settings - Fork 155
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
add external properties to SolutionInfo #194
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #194 +/- ##
==========================================
+ Coverage 51.63% 51.88% +0.26%
==========================================
Files 101 102 +1
Lines 6590 7202 +612
==========================================
+ Hits 3402 3736 +334
- Misses 3188 3466 +278
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that a Property's value
field is a string comprising a serialized version of an arbitrary property.
The serialization/deserialization methods are not (yet) exposed and might be subject to changes. There are also some properties, which don't (yet) have a serialization/deserialization method defined.
Hence, the Property
type might not be the best choice to implement the behavior here. At least we would need to expose the deserialization methods...
That's exactly why I would prefer it over some string indicator fields for this.
Same for everything else in MTC.
From a pragmatic point of view it works just fine with |
a3f816a
to
89f9d2f
Compare
Better usability for user code if they deserialize individual Propertys. The fallback variants are not used internally and are redundant because there is a separate default behavior. Removed the msg parameter for Property exceptions. It was only used by a single edge-case which didn't really justify the use of the exception anyway. Instead allow `undefined` to be instantiated without parameters because the Property does not know its own name.
Defaults are not supposed to be modified by accident. Instead, provide a writable reference to currentValue.
89f9d2f
to
50ef6ea
Compare
50ef6ea
to
fb0fa19
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few remarks... We definitely should have a phone call to sync a little bit on our activities 😉
Derive from a type conditioned on the actual capabilities of T.
I was long thinking about why I decided against your proposed solution when I worked on Property serialization.
|
We discussed pros and cons of the old and the proposed approach in a phone conference. This is the summary:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the summary. here are some more comments I wrote before the talk reviewing your changes.
I want to execute subsolutions of a solution sequentially and in between set IOs or call services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the status of this PR. @v4hn, maybe we should schedule another phone call?
} catch (Property::undefined& e) { | ||
e.setName(name); | ||
throw e; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching and rethrowing is more costly than the previous version of testing and throwing only once.
/// the current value defined or will the fallback be used? | ||
inline bool defined() const { return !value_.empty(); } | ||
/// is a value defined? | ||
inline bool defined() const { return !(value_.empty() && default_.empty()); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you change the semantics of defined()
!
I guess you want to distinguish isDefined()
from isSet() == hasCurrentValue()
?
Let's discuss the naming over phone...
const boost::any& v{ value() }; | ||
if (v.empty()) | ||
throw Property::undefined(); | ||
return boost::any_cast<const T&>(value()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return boost::any_cast<const T&>(value()); | |
return boost::any_cast<const T&>(v); |
See also my comment on PropertyMap::get()
.
What is the status of this PR ? Would be really useful. I think a lot of people got their own way of dealing with this. BTW this PR needs this patch, void SolutionBase::fillInfo(moveit_task_constructor_msgs::SolutionInfo& info, Introspection* introspection) const {
info.id = introspection ? introspection->solutionId(*this) : 0;
info.cost = this->cost();
info.comment = this->comment();
const Introspection* ci = introspection;
info.stage_id = ci ? ci->stageId(this->creator()) : 0;
// got to add this
creator_->properties().fillMsgs(info.properties);
const auto& markers = this->markers();
info.markers.resize(markers.size());
std::copy(markers.begin(), markers.end(), info.markers.begin());
} to actually print the properties. for (const auto& solution : task->solutions())
{
moveit_task_constructor_msgs::Solution solution_msg;
solution->fillMessage(solution_msg, &task->introspection());
for (const auto& sub_traj : solution_msg.sub_trajectory)
{
std::cout << "==========" << std::endl;
std::cout << "stage_id: " << sub_traj.info.id << std::endl;
auto props = sub_traj.info.properties;
for (moveit_task_constructor_msgs::Property& p : props)
{
std::cout << "name: " << p.name << std::endl;
std::cout << "type: " << p.type << std::endl;
std::cout << "val : " << p.value << std::endl;
std::cout << "---------" << std::endl;
}
}
}
==========
stage_id: 1
name: forwarded_properties
type: St3setINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESt4lessIS5_ESaIS5_EE
val :
---------
name: hey
type: NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
val :
---------
name: ignore_collisions
type: b
val : 0
---------
name: marker_ns
type: NSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
val : current state
---------
name: timeout
type: d
val :
---------
... |
@v4hn Trying to serialize the ros msg control_msgs::GripperCommand controller_goal;
controller_goal.max_effort = 100;
controller_goal.position = robot_state.joint_state.position.front();
stage->setProperty("point", point);
stage->setProperty("controller_goal", controller_goal);
// Prints
name: point
type: geometry_msgs/Vector3Stamped
val : thermal_cycler���Q��?
--------
name: controller_goal
type:
val : |
This interface can be customized by the user to state when/where additional execution hooks should run.
This is an initial thread to discuss/extend this idea as discussed in #192