44 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
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;
124 for (
int i=0; i<1; i++) {
126 std::cout <<
"Try to initialize biclops head " << std::endl;
127 binit = biclops.Initialize(configfile);
131 std::cout <<
"Initialization succeed...\n";
135 std::cout <<
"Initialization failed...\n";
140 std::cout <<
"Initialization failed..."<< std::endl;
145 std::cout <<
"Cannot initialize biclops head. " << std::endl;
146 std::cout <<
"Check if the serial cable is connected." << std::endl;
147 std::cout <<
"Check if the robot is powered on." << std::endl;
148 std::cout <<
"Check if you try to open the good serial port." << std::endl;
149 std::cout <<
"Try to power off/on and restart..." << std::endl;
152 "Cannot initialize biclops head.");
160 panAxis = biclops.GetAxis(Biclops::Pan);
161 tiltAxis = biclops.GetAxis(Biclops::Tilt);
162 if ((axisMask & Biclops::VergeMask) != 0)
163 vergeAxis = biclops.GetAxis(Biclops::Verge);
165 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
166 if (!panAxis -> GetHomedState() || !tiltAxis -> GetHomedState()) {
170 if (!panAxis -> IsAlreadyHomed() || !tiltAxis -> IsAlreadyHomed()) {
176 vpDEBUG_TRACE(12,
"Execute the homing sequence for all axes");
177 vpDEBUG_TRACE(12,
"Execute the homing sequence for all axes");
178 if ( biclops.HomeAxes(axisMask))
183 "Cannot open connexion with biclops");
188 panAxis->GetProfile(panProfile);
189 tiltAxis->GetProfile(tiltProfile);
190 if ((axisMask & Biclops::VergeMask) != 0)
191 vergeAxis->GetProfile(vergeProfile);
211 const double percentVelocity )
217 "Bad dimension for positioning vector.");
220 panAxis -> SetProfileMode(PMDTrapezoidalProfile);
221 tiltAxis -> SetProfileMode(PMDTrapezoidalProfile);
224 PMDUtils::AxisList axisList;
225 axisList.push_back(panAxis);
226 axisList.push_back(tiltAxis);
228 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
230 PMDAxisControl::Profile panProfile,tiltProfile;
231 panAxis->GetProfile(panProfile);
232 tiltAxis->GetProfile(tiltProfile);
237 panProfile.pos = PMDUtils::RadsToRevs(q[0]);
239 * percentVelocity / 100.);
241 tiltProfile.pos = PMDUtils::RadsToRevs(q[1]);
243 * percentVelocity / 100.);
246 panAxis->SetProfile(panProfile);
247 tiltAxis->SetProfile(tiltProfile);
251 PMDAxisControl::CountsProfile desired_profile;
256 panProfile.pos = PMDUtils::RadsToRevs(q[0]);
258 * percentVelocity / 100.);
263 panAxis -> ProfileToCounts(panProfile, desired_profile);
264 vpCDEBUG(12) <<
"desired_profile.pos: " << desired_profile.pos << std::endl;
265 vpCDEBUG(12) <<
"desired_profile.vel: " << desired_profile.vel << std::endl;
267 panAxis -> SetProfile(desired_profile);
272 tiltProfile.pos = PMDUtils::RadsToRevs(q[1]);
274 * percentVelocity / 100.);
276 tiltAxis -> ProfileToCounts(tiltProfile, desired_profile);
277 vpCDEBUG(12) <<
"desired_profile.pos: " << desired_profile.pos << std::endl;
278 vpCDEBUG(12) <<
"desired_profile.vel: " << desired_profile.vel << std::endl;
280 tiltAxis -> SetProfile(desired_profile);
284 PMDUtils::Coordinate(axisList);
285 biclops.Move(Biclops::PanMask + Biclops::TiltMask);
305 "Bad dimension for velocity vector.");
309 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
311 PMDAxisControl::Profile panProfile, tiltProfile;
312 panAxis->GetProfile(panProfile);
313 tiltAxis->GetProfile(tiltProfile);
318 panProfile.vel = PMDUtils::RadsToRevs(q_dot[0]);
319 tiltProfile.vel = PMDUtils::RadsToRevs(q_dot[1]);
322 panAxis->SetProfile(panProfile);
323 tiltAxis->SetProfile(tiltProfile);
325 panAxis -> SetProfileMode(PMDVelocityContouringProfile);
326 tiltAxis -> SetProfileMode(PMDVelocityContouringProfile);
328 panAxis -> SetProfileMode(PMDVelocityContouringProfile);
329 tiltAxis -> SetProfileMode(PMDVelocityContouringProfile);
331 PMDAxisControl::CountsProfile desired_profile;
336 panProfile.vel = PMDUtils::RadsToRevs(q_dot[0]);
338 panAxis -> ProfileToCounts(panProfile, desired_profile);
339 panAxis -> SetProfile(desired_profile);
344 tiltProfile.vel = PMDUtils::RadsToRevs(q_dot[1]);
346 tiltAxis -> ProfileToCounts(tiltProfile, desired_profile);
347 tiltAxis -> SetProfile(desired_profile);
350 biclops.Move(Biclops::PanMask + Biclops::TiltMask, 0);
363 vpDEBUG_TRACE (12,
"Start vpRobotBiclopsController::getPosition() ");
365 PMDint32 panpos, tiltpos;
367 panAxis -> GetPosition(panpos);
368 tiltAxis -> GetPosition(tiltpos);
370 q[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(panpos));
371 q[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tiltpos));
373 vpCDEBUG(11) <<
"++++++++ Mesure : " << q.
t();
374 vpDEBUG_TRACE (12,
"End vpRobotBiclopsController::getPosition()");
390 PMDint32 panpos, tiltpos;
392 panAxis -> GetActualPosition(panpos);
393 tiltAxis -> GetActualPosition(tiltpos);
395 q[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(panpos));
396 q[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tiltpos));
412 PMDint32 pan_vel, tilt_vel;
414 panAxis -> GetVelocity(pan_vel);
415 tiltAxis -> GetVelocity(tilt_vel);
417 q_dot[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(pan_vel));
418 q_dot[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tilt_vel));
434 PMDint32 pan_vel, tilt_vel;
436 panAxis -> GetActualVelocity(pan_vel);
437 tiltAxis -> GetActualVelocity(tilt_vel);
439 q_dot[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(pan_vel));
440 q_dot[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tilt_vel));
457 memcpy(&this->shm, &shm_,
sizeof(shmType));
470 vpRobotBiclopsController::shmType
478 memcpy(&tmp_shm, &this->shm,
sizeof(shmType));
481 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 a 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.