file.cpp
Go to the documentation of this file.
1 
10 #include <ctrl/file.hpp>
11 
12 
13 // Cf Controller::chooseVelocities(...)
14 void FileCtrl::chooseVelocities(double& trans_vel, double& rot_vel,
15  std::ostream& log_str) {
16  static double remain_dur = 0, duration, moving_acc, turning_acc;
17  if ( inputOK() ) { // only works if input file is OK
18  // when needed, get new accelerations from file
19  if ( remain_dur < timeStep() ) {
20  // read new line in input stream
21  *input >> duration >> moving_acc >> turning_acc;
22  if ( inputEnded() ) // stop at the end of file
23  { moving_acc = turning_acc = 0; duration = 10; }
24  remain_dur += duration;
25  } // apply accelerations during time step to fin future velocities
28  moving_acc, turning_acc, time_step);
29  /* log when needed
30  log_str << "+(" << moving_acc << ", " << turning_acc
31  << ", " << time_step << "/" << remain_dur << ")"; */
32  // set velocities
33  updateVelocities(trans_vel, rot_vel);
34  remain_dur -= timeStep(); // decrease remaining time
35  } // end of if (input OK)
36 } // end of void FileCtrl::chooseVelocities(double&, double&, ...) ---
bool inputEnded() const
Is the input stream at its end?
Definition: file.hpp:36
File controller (teleoperation) class.
const double time_step
The time step of the controller.
Definition: controller.hpp:39
void chooseVelocities(double &trans_vel, double &rot_vel, std::ostream &log_str)
Computes new velocities for ROS node.
Definition: file.cpp:14
double moving_velocity
Translation velocity desired for the robot.
Definition: controller.hpp:45
bool inputOK() const
Is the input stream OK for reading?
Definition: file.hpp:31
void updateVelocities(double &trans_vel, double &rot_vel)
Update the velocities from the fields and send the update signal.
Definition: controller.hpp:66
const MotionModel & motion_model
The model of the motion.
Definition: controller.hpp:36
void applyAccelerations(double &trans_vel, double &rot_vel, const double &trans_acc, const double &rot_acc, const double &time_step) const
Modify translation and rotation given velocities, applying the given accelerations during the given t...
Definition: motion.cpp:129
const double & timeStep() const
Stops the robot (i.e. sets both velocities to zero).
Definition: controller.hpp:88
double turning_velocity
Rotation velocity desired for the robot.
Definition: controller.hpp:47
std::ifstream * input
The input stream, if any.
Definition: file.hpp:27


qt_ctrl
Author(s): Alexis Scheuer
autogenerated on Wed Dec 16 2020 15:51:32