Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ylo3-real-robot-controller-on-quad-sdk-noetic-ekf-hardware #338

Open
wants to merge 53 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e32fba2
update
elpimous Jan 28, 2023
da3bd57
update
elpimous Jan 28, 2023
a1830f7
update
elpimous Jan 28, 2023
92b18dc
personal use only
elpimous Jan 28, 2023
1233f42
new pictures
elpimous Jan 28, 2023
a2119a6
Update README.md
elpimous Jan 28, 2023
57a4714
Update README.md
elpimous Jan 28, 2023
03bdbd2
Update README.md
elpimous Jan 28, 2023
18adc91
ylo2 robot integration
elpimous Feb 2, 2023
d5022a1
Merge remote-tracking branch 'origin/main' into main
elpimous Feb 2, 2023
d80adbb
ylo2 imu node integration
elpimous Feb 5, 2023
bee076a
ylo2 imu integration
elpimous Feb 5, 2023
3ba55bc
ylo2 motors controller library
elpimous Feb 5, 2023
0f4108d
ylo2 integration
elpimous Feb 5, 2023
9a359ab
ylo hardware interface
elpimous Feb 5, 2023
027effe
deleted
elpimous Feb 5, 2023
32e2a1a
adding moteus controller for ylo2
elpimous Feb 5, 2023
0d5abfd
adding param => is_hardware, in bringup launch
elpimous Feb 7, 2023
a0a9444
working on send and recv functions, for moteus controllers
elpimous Feb 7, 2023
2753789
removing unneeded part
elpimous Feb 7, 2023
8e1cb21
imu integration
elpimous Feb 7, 2023
bb6fe74
imu integration problems
elpimous Feb 7, 2023
b94fbae
removing unneeded part
elpimous Feb 9, 2023
3b530a5
Update README.md
elpimous Feb 11, 2023
6161d84
adding ylo2 stand & walk animated gif
elpimous Feb 11, 2023
3723628
adding ylo2 stand & walk animated gif
elpimous Feb 11, 2023
3929a7d
update
elpimous Feb 11, 2023
cce2e78
Added support and test for recording IMU data
QuentinOlivierISFM Feb 11, 2023
1bd9191
Merge pull request #1 from QuenOlivier/feature/add_imu_support
elpimous Feb 11, 2023
45ca72a
Deuxieme test
QuentinOlivierISFM Feb 12, 2023
ce5d2ea
Merge pull request #2 from QuenOlivier/feature/add_imu_support
elpimous Feb 12, 2023
2889bbc
working ylo2 hardware, under a1 naming (for now)
elpimous Mar 18, 2023
a71a52f
ylo2_description working
elpimous Mar 18, 2023
7b4b2e4
minor changes
elpimous Mar 18, 2023
b657481
minor changes
elpimous Mar 18, 2023
a1eff34
minor changes
elpimous Mar 18, 2023
c06904a
minor changes
elpimous Mar 18, 2023
81c581b
Update README.md
elpimous Mar 18, 2023
25ed4f8
standup video
elpimous Mar 18, 2023
0d47230
Update README.md
elpimous Mar 18, 2023
584f5f7
Update README.md
elpimous Mar 18, 2023
d242dcf
Update README.md
elpimous May 15, 2023
9514dd5
Update README.md
elpimous May 15, 2023
6001fae
some minor changes
elpimous Jul 19, 2023
debf51f
adding videos, and ylo2 installation guide
elpimous Jul 19, 2023
52ba62d
adding video
elpimous Jul 19, 2023
ecdd79c
new launchs
elpimous Jul 19, 2023
32186c5
Update README.md
elpimous Jul 19, 2023
6114d37
Update README.md
elpimous Jul 19, 2023
4be5830
Update README.md
elpimous Jul 26, 2023
3f1311c
noetic_ekf_clean_real_ylo2
elpimous Nov 15, 2023
f3ed0c0
noetic_ekf_clean_real_ylo2
elpimous Nov 15, 2023
17b6bbe
Adding files for new noetic_ekf_hardware_on_a_non_unitree_robot
Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions body_force_estimator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
cmake_minimum_required(VERSION 3.0.2)
project(body_force_estimator)

## Compile as C++14, supported in ROS Melodic and newer
add_compile_options(-std=c++14)

## Set default cmake build type to release
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
quad_msgs
quad_utils
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a exec_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
# add_message_files(
# FILES
# Message1.msg
# Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
# FILES
# Service1.srv
# Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )

## Generate added messages and services with any dependencies listed here
# generate_messages(
# DEPENDENCIES
# std_msgs
# )

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
# cfg/DynReconf1.cfg
# cfg/DynReconf2.cfg
# )

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
INCLUDE_DIRS include
# LIBRARIES body_force_estimator
CATKIN_DEPENDS roscpp std_msgs quad_msgs quad_utils
# DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
include
${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
add_library(${PROJECT_NAME}
src/body_force_estimator.cpp
src/body_force_estimator_dynamics.cpp
)

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
add_executable(${PROJECT_NAME}_node src/body_force_estimator_node.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
target_link_libraries(body_force_estimator_node
body_force_estimator
${catkin_LIBRARIES}
)

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
catkin_install_python(PROGRAMS
scripts/leg_flail.py
scripts/path_following.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
catkin_add_gtest(${PROJECT_NAME}-test test/test_body_force_estimator.cpp)
target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME} ${catkin_LIBRARIES})

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
4 changes: 4 additions & 0 deletions body_force_estimator/body_force_estimator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body_force_estimator:
update_rate: 250
K_O: 25 # 50
cancel_friction: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#ifndef BODY_FORCE_ESTIMATOR_H
#define BODY_FORCE_ESTIMATOR_H

#include <quad_msgs/BodyForceEstimate.h>
#include <quad_msgs/GRFArray.h>
#include <quad_msgs/RobotPlan.h>
#include <quad_msgs/RobotState.h>
#include <quad_utils/math_utils.h>
#include <quad_utils/ros_utils.h>
#include <ros/ros.h>

//! Estimates body contact forces
/*!
BodyForceEstimator is a container for all logic used in estimating force from
contacts distrbuted across all links of the robot. It requires robot state
estimates and motor commands and exposes an update method.
*/
class BodyForceEstimator {
public:
/**
* @brief Constructor for BodyForceEstimator Class
* @param[in] nh ROS NodeHandle to publish and subscribe from
* @return Constructed object of type BodyForceEstimator
*/
BodyForceEstimator(ros::NodeHandle nh);

/**
* @brief Calls ros spinOnce and pubs data at set frequency
*/
void spin();

/**
* @brief Callback function to handle new state estimates
* @param[in] Robot state message contining position and velocity for each
* joint and robot body
*/
void robotStateCallback(const quad_msgs::RobotState::ConstPtr& msg);

/**
* @brief Callback function to handle new local plan (states and GRFs)
* @param[in] msg input message contining the local plan
*/
void localPlanCallback(const quad_msgs::RobotPlan::ConstPtr& msg);

/**
* @brief Compute the momentum observer external force estimation update.
*/
void update();

/**
* @brief Publish body force force estimates
*/
void publishBodyForce();

/// ROS subscriber for the robot state
ros::Subscriber robot_state_sub_;

/// ROS subscriber for local plan
ros::Subscriber local_plan_sub_;

/// ROS publisher for body force force estimates
ros::Publisher body_force_pub_;

/// ROS publisher for toe force estimates
ros::Publisher toe_force_pub_;

/// Nodehandle to pub to and sub from
ros::NodeHandle nh_;

/// Update rate for sending and receiving data;
double update_rate_;

/// Momentum observer gain
double K_O_;

/// Momentum observer cancel friction or not
int cancel_friction_;

private:
/// External torque estimate
double r_mom[12];

/// Momentum estimate
double p_hat[12];

/// Most recent local plan
quad_msgs::RobotPlan::ConstPtr last_local_plan_msg_;

/// Previous foot state
quad_msgs::MultiFootState past_feet_state_;

// Robot state estimate
quad_msgs::RobotState::ConstPtr last_state_msg_;
};

#endif // BODY_FORCE_ESTIMATOR_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef FORCE_ESTIMATOR_DYNAMICS_H
#define FORCE_ESTIMATOR_DYNAMICS_H

#include <math.h>
#include <ros/ros.h>

#include <eigen3/Eigen/Dense>

namespace force_estimation_dynamics {
void f_M(Eigen::Vector3d q, int RL, Eigen::Matrix3d &F);
void f_beta(Eigen::Vector3d q, Eigen::Vector3d qd, int RL, Eigen::Vector3d &F);
void f_J_MO(Eigen::Vector3d q, int RL, Eigen::Matrix3d &F);

extern double MO_fric[3];
extern double MO_damp[3];
extern double MO_ktau[3];
} // namespace force_estimation_dynamics

#endif // FORCE_ESTIMATOR_DYNAMICS_H
Loading