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

Use foot sensor to detect steps / rework pressure converter. #337

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b58555a
add pressure filter
val-ba Nov 20, 2023
31bdc89
make it work
val-ba Nov 20, 2023
9a2ee55
move support state detector to own node
val-ba Nov 20, 2023
3db2077
add node to launch
val-ba Nov 22, 2023
769eb1c
add debug and low pass
val-ba Nov 22, 2023
aaff146
add step duration threshold
val-ba Nov 22, 2023
3c9cf6c
add parameter library
val-ba Nov 24, 2023
25b00c5
add parameter tuning
val-ba Nov 24, 2023
ab44063
remove unused variables and comments
val-ba Nov 24, 2023
4b09f36
move step_detector from old repo to mono
val-ba Feb 2, 2024
ee29308
fix includes
val-ba Feb 2, 2024
8b48f0d
update support foot detector with debug options
val-ba Feb 5, 2024
c53f5eb
fix double usage of left instead of right
val-ba Feb 5, 2024
353e9c4
write out left and right
val-ba Feb 5, 2024
8c8b36b
change description of parameters
val-ba Feb 5, 2024
e8013ee
add foot to wolfgang yaml again
val-ba Feb 5, 2024
45a2276
add foot pressure sensors and sensors filtered
val-ba Feb 5, 2024
2e45853
fix typo in pressure_converter.launch
val-ba Feb 5, 2024
98d1ce0
update amy config and undo renaming nobot to robot
val-ba Feb 6, 2024
1f255bd
use phase::message constants instead of numbers and add seperate para…
val-ba Feb 6, 2024
ac7eda2
update odometry yaml values for real world
val-ba Feb 6, 2024
5474165
add sim yaml
val-ba Feb 7, 2024
57430cb
update ros_control launch
val-ba Mar 29, 2024
68a3221
Merge branch 'main' of github.com:bit-bots/bitbots_main into feature/…
Flova Jun 3, 2024
01efbd4
Fix merge conflicts (again)??
Flova Jun 3, 2024
2b18ec5
Untangle odometry and step detector
Flova Jun 3, 2024
4391467
Fix odom deps
Flova Jun 3, 2024
cab4914
Fix odom launch file
Flova Jun 3, 2024
f6618ad
Migrate to non header setup
Flova Jun 3, 2024
07a328e
Remove walk from name
Flova Jun 3, 2024
9425fc3
Apply autoformat
Flova Jun 3, 2024
247ac22
Cleanup and apply feedback from the pr review
Flova Jun 3, 2024
fbe385e
Append
Flova Jun 3, 2024
f9080f3
Cleanup preassure converter
Flova Jun 3, 2024
9497d86
Fix formatting
Flova Jun 3, 2024
a145735
Fix
Flova Jun 3, 2024
6b23f87
Remove dep
Flova Jun 3, 2024
42e8ad9
Fix runtime errors
Flova Jun 3, 2024
64098ee
Fix init
Flova Jun 3, 2024
4e4de7e
Merge branch 'main' into feature/use_foot_pressure_step_detection
jaagut Jun 15, 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
32 changes: 16 additions & 16 deletions bitbots_lowlevel/bitbots_ros_control/config/pressure_amy.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
pressure_converter:
ros__parameters:
zero_r:
- -27455372.92
- 14459386.46
- 17952654.76
- -10605254.74
- -66830780.078431375
- 5538079.1372549022
- -24570754.156862747
- -168909925.33333334
zero_l:
- -14063383.6
- 30331751.92
- -2034247.26
- 48130515.2
- -3166809.769230769
- -58675654.461538464
- 18054924.769230768
- -2147483648.0
scale_r:
- 2.879445523352348e-06
- -2.252145560713656e-05
- -2.754225471994077e-06
- 2.763926644524643e-06
- 0.00044307157572154597
- -1.7351776459253373e-05
- -0.00047527688810231853
- -0.00079238401835424893
scale_l:
- 2.879445523352348e-06
- -2.252145560713656e-05
- -2.754225471994077e-06
- 2.763926644524643e-06
- 0.0014725335760224815
- -3.8384549952827295e-06
- 0.00047995524568892787
- .inf
9 changes: 9 additions & 0 deletions bitbots_lowlevel/bitbots_ros_control/config/wolfgang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ wolfgang_hardware_interface:
interface_type: LED
number_of_LEDs: 3
start_number: 3

LeftFoot:
id: 102
topic: /foot_pressure_left/raw
model_number: 0
RightFoot:
id: 101
topic: /foot_pressure_right/raw
model_number: 0
# Removed head imu at worldcup due to motorbus issues
#IMU_head:
# id: 242
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<include file="$(find-pkg-share system_monitor)/launch/system_monitor.launch"/>
<include file="$(find-pkg-share bitbots_buttons)/launch/buttons.launch"/>
<include file="$(find-pkg-share humanoid_league_speaker)/launch/speaker.launch"/>
<!--include file="$(find-pkg-share bitbots_ros_control)/launch/pressure_converter.launch"/-->
<include file="$(find-pkg-share bitbots_ros_control)/launch/pressure_converter.launch"/>
</group>

</launch>
Expand Down
30 changes: 27 additions & 3 deletions bitbots_motion/bitbots_odometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(biped_interfaces REQUIRED)
find_package(bitbots_docs REQUIRED)
find_package(bitbots_msgs REQUIRED)
find_package(bitbots_utils REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(generate_parameter_library REQUIRED)
Expand All @@ -22,6 +23,7 @@ find_package(tf2 REQUIRED)
find_package(tf2_eigen REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(std_msgs REQUIRED)

generate_parameter_library(odometry_parameters
config/odometry_config_template.yaml)
Expand All @@ -32,15 +34,23 @@ add_compile_options(-Wall -Werror -Wno-unused)

add_executable(odometry_fuser src/odometry_fuser.cpp)
add_executable(motion_odometry src/motion_odometry.cpp)
add_executable(walk_support_state_detector src/walk_support_state_detector.cpp)

target_link_libraries(motion_odometry rclcpp::rclcpp odometry_parameters)

# Specify libraries to link a library or executable target against
target_link_libraries(
walk_support_state_detector
rclcpp::rclcpp
odometry_parameters
)

## Specify libraries to link a library or executable target against
ament_target_dependencies(
motion_odometry
ament_cmake
biped_interfaces
bitbots_docs
bitbots_msgs
bitbots_utils
generate_parameter_library
geometry_msgs
Expand All @@ -52,7 +62,17 @@ ament_target_dependencies(
tf2
tf2_eigen
tf2_geometry_msgs
tf2_ros)
tf2_ros
std_msgs
)

ament_target_dependencies(
walk_support_state_detector
bitbots_msgs
biped_interfaces
generate_parameter_library
std_msgs
)

ament_target_dependencies(
odometry_fuser
Expand All @@ -78,7 +98,11 @@ install(TARGETS motion_odometry DESTINATION lib/${PROJECT_NAME})

install(TARGETS odometry_fuser DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
install(TARGETS walk_support_state_detector
DESTINATION lib/${PROJECT_NAME})

install(DIRECTORY launch
DESTINATION share/${PROJECT_NAME})

install(DIRECTORY config DESTINATION share/${PROJECT_NAME})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,67 @@ motion_odometry:
default_value: false,
description: "Should odom tf be published"
}

k: {
type: double,
default_value: 0.97,
description: "Factor for lowpass filtering the foot pressure",
validation: {
bounds<>: [0.0, 1.0]
}
}


m: {
type: double,
default_value: 0.95,
description: "Factor for lowpass filtering the step duration. This only plays a role if temporal_step_offset is not 0.",
validation: {
bounds<>: [0.0, 1.0]
}
}

temporal_step_offset_factor: {
type: double,
default_value: 0.0,
description: "Offset factor for taking the time stamp when the robot really stands on one foot. 1 means waiting until the steps is finished, 0 means taking the first time stamp when robots start standing",
validation: {
bounds<>: [0.0, 1.0]
}
}

summed_pressure_threshold_right: {
type: int,
default_value: 2500,
description: "Threshold for detecting whether the robot really stands on right foot. If they overlap, the robot is considered to stand on both feet.",
validation: {
bounds<>: [0, 5000]
}
}

summed_pressure_threshold_left: {
type: int,
default_value: 2500,
description: "Threshold for detecting whether the robot really stands on left foot",
validation: {
bounds<>: [0, 5000]
}
}

foot_pressure_topic_left: {
type: string,
default_value: "cod",
Flova marked this conversation as resolved.
Show resolved Hide resolved
description: "Topic for the left foot pressure sensor"
}

foot_pressure_topic_right: {
type: string,
default_value: "foot_pressure_right/filtered",
description: "Topic for the right foot pressure sensor"
}

debug: {
type: bool,
default_value: true,
description: "Whether debug information should be published"
}
16 changes: 16 additions & 0 deletions bitbots_motion/bitbots_odometry/config/odometry_conifg_sim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
motion_odometry:
ros__parameters:
x_forward_scaling: 1.25
x_backward_scaling: 0.95
y_scaling: 1.0
yaw_scaling: 0.6
publish_walk_odom_tf: false
k: 0.7
m: 0.95
temporal_step_offset_factor: 0.0
summed_pressure_threshold_right: 30
summed_pressure_threshold_left: 30
foot_pressure_topic_left: "foot_pressure_left/raw"
foot_pressure_topic_right: "foot_pressure_right/raw"
debug: true

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <tf2_ros/transform_broadcaster.h>
#include <tf2_ros/transform_listener.h>
#include <unistd.h>

#include "odometry_parameters.hpp"
#include <biped_interfaces/msg/phase.hpp>
#include <bitbots_utils/utils.hpp>
#include <nav_msgs/msg/odometry.hpp>
Expand All @@ -12,9 +12,8 @@
#include <sensor_msgs/msg/joint_state.hpp>
#include <std_msgs/msg/char.hpp>
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>

#include "odometry_parameters.hpp"

#include <unistd.h>
#include <bitbots_msgs/msg/foot_pressure.hpp>
using std::placeholders::_1;

namespace bitbots_odometry {
Expand Down Expand Up @@ -52,6 +51,7 @@ class MotionOdometry : public rclcpp::Node {
std::string previous_support_link_;
std::string current_support_link_;
rclcpp::Time start_time_;

};

} // namespace bitbots_odometry
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <rclcpp/rclcpp.hpp>
#include "odometry_parameters.hpp"
#include <biped_interfaces/msg/phase.hpp>

#include <bitbots_msgs/msg/foot_pressure.hpp>
#include <std_msgs/msg/float64.hpp>
using std::placeholders::_1;

namespace bitbots_odometry {

class WalkSupportStateDetector: public rclcpp::Node {
public:
WalkSupportStateDetector();
void loop();
private:
rclcpp::Subscription<bitbots_msgs::msg::FootPressure>::SharedPtr pressure_left_sub_;
rclcpp::Subscription<bitbots_msgs::msg::FootPressure>::SharedPtr pressure_right_sub_;
rclcpp::Publisher<biped_interfaces::msg::Phase>::SharedPtr pub_foot_pressure_support_state_;

void pressure_left_callback(bitbots_msgs::msg::FootPressure msg);
void pressure_right_callback(bitbots_msgs::msg::FootPressure msg);
int curr_stand_left_;
int curr_stand_right_;
int prev_stand_right_;
int prev_stand_left_;
float_t pressure_filtered_left_;
float_t pressure_filtered_right_;

long step_duration_right_;
rclcpp::Time up_right_;

long step_duration_left_;
rclcpp::Time up_left_;
biped_interfaces::msg::Phase curr_stance_;

// Declare parameter listener and struct from the generate_parameter_library
motion_odometry::ParamListener param_listener_;
// Datastructure to hold all parameters, which is build from the schema in the 'parameters.yaml'
motion_odometry::Params config_;

// if debug is true, publish a debug for summed pressure
rclcpp::Publisher<std_msgs::msg::Float64>::SharedPtr pub_summed_pressure_left_;
rclcpp::Publisher<std_msgs::msg::Float64>::SharedPtr pub_summed_pressure_right_;
};

}
15 changes: 15 additions & 0 deletions bitbots_motion/bitbots_odometry/launch/odometry.launch
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,19 @@
<param name="cop_frame" value="$(var tf_prefix)cop"/>
<param name="use_sim_time" value="$(var sim)"/>
</node>

<group unless="$(var sim)">
<node name="walk_support_state_detector" pkg="bitbots_odometry" exec="walk_support_state_detector" launch-prefix="$(var taskset)">
<!-- for the normal walk_support_state_detector_default values are set and do not need to be loaded-->

</node>
</group>
<group if="$(var sim)">
<node name="walk_support_state_detector" pkg="bitbots_odometry" exec="walk_support_state_detector" launch-prefix="$(var taskset)">
<param name="use_sim_time" value="$(var sim)"/>
<param from="$(find-pkg-share bitbots_odometry)/config/odometry_config_sim.yaml"/>
</node>
</group>


</launch>
1 change: 1 addition & 0 deletions bitbots_motion/bitbots_odometry/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<buildtool_depend>ament_cmake</buildtool_depend>
<depend>biped_interfaces</depend>
<depend>bitbots_docs</depend>
<depend>bitbots_msgs</depend>
<depend>bitbots_utils</depend>
<depend>generate_parameter_library</depend>
<depend>message_filters</depend>
Expand Down
28 changes: 20 additions & 8 deletions bitbots_motion/bitbots_odometry/src/motion_odometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ MotionOdometry::MotionOdometry() : Node("MotionOdometry"), param_listener_(get_n
current_support_state_ = -1;
previous_support_state_ = -1;

walk_support_state_sub_ = this->create_subscription<biped_interfaces::msg::Phase>(
"walk_support_state", 1, std::bind(&MotionOdometry::supportCallback, this, _1));
kick_support_state_sub_ = this->create_subscription<biped_interfaces::msg::Phase>(
"dynamic_kick_support_state", 1, std::bind(&MotionOdometry::supportCallback, this, _1));
odom_subscriber_ = this->create_subscription<nav_msgs::msg::Odometry>(
"walk_engine_odometry", 1, std::bind(&MotionOdometry::odomCallback, this, _1));
walk_support_state_sub_ =
this->create_subscription<biped_interfaces::msg::Phase>("foot_pressure/walk_support_state",
1,
std::bind(&MotionOdometry::supportCallback,
this, _1));
kick_support_state_sub_ =
this->create_subscription<biped_interfaces::msg::Phase>("dynamic_kick_support_state",
1,
std::bind(&MotionOdometry::supportCallback,
this, _1));
odom_subscriber_ =
this->create_subscription<nav_msgs::msg::Odometry>("walk_engine_odometry",
1,
std::bind(&MotionOdometry::odomCallback, this, _1));

pub_odometry_ = this->create_publisher<nav_msgs::msg::Odometry>("motion_odometry", 1);
// set the origin to 0. will be set correctly on recieving first support state
Expand All @@ -36,6 +44,9 @@ MotionOdometry::MotionOdometry() : Node("MotionOdometry"), param_listener_(get_n
foot_change_time_ = rclcpp::Time(0, 0, RCL_ROS_TIME);
previous_support_link_ = r_sole_frame_;
start_time_ = this->now();



}

void MotionOdometry::loop() {
Expand Down Expand Up @@ -154,7 +165,7 @@ void MotionOdometry::loop() {
void MotionOdometry::supportCallback(const biped_interfaces::msg::Phase::SharedPtr msg) {
current_support_state_ = msg->phase;
current_support_state_time_ = msg->header.stamp;

// remember if we received first support state, only remember left or right
if (previous_support_state_ == -1 && current_support_state_ != biped_interfaces::msg::Phase::DOUBLE_STANCE) {
std::string current_support_link;
Expand Down Expand Up @@ -183,7 +194,8 @@ void MotionOdometry::supportCallback(const biped_interfaces::msg::Phase::SharedP

void MotionOdometry::odomCallback(const nav_msgs::msg::Odometry::SharedPtr msg) { current_odom_msg_ = *msg; }

} // namespace bitbots_odometry

}

int main(int argc, char **argv) {
rclcpp::init(argc, argv);
Expand Down
Loading
Loading