Skip to content

Commit 5c5cf88

Browse files
MiladS-Dafarra
authored andcommitted
adding the step adaptation library
changing the name of QPSolver class remove small bug combining the two class of step adaptation into one class small modifications of step adaptation library modifications of step adaptation library modifications of step adaptation library small modifications of step adaptation library removing some useless methods removing some useless methods small modifications adding an enum for recognizing of swing foot in solve method Using step adaptation library inside the walking controller fixing some bugs fixing the bug related to the size of hessian matrix of step adaptation optimization push recovery by two arms in saggital and lateral direction cleaning the code some primary modifications separation of the step adaptation config files some primary modifications adding the documentation link to the simple estimator modification of the configuration file make an object of TrajectoryGeneration for step adjustment some modifications in trajectoryGenerator and module some small modifications in Module.cpp moving the arms push detection inside the stepAdjustment module modifying some comments dubeg of moving the step adjustment stuff from walkingModule to step adaptation library Keeping the dcm replanning part inside the walkingModule remove some magic numbers modify the input of runstepAdaptation as a reference small modifications step adaptation documentation and configuration files modification Bring the arm joints name for push detection inside the configuration file some modification on walkingModule and exceptions some modifications in walkingModule defining the output and input of step adaptation structure as a private member removing some small bugs! add missing trajectoryPlanner inside cmake lists remove the bug related to zmp offset copy the retargeting planner parameters to reduce the shaking tuning pull request on the robot step adaptation left arm lateral direction tuning the planner parametr for yaw movement tuning unicycle planner parameter for rotational movement tuning step adaptaion on the robot set stiffness and damping joint again inside the code tune the step adaptation parameters tuning step adaptation tuning step adjustment tune the step adaptation parameters activating push recovery every two steps lateral direction is working remove the yaw error remove some comments tuning step adaptaion parameters remove the bug related to the yaw orientation small modification removing the bug related to the push detection during rotational walking parameter tuning some small modifications solve the problem of joystick command during step adaptation solve the problem of joystick increasing speed of walking some modifications try to solve joystick problem small modification try to solve the last step impact saturation of the com error tunning parameters saturation of the com error video recorded version pull request modifications Fix some rebase issues.
1 parent 33e9b06 commit 5c5cf88

25 files changed

Lines changed: 2917 additions & 30 deletions

File tree

cmake/WalkingControllersFindDependencies.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ checkandset_dependency(ICUBcontrib)
131131
find_package(iDynTree QUIET)
132132
checkandset_dependency(iDynTree)
133133

134-
find_package(UnicyclePlanner 0.1.102 QUIET)
134+
find_package(UnicyclePlanner 0.2.102 QUIET)
135135
checkandset_dependency(UnicyclePlanner)
136136

137137
find_package(osqp QUIET)
@@ -162,8 +162,11 @@ walking_controllers_dependent_option(WALKING_CONTROLLERS_COMPILE_RetargetingHelp
162162
"WALKING_CONTROLLERS_HAS_iDynTree;WALKING_CONTROLLERS_COMPILE_YarpUtilities;WALKING_CONTROLLERS_HAS_ICUB" OFF)
163163
walking_controllers_dependent_option(WALKING_CONTROLLERS_COMPILE_LoggerClient "Compile LoggerClient library?" ON WALKING_CONTROLLERS_COMPILE_YarpUtilities OFF)
164164

165+
walking_controllers_dependent_option(WALKING_CONTROLLERS_COMPILE_StepAdaptationController "Compile StepAdaptationController library?" ON
166+
"WALKING_CONTROLLERS_HAS_iDynTree;WALKING_CONTROLLERS_COMPILE_iDynTreeUtilities;WALKING_CONTROLLERS_COMPILE_YarpUtilities;WALKING_CONTROLLERS_COMPILE_TrajectoryPlanner;WALKING_CONTROLLERS_HAS_osqp;WALKING_CONTROLLERS_HAS_OsqpEigen" OFF)
167+
165168
walking_controllers_dependent_option(WALKING_CONTROLLERS_COMPILE_WalkingModule "Compile WalkingModule app?" ON
166-
"WALKING_CONTROLLERS_COMPILE_YarpUtilities;WALKING_CONTROLLERS_COMPILE_iDynTreeUtilities;WALKING_CONTROLLERS_COMPILE_RobotInterface;WALKING_CONTROLLERS_COMPILE_KinDynWrapper;WALKING_CONTROLLERS_COMPILE_TrajectoryPlanner;WALKING_CONTROLLERS_COMPILE_SimplifiedModelControllers;WALKING_CONTROLLERS_COMPILE_WholeBodyControllers;WALKING_CONTROLLERS_COMPILE_RetargetingHelper;WALKING_CONTROLLERS_COMPILE_LoggerClient;WALKING_CONTROLLERS_HAS_ICUBcontrib" OFF)
169+
"WALKING_CONTROLLERS_COMPILE_YarpUtilities;WALKING_CONTROLLERS_COMPILE_iDynTreeUtilities;WALKING_CONTROLLERS_COMPILE_RobotInterface;WALKING_CONTROLLERS_COMPILE_KinDynWrapper;WALKING_CONTROLLERS_COMPILE_TrajectoryPlanner;WALKING_CONTROLLERS_COMPILE_SimplifiedModelControllers;WALKING_CONTROLLERS_COMPILE_WholeBodyControllers;WALKING_CONTROLLERS_COMPILE_RetargetingHelper;WALKING_CONTROLLERS_COMPILE_LoggerClient;WALKING_CONTROLLERS_HAS_ICUBcontrib;WALKING_CONTROLLERS_COMPILE_StepAdaptationController" OFF)
167170

168171
walking_controllers_dependent_option(WALKING_CONTROLLERS_COMPILE_JoypadModule "Compile JoypadModule app?" ON "WALKING_CONTROLLERS_COMPILE_YarpUtilities;WALKING_CONTROLLERS_HAS_ICUBcontrib" OFF)
169172

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ add_subdirectory(LoggerClient)
1616
add_subdirectory(WalkingModule)
1717
add_subdirectory(JoypadModule)
1818
add_subdirectory(LoggerModule)
19+
add_subdirectory(StepAdaptationController)

src/RobotInterface/include/WalkingControllers/RobotInterface/Helper.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <yarp/dev/IPositionDirect.h>
2222
#include <yarp/dev/IVelocityControl.h>
2323
#include <yarp/dev/IInteractionMode.h>
24+
#include <yarp/dev/IImpedanceControl.h>
25+
2426
#include <yarp/sig/Vector.h>
2527
#include <yarp/os/Timer.h>
2628

@@ -53,7 +55,7 @@ namespace WalkingControllers
5355
yarp::dev::IControlMode *m_controlModeInterface{nullptr}; /**< Control mode interface. */
5456
yarp::dev::IControlLimits *m_limitsInterface{nullptr}; /**< Encorders interface. */
5557
yarp::dev::IInteractionMode *m_interactionInterface{nullptr}; /**< Stiff/compliant mode interface. */
56-
58+
yarp::dev::IImpedanceControl *m_impedanceControlInterface{nullptr};
5759
std::unique_ptr<WalkingPIDHandler> m_PIDHandler; /**< Pointer to the PID handler object. */
5860

5961
yarp::os::Bottle m_remoteControlBoards; /**< Contain all the name of the controlled joints. */
@@ -71,6 +73,9 @@ namespace WalkingControllers
7173
iDynTree::VectorDynSize m_jointVelocitiesBounds; /**< Joint Velocity bounds [rad/s]. */
7274
iDynTree::VectorDynSize m_jointPositionsUpperBounds; /**< Joint Position upper bound [rad]. */
7375
iDynTree::VectorDynSize m_jointPositionsLowerBounds; /**< Joint Position lower bound [rad]. */
76+
std::vector<yarp::dev::InteractionModeEnum> m_isJointModeStiffVector;/**< Joint is in the stiff or compliance mode */
77+
std::vector<yarp::dev::InteractionModeEnum> m_JointModeStiffVectorDefult;/**< All the joints are in the stiff mode */
78+
std::vector<yarp::dev::InteractionModeEnum> m_currentModeofJoints;/**< Joint is in the stiff or compliance mode based on the walking architecture phases */
7479
// yarp::sig::Vector m_positionFeedbackDegFiltered;
7580
yarp::sig::Vector m_velocityFeedbackDegFiltered; /**< Vector containing the filtered joint velocity [deg/s]. */
7681
std::unique_ptr<iCub::ctrl::FirstOrderLowPassFilter> m_positionFilter; /**< Joint position low pass filter .*/
@@ -89,6 +94,9 @@ namespace WalkingControllers
8994
std::unique_ptr<iCub::ctrl::FirstOrderLowPassFilter> m_rightWrenchFilter; /**< Right wrench low pass filter.*/
9095
bool m_useWrenchFilter; /**< True if the wrench filter is used. */
9196

97+
iDynTree::VectorDynSize m_stiffnessGainVector; /**< the vector of stifness gains for the joint */
98+
iDynTree::VectorDynSize m_dampingGainVector; /**< the vector of damping gains for the joint */
99+
std::vector<bool> m_jointModes; /**< True if the joint is in the stiff mode */
92100
double m_startingPositionControlTime;
93101
bool m_positionMoveSkipped;
94102

@@ -254,6 +262,11 @@ namespace WalkingControllers
254262
*/
255263
bool isExternalRobotBaseUsed();
256264

265+
/**
266+
* Set the impedance control gains of the joints(stiffness/damping).
267+
* @return true in case of success and false otherwise.
268+
*/
269+
bool setImpedanceControlGain();
257270
};
258271
};
259272
#endif

src/RobotInterface/src/Helper.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,27 @@ bool RobotInterface::configureRobot(const yarp::os::Searchable& config)
227227
m_jointInteractionMode.resize(m_actuatedDOFs);
228228
m_currentJointInteractionMode.resize(m_actuatedDOFs);
229229
std::vector<bool> isJointInStiffMode(m_actuatedDOFs);
230+
m_stiffnessGainVector.resize(m_actuatedDOFs);
231+
m_dampingGainVector.resize(m_actuatedDOFs);
230232
if(!YarpUtilities::getVectorOfBooleanFromSearchable(config, "joint_is_stiff_mode",
231233
isJointInStiffMode))
232234
{
233235
yError() << "[RobotInterface::configureRobot] Unable to find joint_is_stiff_mode into config file.";
234236
return false;
235237
}
236238

239+
if(!YarpUtilities::getVectorFromSearchable(config,"joint_stiffness_gain",m_stiffnessGainVector))
240+
{
241+
yError() << "[RobotInterface::configureRobot] Unable to find joint_stiffness_gain into config file.";
242+
return false;
243+
}
244+
245+
if(!YarpUtilities::getVectorFromSearchable(config,"joint_damping_gain",m_dampingGainVector))
246+
{
247+
yError() << "[RobotInterface::configureRobot] Unable to find joint_damping_gain into config file.";
248+
return false;
249+
}
250+
237251
for (unsigned int i = 0; i < m_actuatedDOFs; i++)
238252
{
239253
if(isJointInStiffMode[i])
@@ -306,6 +320,12 @@ bool RobotInterface::configureRobot(const yarp::os::Searchable& config)
306320
return false;
307321
}
308322

323+
if(!m_robotDevice.view(m_impedanceControlInterface) || !m_impedanceControlInterface)
324+
{
325+
yError() << "[configureRobot] Cannot obtain ImpedanceControl interface";
326+
return false;
327+
}
328+
309329
// resize the buffers
310330
m_positionFeedbackDeg.resize(m_actuatedDOFs, 0.0);
311331
m_velocityFeedbackDeg.resize(m_actuatedDOFs, 0.0);
@@ -637,6 +657,12 @@ bool RobotInterface::setPositionReferences(const iDynTree::VectorDynSize& desire
637657
return false;
638658
}
639659

660+
if(m_impedanceControlInterface == nullptr)
661+
{
662+
yError() << "[RobotInterface::setPositionReferences] IImpedanceControlInterface interface is not ready.";
663+
return false;
664+
}
665+
640666
m_desiredJointPositionRad = desiredJointPositionsRad;
641667

642668
std::pair<int, double> worstError(0, 0.0);
@@ -921,3 +947,17 @@ bool RobotInterface::loadCustomInteractionMode()
921947
{
922948
return setInteractionMode(m_jointInteractionMode);
923949
}
950+
951+
bool RobotInterface::setImpedanceControlGain()
952+
{
953+
for (unsigned i = 0; i < m_actuatedDOFs; i++)
954+
{
955+
if(!m_impedanceControlInterface->setImpedance(i,m_stiffnessGainVector(i),m_dampingGainVector(i)))
956+
{
957+
yError() << "[RobotInterface::setImpedanceControlGain] Error while setting the impedance control gains";
958+
return false;
959+
}
960+
}
961+
962+
return true;
963+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright (C) 2020 Fondazione Istituto Italiano di Tecnologia (IIT)
2+
# All Rights Reserved.
3+
# Authors: Milad Shafiee <milad.shafiee@iit.it>
4+
5+
if(WALKING_CONTROLLERS_COMPILE_StepAdaptationController)
6+
7+
# set target name
8+
set(LIBRARY_TARGET_NAME StepAdaptationController)
9+
10+
# set cpp files
11+
set(${LIBRARY_TARGET_NAME}_SRC
12+
src/StepAdaptationController.cpp
13+
src/DCMSimpleEstimator.cpp
14+
)
15+
16+
# set hpp files
17+
set(${LIBRARY_TARGET_NAME}_HDR
18+
include/WalkingControllers/StepAdaptationController/StepAdaptationController.hpp
19+
include/WalkingControllers/StepAdaptationController/DCMSimpleEstimator.hpp
20+
)
21+
22+
# add an executable to the project using the specified source files.
23+
add_library(${LIBRARY_TARGET_NAME} SHARED ${${LIBRARY_TARGET_NAME}_SRC} ${${LIBRARY_TARGET_NAME}_HDR})
24+
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_TARGET_NAME}")
25+
26+
target_link_libraries(${LIBRARY_TARGET_NAME} PUBLIC
27+
WalkingControllers::YarpUtilities
28+
WalkingControllers::iDynTreeUtilities
29+
WalkingControllers::TrajectoryPlanner
30+
osqp::osqp
31+
OsqpEigen::OsqpEigen
32+
${qpOASES_LIBRARIES})
33+
34+
35+
add_library(WalkingControllers::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME})
36+
37+
set_target_properties(${LIBRARY_TARGET_NAME} PROPERTIES VERSION ${WalkingControllers_VERSION}
38+
PUBLIC_HEADER "${${LIBRARY_TARGET_NAME}_HDR}")
39+
40+
#Specify include directories for both compilation and installation process.
41+
#The $<INSTALL_PREFIX> generator expression is useful to ensure to create
42+
#relocatable configuration files, see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-relocatable-packages
43+
target_include_directories(${LIBRARY_TARGET_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
44+
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
45+
46+
# Specify installation targets, typology and destination folders.
47+
install(TARGETS ${LIBRARY_TARGET_NAME}
48+
EXPORT ${PROJECT_NAME}
49+
COMPONENT runtime
50+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
51+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
52+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
53+
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/WalkingControllers/StepAdaptationController" COMPONENT dev)
54+
55+
set_property(GLOBAL APPEND PROPERTY WalkingControllers_TARGETS ${LIBRARY_TARGET_NAME})
56+
57+
message(STATUS "Created target ${LIBRARY_TARGET_NAME} for export ${PROJECT_NAME}.")
58+
59+
endif()
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @file DCMSimpleEstimator.hpp
3+
* @authors Milad Shafiee <milad.shafiee@iit.it>
4+
* @copyright 2020 iCub Facility - Istituto Italiano di Tecnologia
5+
* Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
6+
* @date 2020
7+
*/
8+
9+
#ifndef WALKING_CONTROLLERS_DCM_SIMPLE_ESTIMATOR_H
10+
#define WALKING_CONTROLLERS_DCM_SIMPLE_ESTIMATOR_H
11+
12+
// YARP
13+
#include <yarp/os/Searchable.h>
14+
#include <yarp/sig/Vector.h>
15+
16+
//iDynTree
17+
#include <iDynTree/Core/VectorFixSize.h>
18+
#include <iDynTree/Core/Transform.h>
19+
#include <iDynTree/Core/LinearMotionVector3.h>
20+
21+
22+
namespace WalkingControllers
23+
{
24+
/**
25+
* The theory related to this simple estimator has been discussed in the following github issue:
26+
*https://github.com/robotology/walking-controllers/issues/61
27+
*/
28+
class DCMSimpleEstimator
29+
{
30+
double m_omega; /**< Inverted time constant of the 3D-LIPM. */
31+
double m_mass; /**< Mass of the robot. */
32+
iDynTree::Vector2 m_dcmEstimatedPosition; /**< Position of the estimated DCM. */
33+
iDynTree::Vector2 m_dcmPosition; /**< Position of the DCM. */
34+
iDynTree::Vector2 m_dcmVelocity; /**< Velocity of the dcm. */
35+
36+
public:
37+
38+
/**
39+
* Config the DCMEstimator.
40+
* @param config config of the simple DCM estimator;
41+
* @return true on success, false otherwise.
42+
*/
43+
bool configure(const yarp::os::Searchable& config);
44+
45+
/**
46+
* Get the position of the DCM.
47+
* @return position of the DCM.
48+
*/
49+
const iDynTree::Vector2& getDCMPosition() const;
50+
51+
/**
52+
* run the pendulum estimator
53+
* @param footOrientation the orientation of stance foot.
54+
* @param zmp the vector of zmp position with respect to the inertial frame.
55+
* @param com com the com position obtained as if the foot is not rotated.
56+
* @param CoMVelocity3d the vector of com velocity that is simple time derivative of the com position.
57+
* @return true/false in case of success/failure
58+
*/
59+
bool update(const iDynTree::Rotation& footOrientation,const iDynTree::Vector3& zmp,const iDynTree::Vector3& com,const iDynTree::LinVelocity& CoMVelocity3d);
60+
};
61+
};
62+
63+
#endif

0 commit comments

Comments
 (0)