-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 in SWDEV/franka_ros from SRR-1528 to develop
* commit '249c593c8ff4d3f476dd74d5e7bfbf67d0a9d206': (22 commits) ADD: Integration test verifying that user stops stops joint in Gazebo ADD: Make interactive marker configurable in `panda.launch` FIX: Allow finger joints to still be controlled while not in Move FIX: Don't stop finger joints on error recovery FIX: ROS_WARN message on user stop FIX: Don't recovery from errors when user stop still pressed ADD: CHANGELOG entry FIX: Make linter happy ADD: Statemachine tests ADD: Warning to FrankaHWSim::error_recovery action CHANGE: Restart all running controllers on error_recovery CHANGE: Extract `getDesiredXXX()` logic into Joint class FIX: Don't switch control method on user stop ADD: `error_recovery` action to FrankaHWSim CHANGE: Extract motion generators into separate functions CHANGE: Set `control_method` in statemachine actions ADD: FrankaHWSim offers `set_user_stop` service ADD: Allow position control for prismatic joints CHANGE: Properly distinguish between Position & Internal control ADD: Control state machine to franka_gazebo ...
- Loading branch information
Showing
14 changed files
with
804 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#pragma once | ||
|
||
#include <franka/robot_state.h> | ||
#include <franka_gazebo/joint.h> | ||
|
||
#include <ros/ros.h> | ||
#include <boost_sml/sml.hpp> | ||
#include <map> | ||
#include <memory> | ||
#include <string> | ||
|
||
namespace franka_gazebo { | ||
|
||
using JointMap = std::map<std::string, std::shared_ptr<Joint>>; | ||
|
||
// States | ||
struct Idle {}; | ||
struct Move {}; | ||
struct UserStopped {}; | ||
|
||
// Events | ||
struct ErrorRecovery {}; | ||
struct SwitchControl {}; | ||
struct UserStop { | ||
bool pressed; | ||
}; | ||
|
||
// Guards | ||
auto contains = [](const auto& haystack, const auto& needle) { | ||
return haystack.find(needle) != std::string::npos; | ||
}; | ||
auto isPressed = [](const UserStop& event) { return event.pressed; }; | ||
auto isReleased = [](const UserStop& event, const JointMap& joints) { return not event.pressed; }; | ||
auto isStarting = [](const SwitchControl& event, const JointMap& joints) { | ||
for (auto& joint : joints) { | ||
if (contains(joint.first, "_finger_joint")) { | ||
continue; | ||
} | ||
if (joint.second->control_method) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
auto isStopping = [](const SwitchControl& event, const JointMap& joints) { | ||
return not isStarting(event, joints); | ||
}; | ||
|
||
// Actions | ||
auto start = [](franka::RobotState& state) { state.robot_mode = franka::RobotMode::kMove; }; | ||
auto idle = [](franka::RobotState& state) { state.robot_mode = franka::RobotMode::kIdle; }; | ||
auto stop = [](franka::RobotState& state, JointMap& joints) { | ||
ROS_WARN("User stop pressed, stopping robot"); | ||
state.robot_mode = franka::RobotMode::kUserStopped; | ||
state.q_d = state.q; | ||
state.dq_d = {0}; | ||
state.ddq_d = {0}; | ||
|
||
for (auto& joint : joints) { | ||
if (contains(joint.first, "_finger_joint")) { | ||
continue; | ||
} | ||
joint.second->stop_position = joint.second->position; | ||
joint.second->desired_position = joint.second->position; | ||
joint.second->desired_velocity = 0; | ||
} | ||
}; | ||
|
||
struct StateMachine { | ||
auto operator()() const { | ||
using namespace boost::sml; | ||
return make_transition_table( | ||
// clang-format off | ||
*state<Idle> + event<SwitchControl>[isStarting] / start = state<Move>, | ||
state<Idle> + event<UserStop>[isPressed] / stop = state<UserStopped>, | ||
state<Idle> + event<ErrorRecovery> / start = state<Move>, | ||
state<Move> + event<SwitchControl>[isStopping] / idle = state<Idle>, | ||
state<Move> + event<UserStop>[isPressed] / stop = state<UserStopped>, | ||
state<UserStopped> + event<UserStop>[isReleased] / idle = state<Idle> | ||
// clang-format on | ||
); | ||
} | ||
}; | ||
} // namespace franka_gazebo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.