gusimplewhiteboard
WEBOTS_NXT_bridge.hpp
Go to the documentation of this file.
1/*
2 * WEBOTS_NXT_bridge.h
3 *
4 * Created by Vald Estivill-Castro on 25/10/13.
5 * Copyright (c) 2013 Rene Hexel. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials
17 * provided with the distribution.
18 *
19 * 3. All advertising materials mentioning features or use of this
20 * software must display the following acknowledgement:
21 *
22 * This product includes software developed by Rene Hexel.
23 *
24 * 4. Neither the name of the author nor the names of contributors
25 * may be used to endorse or promote products derived from this
26 * software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * -----------------------------------------------------------------------
41 * This program is free software; you can redistribute it and/or
42 * modify it under the above terms or under the terms of the GNU
43 * General Public License as published by the Free Software Foundation;
44 * either version 2 of the License, or (at your option) any later version.
45 *
46 * This program is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 * GNU General Public License for more details.
50 *
51 * You should have received a copy of the GNU General Public License
52 * along with this program; if not, see http://www.gnu.org/licenses/
53 * or write to the Free Software Foundation, Inc., 51 Franklin Street,
54 * Fifth Floor, Boston, MA 02110-1301, USA.
55 *
56 */
57#ifndef WEBOTS_NXT_bridge_DEFINED
58#define WEBOTS_NXT_bridge_DEFINED
59#define WEBOTS_NXT_encoders_DEFINED
60#define WEBOTS_NXT_bumper_DEFINED
61#define WEBOTS_NXT_camera_DEFINED
62#define WEBOTS_NXT_deadReakoning_walk_DEFINED
63#define WEBOTS_NXT_walk_isRunning_DEFINED
64#define WEBOTS_NXT_colorLine_walk_DEFINED
65#define WEBOTS_NXT_gridMotions_DEFINED
66#define WEBOTS_NXT_vector_bridge_DEFINED
67
68#pragma clang diagnostic push
69#pragma clang diagnostic ignored "-Wpadded"
70
71#include <cstdlib>
72#include <sstream>
73#include <gu_util.h>
74
75const char OBJECT_SEPARATOR = '|';
76const char FIELD_SERPARATOR = ',';
77const char EQUALS = '=';
78
79namespace guWhiteboard
80{
86 NXT_MOTOR3 = 2 //constant for the third motor on nxt's
87 };
88
91 static const char* MotorStrings[] = {
92 "LEFT_MOTOR",
93 "RIGHT_MOTOR",
94 "NXT_MOTOR3"
95 };
96
102 };
103
106 static const char* SoundStrings[] = {
107 "SOUND_DURATION",
108 "SOUND_FREQUENCY"
109 };
110
116 };
117
123 };
124
130 NXT_NUM_SENSORS_IN_BUMBER = 2 //constant for the total number of sensors in the nxt's bumper
131 };
132
139 NXT_PORT_4 = 3
140 };
141
149 };
150
154 // ACTUATORS
155 MOVE_MOTORS = 0, // Sets the left and right motor speeds
156 ONE_MOTOR_SETTING = 1, // Allows setting motor speed for a single motor
159 // SENSORS
163 CAMERA = 7, // Each colour channel can be turned On or Off individually, or the frame data read
164 TOUCH = 8,
165 NUMBER_WEBOTS_NXT_bridge_MESSAGES// no value assigned to allow for additional instructions later
166 };
167
174 };
175#if 0 // not used so far: compiler is complaining (put back in when actually used)
176static const char* Commands[] = {"MOVE_MOTORS", "ONE_MOTOR_SETTING", "PLAY_SOUND", "LIGHTUP_LED",
177 "START_DISTANCE", "START_INTENSITY_LIGHT", "START_ROTATION_ENCODER",
178 "START_CAMERA", "START_TOUCH", "Undefined"};
179#endif
180
181
187 public:
188
192 PROPERTY(int16_t, theRobotID)
196 PROPERTY(int16_t, speedLeftMotor)
200 PROPERTY(int16_t, speedRightMotor)
204 PROPERTY(int16_t, soundFrequency)
208 PROPERTY(int16_t, soundDuration)
209
210 WEBOTS_NXT_vector_bridge() { memset(this, 0, sizeof(*this)); } // setting everything empty in the constructor
211
213 WEBOTS_NXT_vector_bridge(const std::string &names) { from_string(names); }
214
217 _theRobotID(other._theRobotID),
218 _speedLeftMotor(other._speedLeftMotor),
219 _speedRightMotor(other._speedRightMotor),
220 _soundFrequency(other._soundFrequency),
221 _soundDuration(other._soundDuration) {}
222
225 _theRobotID = other._theRobotID;
226 _speedLeftMotor = other._speedLeftMotor;
227 _speedRightMotor = other._speedRightMotor;
228 _soundFrequency = other._soundFrequency;
229 _soundDuration = other._soundDuration;
230 return *this;
231 }
232
234 std::string description() const {
235 std::ostringstream ss;
236 ss<< _theRobotID << FIELD_SERPARATOR;
237 // attempt to make it that the order does not matter
238 ss << MotorStrings[LEFT_MOTOR_DIFFERENTIAL] << EQUALS << _speedLeftMotor << FIELD_SERPARATOR;
239 ss << MotorStrings[RIGHT_MOTOR_DIFFERENTIAL] << EQUALS << _speedRightMotor << FIELD_SERPARATOR;
240 ss << SoundStrings[SOUND_FREQUENCY] << EQUALS << _soundFrequency << FIELD_SERPARATOR;
241 ss << SoundStrings[SOUND_DURATION] << EQUALS << _soundDuration << FIELD_SERPARATOR;
242 return ss.str();
243 }
244
246 void from_string(const std::string &strWithID) {
247 // can parse the input , set all default values
248 set_theRobotID(0);
249 set_speedLeftMotor(0);
250 set_speedRightMotor(0);
251 set_soundFrequency(0);
252 set_soundDuration(0);
253 std::istringstream iss(strWithID);
254 std::string token;
255 if (getline(iss, token, FIELD_SERPARATOR)) {
256 int16_t numberForID = int16_t ( atoi(token.c_str())) ; // Robots id are 0,1,2 .....
257 if (numberForID <0) set_theRobotID(-numberForID); else set_theRobotID(numberForID);
258 std::string comaDel (1,FIELD_SERPARATOR);
259 std::size_t found = strWithID.find(comaDel);
260 if (std::string::npos!=found ) {
261 std::string str=strWithID.substr (found+comaDel.size());
262 // string without the Robot ID
263 std::istringstream second_iss(str);
264 // lest find pairs where the token is property=value,
265 while (getline(second_iss, token, FIELD_SERPARATOR)) {
266 std::size_t postionEQUALS= token.find(EQUALS);
267
268 if ( (std::string::npos!=token.find(MotorStrings[LEFT_MOTOR_DIFFERENTIAL]) )
269 && (std::string::npos!=postionEQUALS) )
270 { std::string theValue = token.substr (postionEQUALS+1,token.size() );
271 set_speedLeftMotor( static_cast<int16_t>(atoi (theValue.c_str()) ));
272 }
273
274 if ( (std::string::npos!=token.find(MotorStrings[RIGHT_MOTOR_DIFFERENTIAL]) )
275 && (std::string::npos!=postionEQUALS) )
276 { std::string theValue = token.substr (postionEQUALS+1,token.size() );
277 set_speedRightMotor(static_cast<int16_t>(atoi (theValue.c_str()) ));
278 }
279
280 if ( (std::string::npos!=token.find(SoundStrings[SOUND_FREQUENCY]) )
281 && (std::string::npos!=postionEQUALS) )
282 { std::string theValue = token.substr (postionEQUALS+1,token.size() );
283 set_soundFrequency(static_cast<int16_t>( atoi (theValue.c_str()) ));
284 }
285
286 if ( (std::string::npos!=token.find(SoundStrings[SOUND_DURATION]) )
287 && (std::string::npos!=postionEQUALS) )
288 { std::string theValue = token.substr (postionEQUALS+1,token.size() );
289 set_soundDuration(static_cast<int16_t>( atoi (theValue.c_str()) ));
290 }
291
292 // find next comma in the string
293 found = str.find(comaDel);
294 if (std::string::npos!=found ) { // a comma is found
295 std::string newstr=str.substr (found+comaDel.size());
296 second_iss.str(newstr);
297 //move the string along
298 str=str.substr (found+comaDel.size());
299 }
300 }
301 }
302 }
303 }
304
312 void set_actuator(DifferentialInstructions theActuator,int16_t firstParameter,int16_t secondParameter) {
313 SoundDiscriminators theInstructionModality =static_cast<SoundDiscriminators>( firstParameter);
314
315 switch (theActuator) {
316 case MOVE_MOTORS :
317 break;
319 break;
320 case PLAY_SOUND:
321 switch (theInstructionModality) {
322 case SOUND_DURATION: set_soundDuration(secondParameter );
323 break;
324 case SOUND_FREQUENCY : set_soundFrequency(secondParameter );
325 break;
326 }
327 break;
328 case LIGHTUP_LED:
329 break;
330 case DISTANCE:
331 break;
332 case INTENSITY_LIGHT:
333 break;
334 case ROTATION_ENCODER:
335 break;
336 case CAMERA:
337 break;
338 case TOUCH:
339 break;
341 break;
342 }
343 }
344 };
345
346
354 PROPERTY(int16_t, theRobotID)
356 PROPERTY(DifferentialInstructions, theInstruction)
358 PROPERTY(int16_t, firstParameter)
360 PROPERTY(int16_t, secondParameter)
362 PROPERTY(bool, isSensorData)
363
364 public:
365
367 WEBOTS_NXT_bridge(int16_t theRobotID =0 ,DifferentialInstructions theInstruction = MOVE_MOTORS, int16_t firstParameter = 0, int16_t secondParameter=0, bool isSensorData =false): _theRobotID(theRobotID), _theInstruction(theInstruction), _firstParameter(firstParameter), _secondParameter(secondParameter), _isSensorData(isSensorData) { /* better than set_x(x); set_y(y) */ }
368
370 WEBOTS_NXT_bridge(const std::string &names) { from_string(names); }
371
373 WEBOTS_NXT_bridge(const WEBOTS_NXT_bridge &other): _theRobotID(other._theRobotID), _theInstruction(other._theInstruction), _firstParameter(other._firstParameter), _secondParameter(other._secondParameter), _isSensorData(other._isSensorData) {}
374
376 WEBOTS_NXT_bridge &operator=(const WEBOTS_NXT_bridge &other) { _theRobotID = other._theRobotID; _theInstruction = other._theInstruction; _firstParameter = other._firstParameter; _secondParameter = other._secondParameter;_isSensorData = other._isSensorData; return *this; }
377
379 std::string description() const {
380 std::ostringstream ss;
381 ss<< _theRobotID << FIELD_SERPARATOR;
382 if (_isSensorData) {
383 switch(_theInstruction) {
384 case ROTATION_ENCODER :
385 ss << "SENSOR"<<"ROTATION_ENCODER" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
386 break;
387 case INTENSITY_LIGHT :
388 ss << "SENSOR"<<"INTENSITY_LIGHT" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
389 break;
390 case DISTANCE :
391 ss << "SENSOR"<< "DISTANCE" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
392 break;
393 // as a sensor first parameter is total pixele sof color, second parameter is middle of the color
394 case CAMERA :
395 ss << "SENSOR"<< "CAMERA" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
396 break;
397 case TOUCH :
398 ss << "SENSOR"<< "TOUCH" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
399 break;
400 case MOVE_MOTORS:
402 case PLAY_SOUND:
403 case LIGHTUP_LED: //std::cerr << "LOG-error ** This shoudl not hold data" << std::endl;
405 break;
406 }
407 } else {
408 switch(_theInstruction) {
409 case MOVE_MOTORS :
410 /*
411 * Apply power=_firstParameter to LEFT MOTOR
412 * Apply power=_secondParameter to RIGHT MOTOR
413 */
414 ss << "MOVE_MOTORS" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
415 break;
416 case ONE_MOTOR_SETTING :
417 /*
418 * Set the motor in _firstParameter, to the power in the second parameter without
419 * affecting the other motors
420 */
421 ss << "ONE_MOTOR_SETTING" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR;
422 break;
423 case PLAY_SOUND :
424 /*
425 * Play sound for as long as _firstParameter, use second parameter as NXT frequency
426 */
427 ss << "PLAY_SOUND" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR;
428 break;
429 case LIGHTUP_LED :
430 /*
431 * LIGHTUP_LED if 0<> _firstParameter
432 */
433 ss << "LIGHTUP_LED" << "," << ((0!=_firstParameter)? 1: 0) << OBJECT_SEPARATOR;
434 break;
435 case DISTANCE :
436 /*
437 * Start posting Distance from SOnar in potrt _firstParameter if 0<> _secondParameter
438 * Stop posting Distance from SOnar in potrt _firstParameter if 0== _secondParameter
439 */
440 ss << "DISTANCE" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
441 break;
442 case INTENSITY_LIGHT :
443 /*
444 * Start posting light measurement from light sensor in port _firstParameter if 0<> _secondParameter
445 * Stop posting lisght measurement from light in port _firstParameter if 0== _secondParameter
446 */
447 ss << "INTENSITY_LIGHT" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
448 break;
449 case ROTATION_ENCODER :
450 /*
451 * Start posting rotations from encoder in port _firstParameter if 0<> _secondParameter
452 * Stop posting rotations from encoder in port _firstParameter if 0== _secondParameter
453 */
454 ss << "ROTATION_ENCODER" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
455 break;
456 case CAMERA :
457 /*
458 * Start posting from camera, the first paramer is the color channel
459 * the second aprameter is a threshold to comapre how many pixels have intensity abvoe the threshoold
460 * Stop posting for color channel in first aprameter if 0==_secondParameter
461 */
462 ss << "CAMERA" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
463 break;
464 case TOUCH :
465 /*
466 * Start posting wether the touch sensor in port _firstParameter is pressed, if 0<> _secondParameter
467 * Stop posting wether the touch sensor in port _firstParameter is pressed, if 0== _secondParameter
468 */
469 ss << "TOUCH" << "," << _firstParameter << "," << _secondParameter << OBJECT_SEPARATOR ;
470 break;
472 break;
473 }
474 }
475 return ss.str();
476 }
477
479 void from_string(const std::string &strWithID) {
480 std::istringstream iss(strWithID);
481 std::string token;
482 if (getline(iss, token, FIELD_SERPARATOR)) {
483 int16_t numberForID = int16_t ( atoi(token.c_str())) ;
484 // Robots id are 0,1,2 .....
485 if (numberForID <0) set_theRobotID(-numberForID); else set_theRobotID(numberForID);
486 std::string comaDel (",");
487 std::size_t found = strWithID.find(comaDel);
488 if (std::string::npos!=found ) {
489 std::string str=strWithID.substr (found+comaDel.size());
490 // string without the Robot ID
491 std::istringstream second_iss(str);
492 if (getline(second_iss, token, FIELD_SERPARATOR)) {
493 set_firstParameter(0);
494 set_secondParameter(0);
495 set_isSensorData(false);
496 std::string sensorStr ("SENSOR");
497 switch (token[0]) {
498 case 'M' : // expect a MOVE_MOTORS
499 case 'm' :
500 case 'o' :
501 case 'O' : // expect a ONE_MOTOR_SETTING
502 case 'p' :
503 case 'P' : // expect a PLAY_SOUND
504 case 'l' :
505 case 'L' : // expect a LIGHTUP_LED
506 case 'd' :
507 case 'D' : // expect a DISTANCE
508 case 't' :
509 case 'T' : // expect a TOUCH sensor on/off instruction
510 case 'i' :
511 case 'I' : // expect a INTENSITY_LIGHT
512 case 'r' :
513 case 'R' : // expect a ROTATION_ENCODER
514 case 'c' :
515 case 'C' : // expect a ROTATION_ENCODER
516 instruction_from_string ( str );
517 break;
518 case 's' :
519 case 'S' : // expect SENSOR data
520 //std:: cerr<< "Sensor data detected " << std:: endl;
521 set_isSensorData(true);
522 // remove the prefix SENSOR
523 found = str.find(sensorStr);
524 if (std::string::npos!=found ) {
525 std::string strWithoutPrefix =str.substr (found+sensorStr.size());
526 measurement_from_string ( strWithoutPrefix );
527 }
528 break;
529 }
530 }
531 }
532 }
533 }
534
535 private :
536 /*
537 * Extract the First parameter as an NXT in port
538 * the second parameter as a binary {0,1} value
539 */
540 void set_parameters2ndBinary ( const std::string &str ) {
541 std::istringstream iss(str);
542 std::string token;
543 // advance the token
544 getline(iss, token, FIELD_SERPARATOR);
545 if (getline(iss, token, FIELD_SERPARATOR)) {
546 int16_t value = int16_t ( atoi(token.c_str())) ;
547 if (NXT_PORT_1 <= value && value <= NXT_PORT_4)
548 set_firstParameter(value);
549 else
550 set_firstParameter(NXT_PORT_1);
551 }
552 if (getline(iss, token, FIELD_SERPARATOR)) {
553 set_secondParameter(int16_t( (0== atoi(token.c_str())? 0 :1 ) ));
554 }
555 }
556
557 void set_parameters2ndNum ( const std::string &str ) {
558 std::istringstream iss(str);
559 std::string token;
560 // advance the token
561 getline(iss, token, FIELD_SERPARATOR);
562 if (getline(iss, token, FIELD_SERPARATOR)) {
563 int16_t value = int16_t ( atoi(token.c_str())) ;
564 if (NXT_PORT_1 <= value && value <= NXT_PORT_4)
565 set_firstParameter(value);
566 else
567 set_firstParameter(NXT_PORT_1);
568 }
569 if (getline(iss, token, FIELD_SERPARATOR)) {
570 set_secondParameter(int16_t( atoi(token.c_str()) ));
571 }
572 }
573
574 void set_parametersCamera ( const std::string &str ) {
575 std::istringstream iss(str);
576 std::string token;
577 // advance the token
578 getline(iss, token, FIELD_SERPARATOR);
579 if (getline(iss, token, FIELD_SERPARATOR)) {
580 int16_t value = int16_t ( atoi(token.c_str())) ;
581 set_firstParameter(value);
582 }
583 if (getline(iss, token, FIELD_SERPARATOR)) {
584 set_secondParameter(int16_t(atoi(token.c_str()) ));
585 }
586 }
587
588 /*
589 * Extract the effector type and its parameters
590 */
591 void instruction_from_string ( const std::string &str ) {
592 std::istringstream iss(str);
593 std::string token;
594 getline(iss, token, FIELD_SERPARATOR);
595 switch (token[0]) {
596 case 'M' : // expect a MOVE_MOTORS
597 case 'm' :
598 set_theInstruction(MOVE_MOTORS);
599 if (getline(iss, token, FIELD_SERPARATOR)) {
600 set_firstParameter(int16_t(atoi(token.c_str())));
601 }
602 if (getline(iss, token, FIELD_SERPARATOR)) {
603 set_secondParameter(int16_t(atoi(token.c_str())));
604 }
605 break;
606 case 'o' : // expect a ONE_MOTOR_SETTING
607 case 'O' :
608 set_theInstruction(ONE_MOTOR_SETTING);
609 if (getline(iss, token, FIELD_SERPARATOR)) {
610 int16_t motorID= 0!= atoi(token.c_str()) ? RIGHT_MOTOR_DIFFERENTIAL : LEFT_MOTOR_DIFFERENTIAL ;
611 set_firstParameter(motorID);
612 }
613 if (getline(iss, token, FIELD_SERPARATOR)) {
614 set_secondParameter(int16_t(atoi(token.c_str())));
615 }
616 break;
617 case 'p' :
618 case 'P' : // expect a PLAY_SOUND
619 set_theInstruction(PLAY_SOUND);
620 set_firstParameter(0);
621 set_secondParameter(0);
622 if (getline(iss, token, FIELD_SERPARATOR)) { // duration
623 // always positive
624 int16_t value= int16_t ( atoi(token.c_str()) );
625 value = value >=0 ? value : -1*value;
626 set_firstParameter(value);
627 if (getline(iss, token, FIELD_SERPARATOR)) { //frequency
628 // always positive
629 int16_t frequency_value= int16_t ( atoi(token.c_str()) );
630 frequency_value = frequency_value >=0 ? frequency_value : -1*frequency_value;
631 set_secondParameter(frequency_value);
632 }
633 }
634 break;
635 case 'l' :
636 case 'L' : // expect a LIGHTUP_LED
637 set_theInstruction(LIGHTUP_LED);
638 if (getline(iss, token, FIELD_SERPARATOR)) {
639 set_firstParameter(int16_t((0== atoi(token.c_str())? 0 :1 ) ));
640 }
641 break;
642 case 'd' :
643 case 'D' : // expect a DISTANCE
644 set_theInstruction(DISTANCE);
645 set_parameters2ndBinary(str);
646 break;
647 case 't' :
648 case 'T' : // expect a TOUCH sensor command
649 set_theInstruction(TOUCH);
650 set_parameters2ndBinary(str);
651 break;
652 case 'i' :
653 case 'I' : // expect a INTENSITY_LIGHT
654 set_theInstruction(INTENSITY_LIGHT);
655 set_parameters2ndBinary(str);
656 break;
657 case 'r' :
658 case 'R' : // expect a ROTATION_ENCODER
659 set_theInstruction(ROTATION_ENCODER);
660 set_parameters2ndBinary(str);
661 break;
662 case 'c' :
663 case 'C' : // expect a CAMERA
664 set_theInstruction(CAMERA);
665 set_parameters2ndBinary(str);
666 break;
667 }//switch
668 }
669
670 /*
671 * Extract the sensor type and its parameters
672 */
673 void measurement_from_string ( const std::string &str ) {
674 std::istringstream iss(str);
675 std::string token;
676 getline(iss, token, FIELD_SERPARATOR);
677 switch (token[0]) {
678 case 'd' :
679 case 'D' : // expect a DISTANCE
680 set_theInstruction(DISTANCE);
681 set_parameters2ndNum(str);
682 break;
683 case 'i' :
684 case 'I' : // expect a INTENSITY_LIGHT
685 set_theInstruction(INTENSITY_LIGHT);
686 set_parameters2ndNum(str);
687 break;
688 case 'r' :
689 case 'R' : // expect a ROTATION_ENCODER
690 set_theInstruction(ROTATION_ENCODER);
691 set_parameters2ndNum(str);
692 break;
693 case 'c' :
694 case 'C' : // expect a CAMERA
695 set_theInstruction(CAMERA);
696 set_parametersCamera(str);
697 break;
698 }//switch
699 }
700
701 };
702
703
711 PROPERTY(int16_t, robotID)
715 PROPERTY(int16_t, power)
719 PROPERTY(ColorLineInstructions, theInstruction)
723 PROPERTY(CAMERA_E_PUCK_CHANNELS, color)
727 PROPERTY(int16_t, colorIntensityThreshold)
731 PROPERTY(int16_t, visibilityCountThreshold)
735 PROPERTY(int16_t, limit)
736
737
738 WEBOTS_NXT_colorLine_walk(int16_t robotID = 0 , int16_t power = 0, ColorLineInstructions theInstruction = FOLLOW_COLOR, CAMERA_E_PUCK_CHANNELS color = BLUE_CHANNEL, int16_t colorIntensityThreshold = 100, int16_t visibilityCountThreshold = 10, int16_t limit=90): _robotID(robotID), _power(power), _theInstruction(theInstruction), _color(color), _colorIntensityThreshold(colorIntensityThreshold), _visibilityCountThreshold(visibilityCountThreshold), _limit(limit) { /* better than set_x(x); set_y(y) */ }
739
741 WEBOTS_NXT_colorLine_walk(const std::string &names) { from_string(names); }
742
744 WEBOTS_NXT_colorLine_walk(const WEBOTS_NXT_colorLine_walk &other): _robotID(other._robotID), _power(other._power), _theInstruction(other._theInstruction), _color(other._color), _colorIntensityThreshold(other._colorIntensityThreshold), _visibilityCountThreshold(other._visibilityCountThreshold), _limit(other._limit) {}
745
747 WEBOTS_NXT_colorLine_walk &operator=(const WEBOTS_NXT_colorLine_walk &other) { _robotID = other._robotID; _power = other._power; _theInstruction = other._theInstruction; _color = other._color; _colorIntensityThreshold = other._colorIntensityThreshold; _visibilityCountThreshold = other._visibilityCountThreshold; _limit = other._limit; return *this; }
748
750 std::string description() const {
751 std::ostringstream ss;
752 ss<< _robotID << FIELD_SERPARATOR;
753 ss<< _power << FIELD_SERPARATOR;
754 switch(_theInstruction) {
755 case FOLLOW_COLOR :
756 ss << "FOLLOW_COLOR" << FIELD_SERPARATOR; break;
758 ss << "TURN_RIGHT_UNTIL_COLOR_FOUND" << FIELD_SERPARATOR; break;
760 ss << "TURN_LEFT_UNTIL_COLOR_FOUND" << FIELD_SERPARATOR; break;
761 }
762 switch(_color) {
763 case BLUE_CHANNEL :
764 ss << "BLUE_CHANNEL" << FIELD_SERPARATOR; break;
765 case RED_CHANNEL :
766 ss << "RED_CHANNEL" << FIELD_SERPARATOR; break;
767 case GREEN_CHANNEL :
768 ss << "GREEN_CHANNEL" << FIELD_SERPARATOR; break;
769 case GREY_CHANNEL :
770 ss << "GREY_CHANNEL" << FIELD_SERPARATOR; break;
771 }
772 ss<< _colorIntensityThreshold << FIELD_SERPARATOR;
773 ss<< _visibilityCountThreshold << FIELD_SERPARATOR;
774 ss<< _limit << FIELD_SERPARATOR;
775 return ss.str();
776 }
777
779 void from_string(const std::string &str) {
780 std::istringstream iss(str);
781 std::string token;
782 if (getline(iss, token, FIELD_SERPARATOR)) {
783 _robotID = int16_t ( atoi(token.c_str())) ;
784 if (getline(iss, token, FIELD_SERPARATOR)) {
785 _power = int16_t ( atoi(token.c_str())) ;
786 if (getline(iss, token, FIELD_SERPARATOR)) {
787 _theInstruction = FOLLOW_COLOR;
788 std::size_t found = token.find("RIGHT");
789 if (std::string::npos!=found) _theInstruction = TURN_RIGHT_UNTIL_COLOR_FOUND;
790 else {
791 found = token.find("LEFT");
792 if (std::string::npos!=found) _theInstruction = TURN_LEFT_UNTIL_COLOR_FOUND;
793 }
794 if (getline(iss, token, FIELD_SERPARATOR)) {
795 _color = BLUE_CHANNEL;
796 found = token.find("RED");
797 if (std::string::npos!=found) _color = RED_CHANNEL;
798 else {
799 found = token.find("GREEN");
800 if (std::string::npos!=found) _color = GREEN_CHANNEL;
801 else {
802 found = token.find("GREY");
803 if (std::string::npos!=found) _color = GREY_CHANNEL;
804 }
805 }
806 }
807 if (getline(iss, token, FIELD_SERPARATOR)) {
808 _colorIntensityThreshold = int16_t ( atoi(token.c_str())) ;
809 if (getline(iss, token, FIELD_SERPARATOR)) {
810 _visibilityCountThreshold = int16_t ( atoi(token.c_str())) ;
811 if (getline(iss, token, FIELD_SERPARATOR)) _limit = int16_t ( atoi(token.c_str()));
812 }
813 }
814 }
815 }
816 }
817 } // from string
818
819 }; // WEBOTS_NXT_colorLine_walk
820
821
829 PROPERTY(int16_t, robotID)
833 PROPERTY(bool, runningFlag)
837 PROPERTY(bool, successLastMove)
838
839
840 WEBOTS_NXT_walk_isRunning(int16_t robotID =0 , bool runningFlag = false, bool successLastMove=false ): _robotID(robotID), _runningFlag(runningFlag), _successLastMove(successLastMove) { /* better than set_x(x); set_y(y) */ }
841
843 WEBOTS_NXT_walk_isRunning(const std::string &names) { from_string(names); }
844
846 WEBOTS_NXT_walk_isRunning (const WEBOTS_NXT_walk_isRunning &other): _robotID(other._robotID), _runningFlag(other._runningFlag), _successLastMove(other._successLastMove) {}
847
849 WEBOTS_NXT_walk_isRunning operator=(const WEBOTS_NXT_walk_isRunning &other) { _robotID = other._robotID; _runningFlag = other._runningFlag; _successLastMove = other._successLastMove; return *this; }
850
852 std::string description() const {
853 std::ostringstream ss;
854 ss<< _robotID << FIELD_SERPARATOR;
855 ss<< (_runningFlag ? "1" :"0") << FIELD_SERPARATOR;
856 ss<< (_successLastMove ? "1" :"0") << FIELD_SERPARATOR;
857 return ss.str();
858 }
859
861 void from_string(const std::string &str) {
862 std::istringstream iss(str);
863 std::string token;
864 if (getline(iss, token, FIELD_SERPARATOR)) {
865 _robotID = int16_t ( atoi(token.c_str())) ;
866 if (getline(iss, token, FIELD_SERPARATOR)) {
867 _runningFlag = 0 != atoi(token.c_str());
868 if (getline(iss, token, FIELD_SERPARATOR)) {
869 _successLastMove = 0 != atoi(token.c_str());
870 }
871 }
872 }
873 }
874
875
876 }; // class WEBOTS_NXT_walk_isRunning
877
878
886 PROPERTY(int16_t, robotID)
890 PROPERTY(int16_t, power)
895 PROPERTY(int16_t, spin)
899 PROPERTY(int16_t, forward)
900
901
902 WEBOTS_NXT_deadReakoning_walk(int16_t robotID =0 , int16_t power = 0, int16_t spin=0, int16_t forward =0): _robotID(robotID), _power(power), _spin(spin), _forward(forward) { /* better than set_x(x); set_y(y) */ }
903
905 WEBOTS_NXT_deadReakoning_walk(const std::string &names) { from_string(names); }
906
908 WEBOTS_NXT_deadReakoning_walk(const WEBOTS_NXT_deadReakoning_walk &other): _robotID(other._robotID), _power(other._power), _spin(other._spin), _forward(other._forward) {}
909
911 WEBOTS_NXT_deadReakoning_walk operator=(const WEBOTS_NXT_deadReakoning_walk &other) { _robotID = other._robotID; _power = other._power; _spin = other._spin; _forward = other._forward; return *this; }
912
914 std::string description() const {
915 std::ostringstream ss;
916 ss<< _robotID << FIELD_SERPARATOR;
917 ss<< _power << FIELD_SERPARATOR;
918 ss<< _spin << FIELD_SERPARATOR;
919 ss<< _forward << FIELD_SERPARATOR;
920 return ss.str();
921 }
922
924 void from_string(const std::string &str) {
925 std::istringstream iss(str);
926 std::string token;
927 if (getline(iss, token, FIELD_SERPARATOR)) {
928 _robotID = int16_t ( atoi(token.c_str())) ;
929 if (getline(iss, token, FIELD_SERPARATOR)) {
930 _power = int16_t ( atoi(token.c_str())) ;
931 if (getline(iss, token, FIELD_SERPARATOR)) {
932 _spin = int16_t ( atoi(token.c_str())) ;
933 if (getline(iss, token, FIELD_SERPARATOR)) _forward = int16_t ( atoi(token.c_str())) ;
934 }
935 }
936 }
937
938 }
939 }; // class WEBOTS_NXT_deadReakoning_walk
940
941
946 private:
947
948 class WEBOTS_NXT_bridge _touchSensors[NXT_NUM_SENSORS_IN_BUMBER];
949
950 public :
951
953 WEBOTS_NXT_bridge theLeft(0,TOUCH,LEFT_TOUCH_SENSOR,0,true);
954 _touchSensors[LEFT_TOUCH_SENSOR]= theLeft;
955 WEBOTS_NXT_bridge theRight(0,TOUCH,RIGHT_TOUCH_SENSOR,0,true);
956 _touchSensors[RIGHT_TOUCH_SENSOR]= theRight;
957 }
958
963 _touchSensors[sensorID]=obj;
964 }
965
967 WEBOTS_NXT_bumper(const std::string &names) { from_string(names); }
968
970 WEBOTS_NXT_bumper(const WEBOTS_NXT_bumper &other) { *this = other; }
971
974 memcpy(this, &other, sizeof(other));
975 return *this;
976 }
977
979 class WEBOTS_NXT_bridge *touchSensors() { return _touchSensors; }
980
982 void set_touchSensors(const class WEBOTS_NXT_bridge *objects) {
983 memcpy(_touchSensors, objects, sizeof(_touchSensors));
984 }
985
987 void set_a_sensor(const class WEBOTS_NXT_bridge &obj, enum TouchSensorID sensorID = LEFT_TOUCH_SENSOR) {
988 _touchSensors[sensorID]=obj;
989 }
990
993 return _touchSensors[sensorID];
994 }
995
998 return _touchSensors[sensorID];
999 }
1000
1002 std::string description() const {
1003 std::ostringstream ss;
1004 for ( int i =LEFT_TOUCH_SENSOR; i< NXT_NUM_SENSORS_IN_BUMBER; i++ ) {
1005 TouchSensorID sensorID = TouchSensorID(i);
1006 ss << _touchSensors[sensorID].description();
1007 } //for
1008 return ss.str();
1009 }
1010
1012 void from_string(const std::string &str) {
1013 std::istringstream iss(str);
1014 std::string token;
1015 for (int object = LEFT_TOUCH_SENSOR; object < NXT_NUM_SENSORS_IN_BUMBER; object++) {
1016 //if (!getline(iss, token, '\t')) break;
1017 if (!getline(iss, token, FIELD_SERPARATOR)) break;
1018 _touchSensors[object].from_string( token );
1019 }
1020 }
1021
1022 }; // WEBOTS_NXT_bumper
1023
1024
1029 private:
1030
1034 PROPERTY(int16_t, maxSpeed)
1035
1036
1039 class WEBOTS_NXT_bridge _encoders[NXT_MOTOR3];
1040
1041 public :
1042
1045 _encoders[LEFT_MOTOR_DIFFERENTIAL]= theLeft;
1047 _encoders[RIGHT_MOTOR_DIFFERENTIAL]= theRight;
1048 _maxSpeed=0;
1049 }
1050
1053 _encoders[encoderID]=obj;
1054 _maxSpeed=0;
1055 }
1056
1058 WEBOTS_NXT_encoders(const std::string &names) { from_string(names); }
1059
1061 WEBOTS_NXT_encoders(const WEBOTS_NXT_encoders &other) { *this = other; }
1062
1065 memcpy(this, &other, sizeof(other));
1066 return *this;
1067 }
1068
1070 class WEBOTS_NXT_bridge *encoders() { return _encoders; }
1071
1073 void set_encoders(const class WEBOTS_NXT_bridge *objects) { memcpy(_encoders, objects, sizeof(_encoders)); }
1074
1076 void set_encoder(const class WEBOTS_NXT_bridge &obj, enum DifferentialMotor encoderID = NXT_MOTOR3) { _encoders[encoderID]=obj; }
1077
1079 WEBOTS_NXT_bridge &get_object( enum DifferentialMotor encoderID = NXT_MOTOR3) { return _encoders[encoderID]; }
1080
1082 const WEBOTS_NXT_bridge &get_object( enum DifferentialMotor encoderID = NXT_MOTOR3) const { return _encoders[encoderID]; }
1083
1085 std::string description() const {
1086 std::ostringstream ss;
1087 for ( int i =LEFT_MOTOR_DIFFERENTIAL; i< NXT_MOTOR3; i++ ) {
1088 DifferentialMotor encoderID = DifferentialMotor(i);
1089 ss << _encoders[encoderID].description();
1090 } //for
1091 ss << _maxSpeed;
1092 return ss.str();
1093 }
1094
1096 void from_string(const std::string &str) {
1097 std::istringstream iss(str);
1098 std::string token;
1099 for (int object = LEFT_MOTOR_DIFFERENTIAL; object < NXT_MOTOR3; object++) {
1100 //if (!getline(iss, token, '\t')) break;
1101 if (!getline(iss, token, OBJECT_SEPARATOR)) break;
1102 _encoders[object].from_string( token );
1103 }
1104 _maxSpeed=0;
1105 if (getline(iss, token, FIELD_SERPARATOR))
1106 _maxSpeed = int16_t ( atoi(token.c_str())) ;
1107 }
1108
1109 }; // WEBOTS_NXT_encoders
1110
1111
1116 private:
1117
1121 PROPERTY(int16_t, width)
1122
1123
1126 class WEBOTS_NXT_bridge _channels[GREY_CHANNEL+1];
1127
1128 public :
1129
1130 WEBOTS_NXT_camera() { //first parameter is the total pixels, second parameter is the middle of the pixels
1131 WEBOTS_NXT_bridge theBlueChannel(0,CAMERA,0,0,true);
1132 _channels[BLUE_CHANNEL]= theBlueChannel;
1133 WEBOTS_NXT_bridge theRedChannel(0,CAMERA,0,0,true);
1134 _channels[RED_CHANNEL]= theRedChannel;
1135 WEBOTS_NXT_bridge theGreenChannel(0,CAMERA,0,0,true);
1136 _channels[GREEN_CHANNEL]= theGreenChannel;
1137 WEBOTS_NXT_bridge theGreyChannel(0,CAMERA,0,0,true);
1138 _channels[GREY_CHANNEL]= theGreyChannel;
1139 _width= 0;
1140 }
1141
1143 WEBOTS_NXT_camera(const class WEBOTS_NXT_bridge &obj, int16_t a_width, enum CAMERA_E_PUCK_CHANNELS channelID = GREY_CHANNEL) {
1144 _channels[channelID]=obj;
1145 _width=a_width;
1146 }
1147
1149 WEBOTS_NXT_camera(const std::string &names) { from_string(names); }
1150
1152 WEBOTS_NXT_camera(const WEBOTS_NXT_camera &other) { *this = other; }
1153
1156 memcpy(this, &other, sizeof(other));
1157 return *this;
1158 }
1159
1161 class WEBOTS_NXT_bridge *channels() { return _channels; }
1162
1164 void set_channels(const class WEBOTS_NXT_bridge *objects) { memcpy(_channels, objects, sizeof(_channels)); }
1165
1167 void set_encoder(const class WEBOTS_NXT_bridge &obj, int16_t a_width, enum CAMERA_E_PUCK_CHANNELS channelID = GREY_CHANNEL) {
1168 _channels[channelID]=obj;
1169 _width=a_width;
1170 }
1171
1173 WEBOTS_NXT_bridge &get_channel( enum CAMERA_E_PUCK_CHANNELS channelID = GREY_CHANNEL) { return _channels[channelID]; }
1174
1176 const WEBOTS_NXT_bridge &get_object( enum CAMERA_E_PUCK_CHANNELS channelID = GREY_CHANNEL) const { return _channels[channelID]; }
1177
1179 std::string description() const {
1180 std::ostringstream ss;
1181 for ( int i =BLUE_CHANNEL; i<= GREY_CHANNEL; i++ ) {
1183 ss << _channels[channelID].description();
1184 } //for
1185 ss << _width;
1186 return ss.str();
1187 }
1188
1190 void from_string(const std::string &str) {
1191 std::istringstream iss(str);
1192 std::string token;
1193 for (int object = BLUE_CHANNEL; object <= GREY_CHANNEL; object++) {
1194 //if (!getline(iss, token, '\t')) break;
1195 if (!getline(iss, token, OBJECT_SEPARATOR)) break;
1196 _channels[object].from_string( token );
1197 }
1198 _width=0;
1199 if (getline(iss, token, FIELD_SERPARATOR)) _width = int16_t ( atoi(token.c_str())) ;
1200 }
1201
1202
1203 }; // WEBOTS_NXT_encoders
1204
1205
1215 COMPLETED= 5
1217
1225 PROPERTY(int16_t, theRobotID)
1229 PROPERTY(GridStep, theInstruction)
1233 PROPERTY(int16_t, howMany)
1234
1235 public:
1236
1238 WEBOTS_NXT_gridMotions(int16_t theRobotID =0 ,GridStep theInstruction = PLAIN_LINE_STRAIGHT_STEP, int16_t howMany = 1): _theRobotID(theRobotID), _theInstruction(theInstruction), _howMany(howMany) { /* better than set_x(x); set_y(y) */ }
1239
1241 WEBOTS_NXT_gridMotions(const std::string &names) { from_string(names); }
1242
1244 WEBOTS_NXT_gridMotions(const WEBOTS_NXT_gridMotions &other): _theRobotID(other._theRobotID), _theInstruction(other._theInstruction), _howMany(other._howMany) {}
1245
1247 WEBOTS_NXT_gridMotions &operator=(const WEBOTS_NXT_gridMotions &other) { _theRobotID = other._theRobotID; _theInstruction = other._theInstruction; _howMany = other._howMany; return *this; }
1248
1250 std::string description() const {
1251 std::ostringstream ss;
1252 ss<< _theRobotID << FIELD_SERPARATOR;
1253 switch(_theInstruction) {
1255 /* Move forward ona yellow line ignored if no yellow line
1256 */
1257 ss << "YELLOW_LINE_STRAIGHT_STEP" << FIELD_SERPARATOR << _howMany << FIELD_SERPARATOR;
1258 break;
1260 ss << "MAGENTA_LINE_STRAIGHT_STEP" << FIELD_SERPARATOR << _howMany << FIELD_SERPARATOR;
1261 break;
1263 ss << "PLAIN_LINE_STRAIGHT_STEP" << FIELD_SERPARATOR << _howMany << FIELD_SERPARATOR;
1264 break;
1265 case TURN_LEFT_STEP :
1266 ss << "TURN_LEFT_STEP" << FIELD_SERPARATOR << _howMany << FIELD_SERPARATOR;
1267 break;
1268 case TURN_RIGHT_STEP :
1269 ss << "TURN_RIGHT_STEP" << FIELD_SERPARATOR << _howMany << FIELD_SERPARATOR;
1270 break;
1271 case COMPLETED :
1272 ss << "COMPLETED" << FIELD_SERPARATOR << _howMany << FIELD_SERPARATOR;
1273 break;
1274 }
1275 return ss.str();
1276 }
1277
1279 void from_string(const std::string &strWithID) {
1280 set_theRobotID(0);
1281 _theInstruction = PLAIN_LINE_STRAIGHT_STEP;
1282 set_howMany(1);
1283 std::istringstream iss(strWithID);
1284 std::string token;
1285 if (getline(iss, token, FIELD_SERPARATOR)) {
1286 int16_t numberForID = int16_t ( atoi(token.c_str())) ;
1287 // Robots id are 0,1,2 .....
1288 if (numberForID <0) set_theRobotID(-numberForID); else set_theRobotID(numberForID);
1289
1290 // defaults
1291
1292 if (getline(iss, token, FIELD_SERPARATOR)) {
1293 std::size_t found = token.find("RIGHT");
1294 if (std::string::npos!=found) _theInstruction = TURN_RIGHT_STEP;
1295 else {
1296 found = token.find("LEFT");
1297 if (std::string::npos!=found) _theInstruction = TURN_LEFT_STEP;
1298 else {
1299 found = token.find("YELLOW");
1300 if (std::string::npos!=found) _theInstruction = YELLOW_LINE_STRAIGHT_STEP;
1301 else {
1302 found = token.find("MAGENTA");
1303 if (std::string::npos!=found) _theInstruction = MAGENTA_LINE_STRAIGHT_STEP;
1304 else {
1305 found = token.find("COMPLETED");
1306 if (std::string::npos!=found) _theInstruction = COMPLETED;
1307 }
1308 }
1309 }
1310 }
1311 }
1312 if (getline(iss, token, FIELD_SERPARATOR)) {
1313 int16_t numberofTimes = int16_t ( atoi(token.c_str())) ;
1314 if (numberofTimes <0) set_howMany(-numberofTimes); else set_howMany(numberofTimes >0 ? numberofTimes : 1);
1315 }
1316
1317 }
1318 }
1319
1320 private :
1321
1322 };
1323
1324
1325
1326
1327
1328}// namespace
1329
1330
1331#pragma clang diagnostic pop
1332
1333#endif // WEBOTS_NXT_bridge_DEFINED
const char OBJECT_SEPARATOR
const char EQUALS
const char FIELD_SERPARATOR
This is the base class for the WEBOTS_NXT_bridge library.
This class reports the status of the Bumper behaviour.
WEBOTS_NXT_bumper(const WEBOTS_NXT_bumper &other)
copy constructor
void set_a_sensor(const class WEBOTS_NXT_bridge &obj, enum TouchSensorID sensorID=LEFT_TOUCH_SENSOR)
single sensor object setter
WEBOTS_NXT_bumper & operator=(const WEBOTS_NXT_bumper &other)
copy assignment operator
std::string description() const
convert to a string
void from_string(const std::string &str)
convert from a string
WEBOTS_NXT_bumper(const class WEBOTS_NXT_bridge &obj, enum TouchSensorID sensorID=LEFT_TOUCH_SENSOR)
single touch sensor constructor LEFT_TOUCH_SENDOR is used because it is the first enumerator
void set_touchSensors(const class WEBOTS_NXT_bridge *objects)
property setter
WEBOTS_NXT_bridge & get_object(enum TouchSensorID sensorID=LEFT_TOUCH_SENSOR)
single sensor object getter
const WEBOTS_NXT_bridge & get_object(enum TouchSensorID sensorID=LEFT_TOUCH_SENSOR) const
single sensor object getter
class WEBOTS_NXT_bridge * touchSensors()
property getter
WEBOTS_NXT_bumper(const std::string &names)
string constructor
This class reports the status of the Camera.
const WEBOTS_NXT_bridge & get_object(enum CAMERA_E_PUCK_CHANNELS channelID=GREY_CHANNEL) const
single channel object getter
WEBOTS_NXT_camera & operator=(const WEBOTS_NXT_camera &other)
copy assignment operator
void from_string(const std::string &str)
convert from a string
WEBOTS_NXT_camera(const WEBOTS_NXT_camera &other)
copy constructor
WEBOTS_NXT_camera(const std::string &names)
string constructor
void set_channels(const class WEBOTS_NXT_bridge *objects)
property setter
WEBOTS_NXT_bridge & get_channel(enum CAMERA_E_PUCK_CHANNELS channelID=GREY_CHANNEL)
single channel object getter
void set_encoder(const class WEBOTS_NXT_bridge &obj, int16_t a_width, enum CAMERA_E_PUCK_CHANNELS channelID=GREY_CHANNEL)
single channel with width setter
WEBOTS_NXT_camera(const class WEBOTS_NXT_bridge &obj, int16_t a_width, enum CAMERA_E_PUCK_CHANNELS channelID=GREY_CHANNEL)
single channel with width constructor
std::string description() const
convert to a string
class WEBOTS_NXT_bridge * channels()
property getter
This class reports the status of the ColorLine_Walk behaviour.
This class reports the status of the Dead Reakoning Walk behaviour.
This class reports the status of the Encoder Status.
WEBOTS_NXT_encoders(const class WEBOTS_NXT_bridge &obj, enum DifferentialMotor encoderID=NXT_MOTOR3)
single encoder constructor
WEBOTS_NXT_encoders & operator=(const WEBOTS_NXT_encoders &other)
copy assignment operator
void set_encoders(const class WEBOTS_NXT_bridge *objects)
property setter
const WEBOTS_NXT_bridge & get_object(enum DifferentialMotor encoderID=NXT_MOTOR3) const
single encoder object getter
void set_encoder(const class WEBOTS_NXT_bridge &obj, enum DifferentialMotor encoderID=NXT_MOTOR3)
single encoder object setter
WEBOTS_NXT_encoders(const std::string &names)
string constructor
WEBOTS_NXT_encoders(const WEBOTS_NXT_encoders &other)
copy constructor
void from_string(const std::string &str)
convert from a string
class WEBOTS_NXT_bridge * encoders()
property getter
WEBOTS_NXT_bridge & get_object(enum DifferentialMotor encoderID=NXT_MOTOR3)
single encoder object getter
std::string description() const
convert to a string
This class of messages are for the motion module for the miPal demo grid world.
WEBOTS_NXT_vector_bridge & operator=(const WEBOTS_NXT_vector_bridge &other)
copy assignment operator
WEBOTS_NXT_vector_bridge(const WEBOTS_NXT_vector_bridge &other)
copy constructor
WEBOTS_NXT_vector_bridge(const std::string &names)
string constructor
std::string description() const
convert to a string
void from_string(const std::string &strWithID)
convert from a string
PROPERTY(int16_t, theRobotID) PROPERTY(int16_t
The robot this status is for.
void set_actuator(DifferentialInstructions theActuator, int16_t firstParameter, int16_t secondParameter)
Sets the WEBOTS_NXT_vector_bridge instance properties that represent actuator states based on the spe...
This class reports the status of the Walk is running behaviour.
/file APM_Interface.h
CAMERA_E_PUCK_CHANNELS
Enumeration of the Colour Channels available in camera of the E-Puck differential robot.
SoundDiscriminators
Enumeration of the Sound parameter settings.
TouchSensorID
Enumeration of the Touch Sensors in the NXT and E-Puck differential robots.
GridStep
Enumeration of ID's for motions of the differential robot.
NXT_Sensor_Ports
Enumeration of the Sensor ports available in the NXT differential robot.
DifferentialMotor
Enumerations of motor's in the NXT and E-Puck differential robots.
SonarSensorID
Enumeration of the Sonar Sensors in the NXT and E-Puck differential robots.
DifferentialInstructions
Enumeration of the defined general instructions.
LightSensorID
Enumeration of the Light Sensors in the NXT differential robot.
ColorLineInstructions
Enumeration of the available strategies when following lines.