Commit 6e411599 authored by Gabriele Buondonno's avatar Gabriele Buondonno
Browse files

[nd-trajectory-generator] set

parent aaf07391
......@@ -105,6 +105,12 @@ namespace dynamicgraph {
*/
void move(const int& id, const double& xFinal, const double& time);
/** Instantaneously set a component to a given position.
* @param id integer index.
* @param xVal The desired position of the component.
*/
void set(const int& id, const double& xVal);
/** Start an infinite sinusoidal trajectory.
* @param id integer index.
* @param xFinal The position of the component corresponding to the max amplitude of the sinusoid.
......
......@@ -127,6 +127,11 @@ namespace dynamicgraph
"(int) index",
"(double) final values",
"(double) time to reach the final value in sec")));
addCommand("set",
makeCommandVoid2(*this, &NdTrajectoryGenerator::set,
docCommandVoid2("Instantaneously set component corresponding to index to the specified value.",
"(int) index",
"(double) desired value")));
addCommand("stop",
makeCommandVoid1(*this, &NdTrajectoryGenerator::stop,
docCommandVoid1("Stop the motion of the specified index, or of all components of the vector if index is equal to -1.",
......@@ -610,6 +615,23 @@ namespace dynamicgraph
m_t = 0.0;
}
void NdTrajectoryGenerator::set(const int& id, const double& xVal)
{
if(!m_initSucceeded)
return SEND_MSG("Cannot set value before initialization!",MSG_TYPE_ERROR);
unsigned int i = id;
if(id<0 || id>=static_cast<int>(m_n))
return SEND_MSG("Index is out of bounds", MSG_TYPE_ERROR);
if(m_status[i]!=JTG_STOP)
return SEND_MSG("You cannot set the specified component because it is already controlled.", MSG_TYPE_ERROR);
m_noTrajGen[i]->setInitialPoint(xVal);
// m_status[i] = JTG_STOP;
// m_splineReady = false;
// m_currentTrajGen[i] = m_noTrajGen[i];
// m_t = 0.0;
}
void NdTrajectoryGenerator::stop(const int& id)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment