Skip to content

Commit c0cc05d

Browse files
Add the possibility to use the feet imu in the WalkingModule
1 parent fcdd817 commit c0cc05d

3 files changed

Lines changed: 273 additions & 16 deletions

File tree

src/WalkingModule/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ add_walking_controllers_application(
1010
NAME WalkingModule
1111
SOURCES src/main.cpp src/Module.cpp ${WalkingModule_THRIFT_GEN_FILES}
1212
HEADERS include/WalkingControllers/WalkingModule/Module.h
13-
LINK_LIBRARIES WalkingControllers::YarpUtilities WalkingControllers::iDynTreeUtilities WalkingControllers::StdUtilities WalkingControllers::TimeProfiler WalkingControllers::RobotInterface WalkingControllers::KinDynWrapper WalkingControllers::TrajectoryPlanner WalkingControllers::SimplifiedModelControllers WalkingControllers::WholeBodyControllers WalkingControllers::RetargetingHelper BipedalLocomotion::VectorsCollection BipedalLocomotion::ParametersHandlerYarpImplementation ctrlLib
13+
LINK_LIBRARIES WalkingControllers::YarpUtilities WalkingControllers::iDynTreeUtilities WalkingControllers::StdUtilities WalkingControllers::TimeProfiler WalkingControllers::RobotInterface WalkingControllers::KinDynWrapper WalkingControllers::TrajectoryPlanner WalkingControllers::SimplifiedModelControllers WalkingControllers::WholeBodyControllers WalkingControllers::RetargetingHelper BipedalLocomotion::VectorsCollection BipedalLocomotion::ParametersHandlerYarpImplementation BipedalLocomotion::ParametersHandlerYarpImplementation BipedalLocomotion::RobotInterfaceYarpImplementation ctrlLib
1414
SUBDIRECTORIES app)
1515

src/WalkingModule/include/WalkingControllers/WalkingModule/Module.h

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,46 @@
1010
#define WALKING_MODULE_HPP
1111

1212
// std
13-
#include <WalkingControllers/WholeBodyControllers/BLFIK.h>
13+
#include <unordered_map>
14+
#include <vector>
1415
#include <memory>
1516
#include <deque>
1617

1718
// YARP
19+
#include <yarp/dev/PolyDriverList.h>
1820
#include <yarp/os/RFModule.h>
19-
#include <yarp/sig/Vector.h>
20-
2121
#include <yarp/os/RpcClient.h>
22+
#include <yarp/sig/Vector.h>
2223

23-
24+
#include <BipedalLocomotion/RobotInterface/YarpSensorBridge.h>
25+
#include <BipedalLocomotion/RobotInterface/YarpHelper.h>
2426
#include <BipedalLocomotion/YarpUtilities/VectorsCollection.h>
2527

2628
// iDynTree
2729
#include <iDynTree/Core/VectorFixSize.h>
2830
#include <iDynTree/ModelIO/ModelLoader.h>
31+
#include <iDynTree/Core/Rotation.h>
32+
#include <iDynTree/Core/Transform.h>
33+
#include <iDynTree/Model/Indices.h>
2934

3035
// WalkingControllers library
36+
#include <WalkingControllers/KinDynWrapper/Wrapper.h>
37+
#include <WalkingControllers/RetargetingHelper/Helper.h>
3138
#include <WalkingControllers/RobotInterface/Helper.h>
3239
#include <WalkingControllers/RobotInterface/PIDHandler.h>
33-
#include <WalkingControllers/TrajectoryPlanner/TrajectoryGenerator.h>
34-
#include <WalkingControllers/TrajectoryPlanner/StableDCMModel.h>
35-
#include <WalkingControllers/TrajectoryPlanner/FreeSpaceEllipseManager.h>
36-
3740
#include <WalkingControllers/SimplifiedModelControllers/DCMModelPredictiveController.h>
3841
#include <WalkingControllers/SimplifiedModelControllers/DCMReactiveController.h>
3942
#include <WalkingControllers/SimplifiedModelControllers/ZMPController.h>
40-
43+
#include <WalkingControllers/TimeProfiler/TimeProfiler.h>
44+
#include <WalkingControllers/TrajectoryPlanner/FreeSpaceEllipseManager.h>
45+
#include <WalkingControllers/TrajectoryPlanner/StableDCMModel.h>
46+
#include <WalkingControllers/TrajectoryPlanner/TrajectoryGenerator.h>
47+
#include <WalkingControllers/WholeBodyControllers/BLFIK.h>
4148
#include <WalkingControllers/WholeBodyControllers/InverseKinematics.h>
4249
#include <WalkingControllers/WholeBodyControllers/QPInverseKinematics.h>
4350
#include <WalkingControllers/WholeBodyControllers/QPInverseKinematics_osqp.h>
4451
#include <WalkingControllers/WholeBodyControllers/QPInverseKinematics_qpOASES.h>
4552

46-
#include <WalkingControllers/KinDynWrapper/Wrapper.h>
47-
48-
#include <WalkingControllers/RetargetingHelper/Helper.h>
49-
50-
#include <WalkingControllers/TimeProfiler/TimeProfiler.h>
51-
5253
// iCub-ctrl
5354
#include <iCub/ctrl/filters.h>
5455

@@ -65,6 +66,8 @@ namespace WalkingControllers
6566
enum class WalkingFSM {Idle, Configured, Preparing, Prepared, Walking, Paused, Stopped};
6667
WalkingFSM m_robotState{WalkingFSM::Idle}; /**< State of the WalkingFSM. */
6768

69+
std::vector<BipedalLocomotion::RobotInterface::PolyDriverDescriptor> m_polyDrivers;
70+
6871
double m_dT; /**< RFModule period. */
6972
double m_time; /**< Current time. */
7073
std::string m_robot; /**< Robot name. */
@@ -73,6 +76,7 @@ namespace WalkingControllers
7376
bool m_useQPIK; /**< True if the QP-IK is used. */
7477
bool m_useBLFIK; /**< True if the BLF-IK is used. */
7578
bool m_useOSQP; /**< True if osqp is used to QP-IK problem. */
79+
bool m_useFeetImu{false}; /**< True if you want to use the imu on the feet. */
7680
bool m_dumpData; /**< True if data are saved. */
7781
bool m_firstRun; /**< True if it is the first run. */
7882
bool m_skipDCMController; /**< True if the desired ZMP should be used instead of the DCM controller. */
@@ -101,6 +105,8 @@ namespace WalkingControllers
101105
std::unique_ptr<RetargetingClient> m_retargetingClient; /**< Pointer to the stable DCM dynamics. */
102106
std::unique_ptr<TimeProfiler> m_profiler; /**< Time profiler. */
103107

108+
BipedalLocomotion::RobotInterface::YarpSensorBridge m_sensorBridge; /**< Helper to get the data from the robot */
109+
104110
double m_additionalRotationWeightDesired; /**< Desired additional rotational weight matrix. */
105111
double m_desiredJointsWeight; /**< Desired joint weight matrix. */
106112
yarp::sig::Vector m_desiredJointInRadYarp; /**< Desired joint position (regularization task). */
@@ -153,6 +159,23 @@ namespace WalkingControllers
153159

154160
yarp::os::BufferedPort<BipedalLocomotion::YarpUtilities::VectorsCollection> m_loggerPort; /**< Logger port. */
155161

162+
struct IMUOrientationData
163+
{
164+
iDynTree::Rotation IMU_R_controlledFrame;
165+
iDynTree::FrameIndex frameIndex;
166+
iDynTree::Rotation I_R_I_IMU;
167+
iDynTree::Rotation I_R_IMU;
168+
iDynTree::Rotation I_R_controlledFrame;
169+
};
170+
171+
struct linkIMU
172+
{
173+
std::unordered_map<std::string, IMUOrientationData> IMUs;
174+
iDynTree::Rotation averageRotation;
175+
};
176+
177+
std::unordered_map<std::string, linkIMU> m_linksWithIMU;
178+
156179
/**
157180
* Get the robot model from the resource finder and set it.
158181
* @param rf is the reference to a resource finder object.
@@ -264,6 +287,18 @@ namespace WalkingControllers
264287
*/
265288
void applyGoalScaling(yarp::sig::Vector &plannerInput);
266289

290+
291+
/**
292+
* Configure the SensorBridge.
293+
* @param rf is the reference to a resource finder object
294+
* @return true in case of success and false otherwise.
295+
*/
296+
bool configureSensorBridge(const yarp::os::Bottle& rf);
297+
298+
bool configureLinkWithIMU(
299+
std::weak_ptr<const BipedalLocomotion::ParametersHandler::IParametersHandler> handler,
300+
const std::string& linkName);
301+
267302
public:
268303

269304
/**

0 commit comments

Comments
 (0)