staubli_driver_ros2 main
ROS2 control driver for Staubli robots
Loading...
Searching...
No Matches
robot_driver_helpers.hpp
Go to the documentation of this file.
1// Copyright 2025 ICUBE Laboratory, University of Strasbourg
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Author: Thibault Poignonec (thibault.poignonec@gmail.fr)
16
17
18#ifndef STAUBLI_ROBOT_DRIVER__ROBOT_DRIVER_HELPERS_HPP_
19#define STAUBLI_ROBOT_DRIVER__ROBOT_DRIVER_HELPERS_HPP_
20
21// C++
22#include <algorithm>
23#include <vector>
24
25// Staubli Robot Driver
27
28namespace staubli_robot_driver {
29
31{
32 msg.command_type = CommandType::STOP;
33 msg.command_reference.fill(0.0);
34 return true;
35}
36
37bool set_command_joint_position(RobotCommandMessage& msg, std::vector<double> joint_positions)
38{
39 if (joint_positions.size() != msg.command_reference.size()) {
40 return false;
41 }
42 msg.command_type = CommandType::JOINT_POSITION;
43 std::copy(joint_positions.begin(), joint_positions.end(), msg.command_reference.begin());
44 return true;
45}
46
47bool set_command_joint_velocity(RobotCommandMessage& msg, std::vector<double> joint_velocities)
48{
49 if (joint_velocities.size() != msg.command_reference.size()) {
50 return false;
51 }
52 msg.command_type = CommandType::JOINT_VELOCITY;
53 std::copy(joint_velocities.begin(), joint_velocities.end(), msg.command_reference.begin());
54 return true;
55}
56
57
59{
60 msg.header.sequence_number = state.header.sequence_number;
61 return true;
62}
63
71{
72 bool result = true;
74 // Set command
76 // Command robot stop and clear IOs
77 msg.digital_outputs.fill(false);
78 msg.analog_outputs.fill(0.0);
79 return result;
80}
81
82} // namespace staubli_robot_driver
83
84#endif // STAUBLI_ROBOT_DRIVER__ROBOT_DRIVER_HELPERS_HPP_
Bilateral real-time socket interface for pub/sub communication.
Definition real_time_socket_interface.hpp:39
Robot command message.
Definition messages.hpp:139
Robot state message.
Definition messages.hpp:62
Definition messages.hpp:23
bool set_command_joint_velocity(RobotCommandMessage &msg, std::vector< double > joint_velocities)
Definition robot_driver_helpers.hpp:47
bool prepare_robot_command_message(RobotCommandMessage &msg, RobotStateMessage &state)
Clear and prepare a RobotCommandMessage.
Definition robot_driver_helpers.hpp:70
bool set_command_joint_position(RobotCommandMessage &msg, std::vector< double > joint_positions)
Definition robot_driver_helpers.hpp:37
bool set_command_stop(RobotCommandMessage &msg)
Definition robot_driver_helpers.hpp:30
bool set_sequence_number(RobotCommandMessage &msg, RobotStateMessage &state)
Definition robot_driver_helpers.hpp:58