Skip to content
Snippets Groups Projects
Commit 8647e8af authored by Mirko Wächter's avatar Mirko Wächter
Browse files

trajectory doc

parent 80194304
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,10 @@ namespace armarx
* Basic usage:
* @snippet RobotAPI/libraries/core/test/TrajectoryTest.cpp TrajectoryDocumentation BasicUsage
*
* The trajectory offers normal iterator capabilities:
* @snippet RobotAPI/libraries/core/test/TrajectoryTest.cpp TrajectoryDocumentation IteratorUsage
* @note Only const iterators are currently available.
*
* With the iterators it can be used like a std container:
* @snippet RobotAPI/libraries/core/test/TrajectoryTest.cpp TrajectoryDocumentation CopyIf
*/
......@@ -194,6 +198,11 @@ namespace armarx
void removeDerivation(size_t dimension, size_t derivation);
// iterators
/**
* @brief Iterators that iterates in incremental order of the timestamps through the trajectory.
* @note Only const versions are available currently.
* @see end(), rbegin(), rend()
*/
typename ordered_view::const_iterator begin() const;
typename ordered_view::const_iterator end() const;
typename ordered_view::const_reverse_iterator rbegin() const;
......
......@@ -135,6 +135,30 @@ BOOST_AUTO_TEST_CASE(TrajectoryBasicUsage)
//! [TrajectoryDocumentation BasicUsage]
ARMARX_INFO_S << VAROUT(pos) << VAROUT(positions);
}
BOOST_AUTO_TEST_CASE(TrajectoryIteratorUsage)
{
Ice::DoubleSeq myPositionValues{0,5,1}; // fill with your values;
Ice::DoubleSeq timestamps = Trajectory::GenerateTimestamps(0, 1, 1.0/(myPositionValues.size()-1)); // if you dont have timestamps
TrajectoryPtr trajectory(new Trajectory);
trajectory->addDimension(timestamps, myPositionValues, "Shoulder 1 L");
//! [TrajectoryDocumentation IteratorUsage]
Trajectory::ordered_view::iterator it; // or just auto it;
it = trajectory->begin();
for(; it != trajectory->end(); it++)
{
const Trajectory::TrajData& data = *it;
ARMARX_INFO_S << "Position at " << data.getTimestamp() << " :" << data.getPosition(0);
}
// or with c++11 for loop:
for(const Trajectory::TrajData& element : *trajectory)
{
ARMARX_INFO_S << "Position at " << element.getTimestamp() << " :" << element.getPosition(0);
}
//! [TrajectoryDocumentation IteratorUsage]
}
BOOST_AUTO_TEST_CASE(testInplaceDerivation2)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment