40 #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
43 #include <visp3/core/vpConfig.h>
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 #ifdef VISP_HAVE_BICLOPS
49 #include <visp3/robot/vpRobotBiclops.h>
50 #include <visp3/robot/vpRobotBiclopsController.h>
51 #include <visp3/robot/vpRobotException.h>
56 #include <visp3/core/vpDebug.h>
67 vpRobotBiclopsController::vpRobotBiclopsController()
68 : biclops(), axisMask(0), panAxis(NULL), tiltAxis(NULL), vergeAxis(NULL),
69 panProfile(), tiltProfile(), vergeProfile(), shm(), stopControllerThread_(false)
71 axisMask = Biclops::PanMask
79 biclops.SetDebugLevel(0);
86 shm.jointLimit[i] =
false;
96 vpRobotBiclopsController::~vpRobotBiclopsController()
114 vpRobotBiclopsController::init(
const std::string &configfile)
118 for (
int i=0; i<1; i++) {
120 std::cout <<
"Try to initialize biclops head " << std::endl;
121 binit = biclops.Initialize(configfile.c_str());
125 std::cout <<
"Initialization succeed...\n";
129 std::cout <<
"Initialization failed...\n";
134 std::cout <<
"Initialization failed..."<< std::endl;
139 std::cout <<
"Cannot initialize biclops head. " << std::endl;
140 std::cout <<
"Check if the serial cable is connected." << std::endl;
141 std::cout <<
"Check if the robot is powered on." << std::endl;
142 std::cout <<
"Check if you try to open the good serial port." << std::endl;
143 std::cout <<
"Try to power off/on and restart..." << std::endl;
146 "Cannot initialize biclops head.");
154 panAxis = biclops.GetAxis(Biclops::Pan);
155 tiltAxis = biclops.GetAxis(Biclops::Tilt);
156 if ((axisMask & Biclops::VergeMask) != 0)
157 vergeAxis = biclops.GetAxis(Biclops::Verge);
159 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
160 if (!panAxis -> GetHomedState() || !tiltAxis -> GetHomedState()) {
164 if (!panAxis -> IsAlreadyHomed() || !tiltAxis -> IsAlreadyHomed()) {
170 vpDEBUG_TRACE(12,
"Execute the homing sequence for all axes");
171 vpDEBUG_TRACE(12,
"Execute the homing sequence for all axes");
172 if ( biclops.HomeAxes(axisMask))
177 "Cannot open connection with biclops");
182 panAxis->GetProfile(panProfile);
183 tiltAxis->GetProfile(tiltProfile);
184 if ((axisMask & Biclops::VergeMask) != 0)
185 vergeAxis->GetProfile(vergeProfile);
204 vpRobotBiclopsController::setPosition(
const vpColVector & q,
205 const double percentVelocity )
211 "Bad dimension for positioning vector.");
214 panAxis -> SetProfileMode(PMDTrapezoidalProfile);
215 tiltAxis -> SetProfileMode(PMDTrapezoidalProfile);
218 PMDUtils::AxisList axisList;
219 axisList.push_back(panAxis);
220 axisList.push_back(tiltAxis);
222 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
225 panAxis->GetProfile(panProfile);
226 tiltAxis->GetProfile(tiltProfile);
231 panProfile.pos = PMDUtils::RadsToRevs(q[0]);
233 * percentVelocity / 100.);
235 tiltProfile.pos = PMDUtils::RadsToRevs(q[1]);
237 * percentVelocity / 100.);
240 panAxis->SetProfile(panProfile);
241 tiltAxis->SetProfile(tiltProfile);
245 PMDAxisControl::CountsProfile desired_profile;
250 panProfile.pos = PMDUtils::RadsToRevs(q[0]);
252 * percentVelocity / 100.);
257 panAxis -> ProfileToCounts(panProfile, desired_profile);
258 vpCDEBUG(12) <<
"desired_profile.pos: " << desired_profile.pos << std::endl;
259 vpCDEBUG(12) <<
"desired_profile.vel: " << desired_profile.vel << std::endl;
261 panAxis -> SetProfile(desired_profile);
266 tiltProfile.pos = PMDUtils::RadsToRevs(q[1]);
268 * percentVelocity / 100.);
270 tiltAxis -> ProfileToCounts(tiltProfile, desired_profile);
271 vpCDEBUG(12) <<
"desired_profile.pos: " << desired_profile.pos << std::endl;
272 vpCDEBUG(12) <<
"desired_profile.vel: " << desired_profile.vel << std::endl;
274 tiltAxis -> SetProfile(desired_profile);
278 PMDUtils::Coordinate(axisList);
279 biclops.Move(Biclops::PanMask + Biclops::TiltMask);
293 vpRobotBiclopsController::setVelocity(
const vpColVector & q_dot)
299 "Bad dimension for velocity vector.");
303 #ifdef VISP_HAVE_BICLOPS_AND_GET_HOMED_STATE_FUNCTION // new API
306 panAxis->GetProfile(panProfile);
307 tiltAxis->GetProfile(tiltProfile);
312 panProfile.vel = PMDUtils::RadsToRevs(q_dot[0]);
313 tiltProfile.vel = PMDUtils::RadsToRevs(q_dot[1]);
316 panAxis->SetProfile(panProfile);
317 tiltAxis->SetProfile(tiltProfile);
319 panAxis -> SetProfileMode(PMDVelocityContouringProfile);
320 tiltAxis -> SetProfileMode(PMDVelocityContouringProfile);
322 panAxis -> SetProfileMode(PMDVelocityContouringProfile);
323 tiltAxis -> SetProfileMode(PMDVelocityContouringProfile);
325 PMDAxisControl::CountsProfile desired_profile;
330 panProfile.vel = PMDUtils::RadsToRevs(q_dot[0]);
332 panAxis -> ProfileToCounts(panProfile, desired_profile);
333 panAxis -> SetProfile(desired_profile);
338 tiltProfile.vel = PMDUtils::RadsToRevs(q_dot[1]);
340 tiltAxis -> ProfileToCounts(tiltProfile, desired_profile);
341 tiltAxis -> SetProfile(desired_profile);
344 biclops.Move(Biclops::PanMask + Biclops::TiltMask, 0);
355 vpRobotBiclopsController::getPosition()
357 vpDEBUG_TRACE (12,
"Start vpRobotBiclopsController::getPosition() ");
359 PMDint32 panpos, tiltpos;
361 panAxis -> GetPosition(panpos);
362 tiltAxis -> GetPosition(tiltpos);
364 q[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(panpos));
365 q[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tiltpos));
367 vpCDEBUG(11) <<
"++++++++ Mesure : " << q.
t();
368 vpDEBUG_TRACE (12,
"End vpRobotBiclopsController::getPosition()");
381 vpRobotBiclopsController::getActualPosition()
384 PMDint32 panpos, tiltpos;
386 panAxis -> GetActualPosition(panpos);
387 tiltAxis -> GetActualPosition(tiltpos);
389 q[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(panpos));
390 q[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tiltpos));
403 vpRobotBiclopsController::getVelocity()
406 PMDint32 pan_vel, tilt_vel;
408 panAxis -> GetVelocity(pan_vel);
409 tiltAxis -> GetVelocity(tilt_vel);
411 q_dot[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(pan_vel));
412 q_dot[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tilt_vel));
425 vpRobotBiclopsController::getActualVelocity()
428 PMDint32 pan_vel, tilt_vel;
430 panAxis -> GetActualVelocity(pan_vel);
431 tiltAxis -> GetActualVelocity(tilt_vel);
433 q_dot[0] = PMDUtils::RevsToRads(panAxis ->CountsToUnits(pan_vel));
434 q_dot[1] = PMDUtils::RevsToRads(tiltAxis->CountsToUnits(tilt_vel));
446 vpRobotBiclopsController::writeShm(shmType &shm_)
451 memcpy(&this->shm, &shm_,
sizeof(shmType));
464 vpRobotBiclopsController::shmType
465 vpRobotBiclopsController::readShm()
472 memcpy(&tmp_shm, &this->shm,
sizeof(shmType));
475 vpDEBUG_TRACE(13,
"tmp_shm.q_dot[%d]=%f", i, tmp_shm.q_dot[i]);
481 #elif !defined(VISP_BUILD_SHARED_LIBS)
483 void dummy_vpRobotBiclopsController() {};
486 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
Error that can be emited by the vpRobot class and its derivates.
static const unsigned int ndof
static const float speedLimit
unsigned int getRows() const
Return the number of rows of the 2D array.
Implementation of column vector and the associated operations.