47 #include <visp/vpConfig.h>
49 #ifdef VISP_HAVE_BICLOPS
52 #include <visp/vpRobotBiclops.h>
53 #include <visp/vpRobotBiclopsController.h>
54 #include <visp/vpRobotException.h>
59 #include <visp/vpDebug.h>
72 stopControllerThread_ =
false;
73 axisMask = Biclops::PanMask
84 biclops.SetDebugLevel(0);
91 shm.jointLimit[i] =
false;
123 for (
int i=0; i<1; i++) {
125 std::cout <<
"Try to initialize biclops head " << std::endl;
126 binit = biclops.Initialize(configfile);
130 std::cout <<
"Initialization succeed...\n";
134 std::cout <<
"Initialization failed...\n";
139 std::cout <<
"Initialization failed..."<< std::endl;
144 std::cout <<
"Cannot initialize biclops head. " << std::endl;
145 std::cout <<
"Check if the serial cable is connected." << std::endl;
146 std::cout <<
"Check if the robot is powered on." << std::endl;
147 std::cout <<
"Check if you try to open the good serial port." << std::endl;
148 std::cout <<
"Try to power off/on and restart..." << std::endl;
151 "Cannot initialize biclops head.");
159 panAxis = biclops.GetAxis(Biclops::Pan);
160 tiltAxis = biclops.GetAxis(Biclops::Tilt);
161 if ((axisMask & Biclops::VergeMask) != 0)
162 vergeAxis = biclops.GetAxis(Biclops::Verge);
164 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
165 if (!panAxis -> GetHomedState() || !tiltAxis -> GetHomedState()) {
169 if (!panAxis -> IsAlreadyHomed() || !tiltAxis -> IsAlreadyHomed()) {
175 vpDEBUG_TRACE(12,
"Execute the homing sequence for all axes");
176 vpDEBUG_TRACE(12,
"Execute the homing sequence for all axes");
177 if ( biclops.HomeAxes(axisMask))
182 "Cannot open connexion with biclops");
187 panAxis->GetProfile(panProfile);
188 tiltAxis->GetProfile(tiltProfile);
189 if ((axisMask & Biclops::VergeMask) != 0)
190 vergeAxis->GetProfile(vergeProfile);
210 const double percentVelocity )
216 "Bad dimension for positioning vector.");
219 panAxis -> SetProfileMode(PMDTrapezoidalProfile);
220 tiltAxis -> SetProfileMode(PMDTrapezoidalProfile);
223 PMDUtils::AxisList axisList;
224 axisList.push_back(panAxis);
225 axisList.push_back(tiltAxis);
227 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
229 PMDAxisControl::Profile panProfile,tiltProfile;
230 panAxis->GetProfile(panProfile);
231 tiltAxis->GetProfile(tiltProfile);
236 panProfile.pos = PMDUtils::RadsToRevs(q[0]);
238 * percentVelocity / 100.);
240 tiltProfile.pos = PMDUtils::RadsToRevs(q[1]);
242 * percentVelocity / 100.);
245 panAxis->SetProfile(panProfile);
246 tiltAxis->SetProfile(tiltProfile);
250 PMDAxisControl::CountsProfile desired_profile;
255 panProfile.pos = PMDUtils::RadsToRevs(q[0]);
257 * percentVelocity / 100.);
262 panAxis -> ProfileToCounts(panProfile, desired_profile);
263 vpCDEBUG(12) <<
"desired_profile.pos: " << desired_profile.pos << std::endl;
264 vpCDEBUG(12) <<
"desired_profile.vel: " << desired_profile.vel << std::endl;
266 panAxis -> SetProfile(desired_profile);
271 tiltProfile.pos = PMDUtils::RadsToRevs(q[1]);
273 * percentVelocity / 100.);
275 tiltAxis -> ProfileToCounts(tiltProfile, desired_profile);
276 vpCDEBUG(12) <<
"desired_profile.pos: " << desired_profile.pos << std::endl;
277 vpCDEBUG(12) <<
"desired_profile.vel: " << desired_profile.vel << std::endl;
279 tiltAxis -> SetProfile(desired_profile);
283 PMDUtils::Coordinate(axisList);
284 biclops.Move(Biclops::PanMask + Biclops::TiltMask);
304 "Bad dimension for velocity vector.");
308 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
310 PMDAxisControl::Profile panProfile, tiltProfile;
311 panAxis->GetProfile(panProfile);
312 tiltAxis->GetProfile(tiltProfile);
317 panProfile.vel = PMDUtils::RadsToRevs(q_dot[0]);
318 tiltProfile.vel = PMDUtils::RadsToRevs(q_dot[1]);
321 panAxis->SetProfile(panProfile);
322 tiltAxis->SetProfile(tiltProfile);
324 panAxis -> SetProfileMode(PMDVelocityContouringProfile);
325 tiltAxis -> SetProfileMode(PMDVelocityContouringProfile);
327 panAxis -> SetProfileMode(PMDVelocityContouringProfile);
328 tiltAxis -> SetProfileMode(PMDVelocityContouringProfile);
330 PMDAxisControl::CountsProfile desired_profile;
335 panProfile.vel = PMDUtils::RadsToRevs(q_dot[0]);
337 panAxis -> ProfileToCounts(panProfile, desired_profile);
338 panAxis -> SetProfile(desired_profile);
343 tiltProfile.vel = PMDUtils::RadsToRevs(q_dot[1]);
345 tiltAxis -> ProfileToCounts(tiltProfile, desired_profile);
346 tiltAxis -> SetProfile(desired_profile);
349 biclops.Move(Biclops::PanMask + Biclops::TiltMask, 0);
362 vpDEBUG_TRACE (12,
"Start vpRobotBiclopsController::getPosition() ");
364 PMDint32 panpos, tiltpos;
366 panAxis -> GetPosition(panpos);
367 tiltAxis -> GetPosition(tiltpos);
369 q[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(panpos));
370 q[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tiltpos));
372 vpCDEBUG(11) <<
"++++++++ Mesure : " << q.
t();
373 vpDEBUG_TRACE (12,
"End vpRobotBiclopsController::getPosition()");
389 PMDint32 panpos, tiltpos;
391 panAxis -> GetActualPosition(panpos);
392 tiltAxis -> GetActualPosition(tiltpos);
394 q[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(panpos));
395 q[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tiltpos));
411 PMDint32 pan_vel, tilt_vel;
413 panAxis -> GetVelocity(pan_vel);
414 tiltAxis -> GetVelocity(tilt_vel);
416 q_dot[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(pan_vel));
417 q_dot[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tilt_vel));
433 PMDint32 pan_vel, tilt_vel;
435 panAxis -> GetActualVelocity(pan_vel);
436 tiltAxis -> GetActualVelocity(tilt_vel);
438 q_dot[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(pan_vel));
439 q_dot[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tilt_vel));
456 memcpy(&this->shm, &shm_,
sizeof(shmType));
469 vpRobotBiclopsController::shmType
477 memcpy(&tmp_shm, &this->shm,
sizeof(shmType));
480 vpDEBUG_TRACE(13,
"tmp_shm.q_dot[%d]=%f", i, tmp_shm.q_dot[i]);
void setVelocity(const vpColVector &q_dot)
vpColVector getPosition()
Error that can be emited by the vpRobot class and its derivates.
static const unsigned int ndof
static const float speedLimit
vpColVector getActualVelocity()
virtual ~vpRobotBiclopsController()
void writeShm(shmType &shm)
vpColVector getVelocity()
vpRobotBiclopsController()
void init(const char *configfile)
void setPosition(const vpColVector &q, const double percentVelocity)
vpRowVector t() const
transpose of Vector
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpColVector getActualPosition()
unsigned int getRows() const
Return the number of rows of the matrix.