refactor: remove command_mode from configuration and related files
This commit is contained in:
@@ -2,7 +2,6 @@ robot:
|
||||
name: "iiwa7"
|
||||
ip: "192.170.10.2"
|
||||
port: 30200
|
||||
command_mode: "position" # torque, position
|
||||
fri_cycle_ms: 10 # период FRI-цикла: 5 мс (200 Гц) или 10 мс (100 Гц)
|
||||
joint_position_tau: 0.04 # EMA фильтр позиций [с]: сглаживает команды перед отправкой в FRI
|
||||
joint_velocity_tau: 0.01 # EMA фильтр скорости [с]: убирает выбросы конечных разностей
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
from launch import LaunchDescription
|
||||
from launch.actions import (
|
||||
DeclareLaunchArgument,
|
||||
EmitEvent,
|
||||
IncludeLaunchDescription,
|
||||
OpaqueFunction,
|
||||
RegisterEventHandler,
|
||||
)
|
||||
from launch.conditions import IfCondition
|
||||
from launch.event_handlers import OnProcessExit
|
||||
from launch.events import Shutdown
|
||||
from launch.launch_description_sources import PythonLaunchDescriptionSource
|
||||
from launch.substitutions import LaunchConfiguration, PathJoinSubstitution
|
||||
from launch_ros.actions import Node
|
||||
from launch_ros.substitutions import FindPackageShare
|
||||
from moveit_configs_utils import MoveItConfigsBuilder
|
||||
|
||||
from iiwa_utils import converter, setting_loader
|
||||
|
||||
|
||||
def _runtime_setup(context, *args, **kwatgs):
|
||||
setup = []
|
||||
|
||||
settings = setting_loader.build_settings(
|
||||
settings_path=LaunchConfiguration("setting").perform(context), check_files=True
|
||||
)
|
||||
|
||||
robot_description = converter.load_robot_description(
|
||||
model_path=settings.robot.description,
|
||||
robot_name=settings.robot.name,
|
||||
xacro_args={
|
||||
"initial_positions_file": settings.controller.moveit.initial_positions
|
||||
},
|
||||
)
|
||||
|
||||
rsp_node = Node(
|
||||
package="robot_state_publisher",
|
||||
executable="robot_state_publisher",
|
||||
name="robot_state_publisher",
|
||||
output="screen",
|
||||
parameters=[{"robot_description": robot_description, "use_sim_time": True}],
|
||||
)
|
||||
|
||||
webots_launch = IncludeLaunchDescription(
|
||||
PythonLaunchDescriptionSource(
|
||||
PathJoinSubstitution(
|
||||
[
|
||||
FindPackageShare("iiwa_bringup"),
|
||||
"launch",
|
||||
"supported",
|
||||
"webots_spawn.launch.py",
|
||||
]
|
||||
)
|
||||
),
|
||||
launch_arguments={
|
||||
"robot_name": str(settings.robot.name),
|
||||
"description": str(settings.robot.description),
|
||||
"world": str(settings.digital_twin.webots.world),
|
||||
"transform": str(settings.digital_twin.webots.transform),
|
||||
"rotation": str(settings.digital_twin.webots.rotation),
|
||||
"controller_timer": str(settings.digital_twin.webots.controller_timer),
|
||||
"controller": str(settings.controller.controller_path),
|
||||
"initial_positions_file": str(settings.controller.moveit.initial_positions),
|
||||
}.items(),
|
||||
)
|
||||
|
||||
moveit_configs = (
|
||||
MoveItConfigsBuilder("iiwa7", package_name="iiwa_config")
|
||||
.robot_description(
|
||||
file_path=settings.robot.description,
|
||||
mappings={
|
||||
"initial_positions_file": settings.controller.moveit.initial_positions
|
||||
},
|
||||
)
|
||||
.robot_description_semantic(file_path=settings.controller.moveit.srdf)
|
||||
.robot_description_kinematics(file_path=settings.controller.moveit.kinematics)
|
||||
.joint_limits(file_path=settings.controller.moveit.joint_limits)
|
||||
.pilz_cartesian_limits(file_path=settings.controller.moveit.pilz_limits)
|
||||
.trajectory_execution(file_path=settings.controller.moveit.moveit_controllers)
|
||||
.moveit_cpp(file_path=settings.controller.moveit.moveit_cpp)
|
||||
.to_moveit_configs()
|
||||
)
|
||||
|
||||
move_group = Node(
|
||||
package="moveit_ros_move_group",
|
||||
executable="move_group",
|
||||
output="screen",
|
||||
parameters=[
|
||||
moveit_configs.to_dict(),
|
||||
{"robot_description": robot_description},
|
||||
{"use_sim_time": True},
|
||||
],
|
||||
)
|
||||
|
||||
# TODO: не забудь поменять правильное название и имя пакета
|
||||
# moveit_py_node = Node(
|
||||
# # name="motion_planning_node",
|
||||
# package="iiwa_planning",
|
||||
# executable="motion_planning",
|
||||
# output="both",
|
||||
# parameters=[moveit_configs.to_dict()],
|
||||
# )
|
||||
|
||||
|
||||
rviz_launch = Node(
|
||||
condition=IfCondition(LaunchConfiguration("rviz")),
|
||||
package="rviz2",
|
||||
executable="rviz2",
|
||||
name="rviz2",
|
||||
arguments=["-d", settings.digital_twin.rviz.config],
|
||||
output="log",
|
||||
parameters=[
|
||||
moveit_configs.robot_description,
|
||||
moveit_configs.robot_description_semantic,
|
||||
moveit_configs.planning_pipelines,
|
||||
moveit_configs.planning_scene_monitor,
|
||||
{"use_sim_time": True},
|
||||
],
|
||||
)
|
||||
|
||||
shutdown_on_rviz_exit = RegisterEventHandler(
|
||||
OnProcessExit(target_action=rviz_launch, on_exit=[EmitEvent(event=Shutdown())])
|
||||
)
|
||||
|
||||
setup += [
|
||||
rsp_node,
|
||||
webots_launch,
|
||||
move_group,
|
||||
# moveit_py_node,
|
||||
rviz_launch,
|
||||
shutdown_on_rviz_exit,
|
||||
]
|
||||
|
||||
return setup
|
||||
|
||||
|
||||
def generate_launch_description():
|
||||
declare_rviz = DeclareLaunchArgument(
|
||||
name="rviz",
|
||||
default_value="0",
|
||||
description="If true|1|yes then launch RViz/MoveIt branch (instead of controllers branch)",
|
||||
)
|
||||
|
||||
declacre_setting = DeclareLaunchArgument(
|
||||
name="setting",
|
||||
default_value=PathJoinSubstitution(
|
||||
[FindPackageShare("iiwa_config"), "config", "setting.yaml"]
|
||||
),
|
||||
description="Absolute path to settings file",
|
||||
)
|
||||
|
||||
runtime_setup = OpaqueFunction(function=_runtime_setup)
|
||||
|
||||
return LaunchDescription(
|
||||
[
|
||||
declare_rviz,
|
||||
declacre_setting,
|
||||
runtime_setup,
|
||||
]
|
||||
)
|
||||
@@ -65,7 +65,6 @@ def _runtime_setup(context, *args, **kwargs):
|
||||
"robot_ip": settings.robot.ip,
|
||||
"fri_port": str(settings.robot.port),
|
||||
"simulate": "false",
|
||||
"command_mode": settings.robot.command_mode,
|
||||
"joint_position_tau": str(settings.robot.joint_position_tau),
|
||||
}
|
||||
use_sim_time = False
|
||||
@@ -168,7 +167,6 @@ def _runtime_setup(context, *args, **kwargs):
|
||||
"transform": str(settings.digital_twin.webots.transform),
|
||||
"rotation": str(settings.digital_twin.webots.rotation),
|
||||
"simulate": "false",
|
||||
"command_mode": settings.robot.command_mode,
|
||||
"controller_timer": str(settings.digital_twin.webots.controller_timer),
|
||||
"fri_cycle_ms": str(settings.robot.fri_cycle_ms),
|
||||
"joint_position_tau": str(settings.robot.joint_position_tau),
|
||||
|
||||
@@ -19,7 +19,6 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
controller_timer = LaunchConfiguration("controller_timer").perform(context)
|
||||
controller_path = LaunchConfiguration("controller_path").perform(context)
|
||||
simulate = LaunchConfiguration("simulate").perform(context).lower() in ("true", "1", "yes")
|
||||
command_mode = LaunchConfiguration("command_mode").perform(context)
|
||||
controller = LaunchConfiguration("controller").perform(context) # "jtc" | "forward"
|
||||
fri_cycle_ms = int(LaunchConfiguration("fri_cycle_ms").perform(context))
|
||||
joint_position_tau = LaunchConfiguration("joint_position_tau").perform(context)
|
||||
@@ -65,18 +64,10 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
parameters=[{"use_sim_time": True}],
|
||||
)
|
||||
|
||||
torque_controller_spawner = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=["iiwa_arm_torque_controller", "--inactive"] + tmo,
|
||||
parameters=[{"use_sim_time": True}]
|
||||
)
|
||||
|
||||
jtc_after_jsb = RegisterEventHandler(
|
||||
OnProcessExit(
|
||||
target_action=jsb,
|
||||
on_exit=[jtc, torque_controller_spawner],
|
||||
on_exit=[jtc],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -107,9 +98,8 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
|
||||
cm = ["--controller-manager", "/controller_manager"]
|
||||
|
||||
# JTC: активен если controller=jtc (и command_mode=position), иначе --inactive
|
||||
jtc_args = ["iiwa_arm_controller"] + cm
|
||||
if command_mode == "torque" or controller == "forward":
|
||||
if controller == "forward":
|
||||
jtc_args += ["--inactive"]
|
||||
|
||||
# ForwardCommandController: активен если controller=forward, иначе --inactive
|
||||
@@ -117,11 +107,6 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
if controller != "forward":
|
||||
forward_args += ["--inactive"]
|
||||
|
||||
# TorqueController: активен если command_mode=torque и controller=jtc
|
||||
torque_args = ["iiwa_arm_torque_controller"] + cm
|
||||
if not (command_mode == "torque" and controller == "jtc"):
|
||||
torque_args += ["--inactive"]
|
||||
|
||||
jtc = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
@@ -136,17 +121,10 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
arguments=forward_args,
|
||||
)
|
||||
|
||||
torque_controller = Node(
|
||||
package="controller_manager",
|
||||
executable="spawner",
|
||||
output="screen",
|
||||
arguments=torque_args,
|
||||
)
|
||||
|
||||
jtc_after_jsb = RegisterEventHandler(
|
||||
OnProcessExit(
|
||||
target_action=jsb,
|
||||
on_exit=[jtc, forward_controller, torque_controller],
|
||||
on_exit=[jtc, forward_controller],
|
||||
)
|
||||
)
|
||||
|
||||
@@ -159,7 +137,6 @@ def _setup_controllers(context, *args, **kwargs):
|
||||
|
||||
def generate_launch_description():
|
||||
return LaunchDescription([
|
||||
DeclareLaunchArgument("command_mode", default_value="position"),
|
||||
DeclareLaunchArgument("fri_cycle_ms", default_value="5"),
|
||||
DeclareLaunchArgument("joint_position_tau", default_value="0.04"),
|
||||
DeclareLaunchArgument("controller", default_value="jtc"),
|
||||
|
||||
@@ -2,7 +2,6 @@ robot:
|
||||
name: "iiwa7"
|
||||
ip: "192.170.10.2"
|
||||
port: 30200
|
||||
command_mode: "position" # torque, position
|
||||
fri_cycle_ms: 10 # период FRI-цикла: 5 мс (200 Гц) или 10 мс (100 Гц)
|
||||
joint_position_tau: 0.04 # EMA фильтр позиций [с]: сглаживает команды перед отправкой в FRI
|
||||
joint_velocity_tau: 0.01 # EMA фильтр скорости [с]: убирает выбросы конечных разностей
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
base_class_type="hardware_interface::SystemInterface">
|
||||
<description>
|
||||
ROS2 hardware interface для KUKA iiwa 7 через FRI (Fast Robot Interface).
|
||||
Поддерживает режимы управления: position, torque.
|
||||
Поддерживает управление в режиме position через FRI.
|
||||
</description>
|
||||
</class>
|
||||
</library>
|
||||
@@ -11,11 +11,6 @@
|
||||
namespace iiwa_controller
|
||||
{
|
||||
|
||||
enum class CommandMode
|
||||
{
|
||||
POSITION,
|
||||
TORQUE
|
||||
};
|
||||
|
||||
// Снимок состояния робота захватывается атомарно за один lock в FRI-потоке
|
||||
// и так же за один lock читается из read() в потоке управления.
|
||||
@@ -40,7 +35,7 @@ public:
|
||||
// joint_position_tau — постоянная времени экспоненциального фильтра позиций [с].
|
||||
// Аналог joint_position_tau из lbr_fri_ros2_stack (по умолчанию 0.04 с = 40 мс).
|
||||
// Сглаживает скачки команд перед отправкой роботу → убирает писк и стук суставов.
|
||||
explicit FRIClient(CommandMode mode = CommandMode::POSITION, double joint_position_tau = 0.04);
|
||||
explicit FRIClient(double joint_position_tau = 0.04);
|
||||
~FRIClient() override = default;
|
||||
|
||||
// Коллбэки FRI SDK, вызываются из friThreadFunc через ClientApplication::step()
|
||||
@@ -52,19 +47,16 @@ public:
|
||||
|
||||
// Потокобезопасное API для ros2_control, вызывается из read() и write()
|
||||
void setTargetJointPositions(const std::array<double, N_JOINTS> & q);
|
||||
void setTargetJointTorques(const std::array<double, N_JOINTS> & tau);
|
||||
IIWAStateSnapshot getStateSnapshot() const;
|
||||
bool isCommandingActive() const;
|
||||
KUKA::FRI::ESessionState getSessionState() const;
|
||||
|
||||
private:
|
||||
CommandMode cmd_mode_;
|
||||
double joint_position_tau_;
|
||||
std::atomic<KUKA::FRI::ESessionState> session_state_{KUKA::FRI::IDLE};
|
||||
|
||||
mutable std::mutex data_mutex_;
|
||||
std::array<double, N_JOINTS> target_pos_{};
|
||||
std::array<double, N_JOINTS> target_tau_{};
|
||||
// Сглаженная позиция, которую реально отправляем роботу.
|
||||
// Инициализируется IPO-позицией в waitForCommand(), чтобы не было скачка при старте.
|
||||
std::array<double, N_JOINTS> filtered_pos_{};
|
||||
|
||||
@@ -59,7 +59,6 @@ private:
|
||||
std::string robot_ip_;
|
||||
int fri_port_{30200};
|
||||
bool simulate_{false};
|
||||
std::string cmd_mode_str_{"position"};
|
||||
double joint_position_tau_{0.04};
|
||||
// EMA-фильтр скорости: сглаживает одиночные выбросы конечных разностей.
|
||||
// joint_velocity_tau = 0 отключает фильтр (raw finite difference).
|
||||
@@ -82,9 +81,7 @@ private:
|
||||
std::array<hardware_interface::StateInterface::SharedPtr, N_JOINTS> h_eff_;
|
||||
std::array<hardware_interface::StateInterface::SharedPtr, N_JOINTS> h_ext_;
|
||||
|
||||
// Хэндлы командных интерфейсов
|
||||
std::array<hardware_interface::CommandInterface::SharedPtr, N_JOINTS> h_cmd_pos_;
|
||||
std::array<hardware_interface::CommandInterface::SharedPtr, N_JOINTS> h_cmd_eff_;
|
||||
|
||||
// Вычисление скорости: конечные разности + EMA-фильтр
|
||||
std::array<double, N_JOINTS> prev_pos_{};
|
||||
@@ -100,7 +97,6 @@ private:
|
||||
|
||||
rclcpp::Clock throttle_clock_{RCL_STEADY_TIME};
|
||||
|
||||
CommandMode parseCommandMode(const std::string & mode_str) const;
|
||||
};
|
||||
|
||||
} // namespace iiwa_controller
|
||||
|
||||
@@ -20,11 +20,10 @@ static const char * friStateName(KUKA::FRI::ESessionState s)
|
||||
}
|
||||
}
|
||||
|
||||
FRIClient::FRIClient(CommandMode mode, double joint_position_tau)
|
||||
: cmd_mode_(mode), joint_position_tau_(joint_position_tau)
|
||||
FRIClient::FRIClient(double joint_position_tau)
|
||||
: joint_position_tau_(joint_position_tau)
|
||||
{
|
||||
target_pos_.fill(0.0);
|
||||
target_tau_.fill(0.0);
|
||||
filtered_pos_.fill(0.0);
|
||||
}
|
||||
|
||||
@@ -86,12 +85,6 @@ void FRIClient::waitForCommand()
|
||||
std::memcpy(filtered_pos_.data(), snapshot_.ipo_pos.data(), N_JOINTS * sizeof(double));
|
||||
|
||||
robotCommand().setJointPosition(filtered_pos_.data());
|
||||
|
||||
if (cmd_mode_ == CommandMode::TORQUE) {
|
||||
// Пока контроллер не синхронизирован, момент держим на нуле
|
||||
target_tau_.fill(0.0);
|
||||
robotCommand().setTorque(target_tau_.data());
|
||||
}
|
||||
}
|
||||
|
||||
// Вызывается в COMMANDING_ACTIVE, основной цикл управления
|
||||
@@ -110,10 +103,6 @@ void FRIClient::command()
|
||||
|
||||
robotCommand().setJointPosition(filtered_pos_.data());
|
||||
|
||||
if (cmd_mode_ == CommandMode::TORQUE) {
|
||||
robotCommand().setTorque(target_tau_.data());
|
||||
}
|
||||
|
||||
// Захватываем снимок ПОСЛЕ EMA: measured_pos = filtered_pos_ = что робот только что получил.
|
||||
captureCommandingData();
|
||||
}
|
||||
@@ -131,11 +120,6 @@ void FRIClient::onStateChange(
|
||||
newState == KUKA::FRI::MONITORING_WAIT ||
|
||||
newState == KUKA::FRI::MONITORING_READY)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(data_mutex_);
|
||||
target_tau_.fill(0.0);
|
||||
RCLCPP_WARN(
|
||||
rclcpp::get_logger("FRIClient"),
|
||||
"FRI сессия неактивна, моменты обнулены");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,17 +136,6 @@ void FRIClient::setTargetJointPositions(const std::array<double, N_JOINTS> & q)
|
||||
target_pos_ = q;
|
||||
}
|
||||
|
||||
void FRIClient::setTargetJointTorques(const std::array<double, N_JOINTS> & tau)
|
||||
{
|
||||
for (const auto & v : tau) {
|
||||
if (!std::isfinite(v)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(data_mutex_);
|
||||
target_tau_ = tau;
|
||||
}
|
||||
|
||||
IIWAStateSnapshot FRIClient::getStateSnapshot() const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(data_mutex_);
|
||||
|
||||
@@ -46,15 +46,13 @@ CallbackReturn IIWAHardwareInterface::on_init(
|
||||
robot_ip_ = getParam(info, "robot_ip", "192.170.10.2");
|
||||
fri_port_ = std::stoi(getParam(info, "fri_port", "30200"));
|
||||
simulate_ = (getParam(info, "simulate", "false") == "true");
|
||||
cmd_mode_str_ = getParam(info, "command_mode", "position");
|
||||
joint_position_tau_ = std::stod(getParam(info, "joint_position_tau", "0.04"));
|
||||
joint_velocity_tau_ = std::stod(getParam(info, "joint_velocity_tau", "0.01"));
|
||||
|
||||
RCLCPP_INFO(rclcpp::get_logger(LOG),
|
||||
"on_init: ip=%s port=%d simulate=%s mode=%s pos_tau=%.3f vel_tau=%.3f",
|
||||
"on_init: ip=%s port=%d simulate=%s pos_tau=%.3f vel_tau=%.3f",
|
||||
robot_ip_.c_str(), fri_port_,
|
||||
simulate_ ? "true" : "false",
|
||||
cmd_mode_str_.c_str(),
|
||||
joint_position_tau_,
|
||||
joint_velocity_tau_);
|
||||
|
||||
@@ -99,7 +97,7 @@ CallbackReturn IIWAHardwareInterface::on_configure(const rclcpp_lifecycle::State
|
||||
return CallbackReturn::SUCCESS;
|
||||
}
|
||||
|
||||
fri_client_ = std::make_unique<FRIClient>(parseCommandMode(cmd_mode_str_), joint_position_tau_);
|
||||
fri_client_ = std::make_unique<FRIClient>(joint_position_tau_);
|
||||
// 100 мс таймаут recvfrom — поток корректно завершится после disconnect().
|
||||
connection_ = std::make_unique<KUKA::FRI::UdpConnection>(100);
|
||||
app_ = std::make_unique<KUKA::FRI::ClientApplication>(*connection_, *fri_client_);
|
||||
@@ -132,10 +130,8 @@ CallbackReturn IIWAHardwareInterface::on_activate(const rclcpp_lifecycle::State
|
||||
h_eff_[i] = get_state_interface_handle(jn + "/" + hardware_interface::HW_IF_EFFORT);
|
||||
h_ext_[i] = get_state_interface_handle(jn + "/external_torque");
|
||||
h_cmd_pos_[i] = get_command_interface_handle(jn + "/" + hardware_interface::HW_IF_POSITION);
|
||||
h_cmd_eff_[i] = get_command_interface_handle(jn + "/" + hardware_interface::HW_IF_EFFORT);
|
||||
|
||||
if (!h_pos_[i] || !h_vel_[i] || !h_eff_[i] || !h_ext_[i] ||
|
||||
!h_cmd_pos_[i] || !h_cmd_eff_[i])
|
||||
if (!h_pos_[i] || !h_vel_[i] || !h_eff_[i] || !h_ext_[i] || !h_cmd_pos_[i])
|
||||
{
|
||||
RCLCPP_FATAL(rclcpp::get_logger(LOG),
|
||||
"Не удалось получить хэндл интерфейса для сустава '%s'. "
|
||||
@@ -199,7 +195,7 @@ CallbackReturn IIWAHardwareInterface::on_deactivate(const rclcpp_lifecycle::Stat
|
||||
|
||||
for (size_t i = 0; i < N_JOINTS; ++i) {
|
||||
h_pos_[i] = h_vel_[i] = h_eff_[i] = h_ext_[i] = nullptr;
|
||||
h_cmd_pos_[i] = h_cmd_eff_[i] = nullptr;
|
||||
h_cmd_pos_[i] = nullptr;
|
||||
}
|
||||
|
||||
velocity_initialized_ = false;
|
||||
@@ -342,23 +338,14 @@ hardware_interface::return_type IIWAHardwareInterface::write(
|
||||
return hardware_interface::return_type::OK;
|
||||
}
|
||||
|
||||
std::array<double, N_JOINTS> pos_cmd{}, tau_cmd{};
|
||||
std::array<double, N_JOINTS> pos_cmd{};
|
||||
for (size_t i = 0; i < N_JOINTS; ++i) {
|
||||
get_command(h_cmd_pos_[i], pos_cmd[i], false);
|
||||
get_command(h_cmd_eff_[i], tau_cmd[i], false);
|
||||
}
|
||||
|
||||
fri_client_->setTargetJointPositions(pos_cmd);
|
||||
fri_client_->setTargetJointTorques(tau_cmd);
|
||||
|
||||
return hardware_interface::return_type::OK;
|
||||
}
|
||||
|
||||
// ── parseCommandMode ───────────────────────────────────────────────────────────
|
||||
|
||||
CommandMode IIWAHardwareInterface::parseCommandMode(const std::string & mode_str) const
|
||||
{
|
||||
return (mode_str == "torque") ? CommandMode::TORQUE : CommandMode::POSITION;
|
||||
}
|
||||
|
||||
} // namespace iiwa_controller
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
<xacro:arg name="simulate" default="false"/>
|
||||
<xacro:arg name="robot_ip" default="192.170.10.2"/>
|
||||
<xacro:arg name="fri_port" default="30200"/>
|
||||
<xacro:arg name="command_mode" default="position"/>
|
||||
<xacro:arg name="joint_position_tau" default="0.04"/>
|
||||
<xacro:arg name="joint_velocity_tau" default="0.01"/>
|
||||
|
||||
@@ -147,7 +146,6 @@
|
||||
<param name="robot_ip">$(arg robot_ip)</param>
|
||||
<param name="fri_port">$(arg fri_port)</param>
|
||||
<param name="simulate">false</param>
|
||||
<param name="command_mode">$(arg command_mode)</param>
|
||||
<param name="joint_position_tau">$(arg joint_position_tau)</param>
|
||||
<param name="joint_velocity_tau">$(arg joint_velocity_tau)</param>
|
||||
</hardware>
|
||||
@@ -157,10 +155,7 @@
|
||||
<param name="min">-2.97</param>
|
||||
<param name="max"> 2.97</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint1']}</param>
|
||||
</state_interface>
|
||||
@@ -173,10 +168,7 @@
|
||||
<param name="min">-2.09</param>
|
||||
<param name="max"> 2.09</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint2']}</param>
|
||||
</state_interface>
|
||||
@@ -189,10 +181,7 @@
|
||||
<param name="min">-2.97</param>
|
||||
<param name="max"> 2.97</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint3']}</param>
|
||||
</state_interface>
|
||||
@@ -205,10 +194,7 @@
|
||||
<param name="min">-2.09</param>
|
||||
<param name="max"> 2.09</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint4']}</param>
|
||||
</state_interface>
|
||||
@@ -221,10 +207,7 @@
|
||||
<param name="min">-2.97</param>
|
||||
<param name="max"> 2.97</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint5']}</param>
|
||||
</state_interface>
|
||||
@@ -237,10 +220,7 @@
|
||||
<param name="min">-2.09</param>
|
||||
<param name="max"> 2.09</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint6']}</param>
|
||||
</state_interface>
|
||||
@@ -253,10 +233,7 @@
|
||||
<param name="min">-3.05</param>
|
||||
<param name="max"> 3.05</param>
|
||||
</command_interface>
|
||||
<command_interface name="effort">
|
||||
<param name="min">-200</param>
|
||||
<param name="max"> 200</param>
|
||||
</command_interface>
|
||||
|
||||
<state_interface name="position">
|
||||
<param name="initial_value">${initial_positions['joint7']}</param>
|
||||
</state_interface>
|
||||
|
||||
@@ -38,10 +38,10 @@ class IiwaMotionServer(Node):
|
||||
"""Сервер управления движением манипулятора iiwa.
|
||||
|
||||
Предоставляет:
|
||||
- action iiwa/move_to_pose — перемещение в декартову позу
|
||||
- action iiwa/move_to_joints — перемещение по суставным координатам
|
||||
- service iiwa/move_to_named — перемещение в именованную позу из SRDF
|
||||
- service iiwa/stop — немедленная остановка движения
|
||||
- action cobot/move_to_pose — перемещение в декартову позу
|
||||
- action cobot/move_to_joints — перемещение по суставным координатам
|
||||
- service cobot/move_to_named — перемещение в именованную позу из SRDF
|
||||
- service cobot/stop — немедленная остановка движения
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -75,19 +75,19 @@ class IiwaMotionServer(Node):
|
||||
cb = ReentrantCallbackGroup()
|
||||
|
||||
ActionServer(
|
||||
self, MoveToPose, "iiwa/move_to_pose", self._execute_pose,
|
||||
self, MoveToPose, "cobot/move_to_pose", self._execute_pose,
|
||||
callback_group=cb,
|
||||
goal_callback=lambda _: GoalResponse.ACCEPT,
|
||||
cancel_callback=lambda _: CancelResponse.ACCEPT,
|
||||
)
|
||||
ActionServer(
|
||||
self, MoveToJoints, "iiwa/move_to_joints", self._execute_joints,
|
||||
self, MoveToJoints, "cobot/move_to_joints", self._execute_joints,
|
||||
callback_group=cb,
|
||||
goal_callback=lambda _: GoalResponse.ACCEPT,
|
||||
cancel_callback=lambda _: CancelResponse.ACCEPT,
|
||||
)
|
||||
self.create_service(MoveToNamedPose, "iiwa/move_to_named", self._handle_named, callback_group=cb)
|
||||
self.create_service(Trigger, "iiwa/stop", self._handle_stop, callback_group=cb)
|
||||
self.create_service(MoveToNamedPose, "cobot/move_to_named", self._handle_named, callback_group=cb)
|
||||
self.create_service(Trigger, "cobot/stop", self._handle_stop, callback_group=cb)
|
||||
|
||||
def _make_plan_params(self, pipeline: str, planner_id: str, plan_time: float, velocity_scale: float, accel_scale: float | None = None) -> PlanRequestParameters:
|
||||
params = PlanRequestParameters(self._moveit, self._planning_group)
|
||||
|
||||
@@ -13,7 +13,6 @@ class RobotCfg:
|
||||
name: str
|
||||
ip: str
|
||||
port: int
|
||||
command_mode: str
|
||||
description: str
|
||||
fri_cycle_ms: int
|
||||
joint_position_tau: float
|
||||
@@ -247,7 +246,6 @@ def build_settings(settings_path: str, check_files: bool = True) -> Settings:
|
||||
name=str(require(robot_raw, "name")),
|
||||
ip=str(require(robot_raw, "ip")),
|
||||
port=int(require(robot_raw, "port")),
|
||||
command_mode=str(require(robot_raw, "command_mode")),
|
||||
description=resolve_path(str(require(robot_raw, "description")), settings_dir),
|
||||
fri_cycle_ms=int(robot_raw.get("fri_cycle_ms", 5)),
|
||||
joint_position_tau=float(robot_raw.get("joint_position_tau", 0.04)),
|
||||
|
||||
Reference in New Issue
Block a user