icub-client
babbling.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 WYSIWYD Consortium, European Commission FP7 Project ICT-612139
3  * Authors: Martina Zambelli
4  * email: m.zambelli13@imperial.ac.uk
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * icub-client/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 #ifndef _BABBLING_H_
19 #define _BABBLING_H_
20 
21 #include <yarp/sig/all.h>
22 #include <yarp/os/all.h>
23 #include <yarp/dev/all.h>
24 
28 class Babbling : public yarp::os::RFModule {
29 protected:
30  yarp::os::RpcServer handlerPort;
31 
32  yarp::dev::IPositionControl* posLeftArm;
33  yarp::dev::IVelocityControl* velLeftArm;
34  yarp::dev::ITorqueControl *itrqLeftArm;
35  yarp::dev::IEncoders* encsLeftArm;
36  yarp::dev::IControlMode *ictrlLeftArm;
37  yarp::dev::IControlLimits *ictrlLimLeftArm;
38 
39  yarp::dev::IPositionControl* posRightArm;
40  yarp::dev::IVelocityControl* velRightArm;
41  yarp::dev::ITorqueControl *itrqRightArm;
42  yarp::dev::IEncoders* encsRightArm;
43  yarp::dev::IControlMode *ictrlRightArm;
44  yarp::dev::IControlLimits *ictrlLimRightArm;
45 
46  yarp::dev::IGazeControl* igaze;
47 
48  yarp::dev::PolyDriver leftArmDev;
49  yarp::dev::PolyDriver rightArmDev;
50  yarp::dev::PolyDriver headDev;
51 
52  yarp::sig::VectorOf<double> encodersLeftArm, encodersRightArm;
53 
54  std::string part;
55  std::string robot;
56  std::string part_babbling;
58 
59  double freq;
60  double amp;
61  double duration;
62 
63  double start_command_arm[16];
64  yarp::sig::VectorOf<double> start_command_head;
65 
66 public:
67  bool configure(yarp::os::ResourceFinder &rf);
68  bool interruptModule();
69  bool close();
70  bool respond(const yarp::os::Bottle& command, yarp::os::Bottle& reply);
71  double getPeriod();
72  bool updateModule();
73 
74 protected:
79  bool init_iCub();
80  bool init_left_arm();
81  bool init_right_arm();
82 
87  bool doBabbling();
88 
89 
95  void babblingCommands(double &t, int j_idx);
96 
101  bool moveHeadToStartPos();
102 
107  bool gotoStartPos();
108 };
109 
110 #endif // _BABBLING_H_
111 
yarp::dev::IVelocityControl * velRightArm
Definition: babbling.h:40
yarp::dev::IEncoders * encsLeftArm
Definition: babbling.h:35
yarp::dev::IControlMode * ictrlRightArm
Definition: babbling.h:43
bool init_left_arm()
Create PolyDriver for left arm.
Definition: babbling.cpp:425
std::string part
Should be "left_arm" or "right_arm".
Definition: babbling.h:54
std::string robot
Should be "icub" or "icubSim".
Definition: babbling.h:55
yarp::sig::VectorOf< double > start_command_head
Target for head in start position.
Definition: babbling.h:64
yarp::dev::PolyDriver headDev
Definition: babbling.h:50
yarp::sig::VectorOf< double > encodersRightArm
Definition: babbling.h:52
yarp::os::RpcServer handlerPort
Definition: babbling.h:30
double start_command_arm[16]
Start command for the 16 arm joints.
Definition: babbling.h:63
bool interruptModule()
Definition: babbling.cpp:91
double getPeriod()
Definition: babbling.cpp:240
bool init_iCub()
Initializes all the device controllers.
Definition: babbling.cpp:538
yarp::dev::IControlLimits * ictrlLimRightArm
Definition: babbling.h:44
bool gotoStartPos()
Move head + arm in start position.
Definition: babbling.cpp:372
bool init_right_arm()
Create PolyDriver for left arm.
Definition: babbling.cpp:481
yarp::dev::IEncoders * encsRightArm
Definition: babbling.h:42
yarp::sig::VectorOf< double > encodersLeftArm
Definition: babbling.h:52
yarp::dev::IPositionControl * posRightArm
Definition: babbling.h:39
std::string part_babbling
Whether to do babbling with the whole "arm" or "hand" (should be either one or the other) ...
Definition: babbling.h:56
int single_joint
Which joint to do babbling with in case it is a single joint.
Definition: babbling.h:57
double duration
Duration for the babbling.
Definition: babbling.h:61
double amp
Amplitude for sin wave.
Definition: babbling.h:60
yarp::dev::IPositionControl * posLeftArm
Definition: babbling.h:32
double freq
Frequency for sin wave.
Definition: babbling.h:59
yarp::dev::ITorqueControl * itrqRightArm
Definition: babbling.h:41
yarp::dev::ITorqueControl * itrqLeftArm
Definition: babbling.h:34
yarp::dev::IGazeControl * igaze
Definition: babbling.h:46
yarp::dev::IVelocityControl * velLeftArm
Definition: babbling.h:33
bool moveHeadToStartPos()
Use iGazeController to move head in start position.
Definition: babbling.cpp:364
yarp::dev::IControlMode * ictrlLeftArm
Definition: babbling.h:36
bool doBabbling()
Sets the joints to be in velocity control, then goes in a loop to call babblingCommands for duration ...
Definition: babbling.cpp:244
bool close()
Definition: babbling.cpp:99
yarp::dev::IControlLimits * ictrlLimLeftArm
Definition: babbling.h:37
bool configure(yarp::os::ResourceFinder &rf)
Definition: babbling.cpp:27
yarp::dev::PolyDriver leftArmDev
Definition: babbling.h:48
bool updateModule()
Definition: babbling.cpp:236
void babblingCommands(double &t, int j_idx)
Issues the actual velocity commands for time t.
Definition: babbling.cpp:281
yarp::dev::PolyDriver rightArmDev
Definition: babbling.h:49
bool respond(const yarp::os::Bottle &command, yarp::os::Bottle &reply)
Definition: babbling.cpp:114