SMACC2
Loading...
Searching...
No Matches
smacc2_client_library
cl_moveit2z
include
cl_moveit2z
client_behaviors
cb_undo_last_trajectory.hpp
Go to the documentation of this file.
1
// Copyright 2021 RobosoftAI Inc.
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
/*****************************************************************************************************************
16
*
17
* Authors: Pablo Inigo Blasco, Brett Aldrich
18
*
19
*****************************************************************************************************************/
20
21
#pragma once
22
23
#include <
cl_moveit2z/client_behaviors/cb_move_end_effector_trajectory.hpp
>
24
#include <
cl_moveit2z/components/cp_trajectory_history.hpp
>
25
26
namespace
cl_moveit2z
27
{
28
class
CbUndoLastTrajectory
:
public
CbMoveEndEffectorTrajectory
29
{
30
public
:
31
CbUndoLastTrajectory
() {}
32
33
CbUndoLastTrajectory
(
int
backIndex) :
backIndex_
(backIndex) {}
34
35
virtual
~CbUndoLastTrajectory
() {}
36
37
virtual
void
onEntry
()
override
38
{
39
CpTrajectoryHistory
* trajectoryHistory;
40
this->
requiresComponent
(trajectoryHistory);
41
this->
requiresClient
(
movegroupClient_
);
42
43
if
(trajectoryHistory->
getLastTrajectory
(
backIndex_
,
trajectory
))
44
{
45
RCLCPP_WARN_STREAM(
46
getLogger
(),
"["
<<
getName
() <<
"] reversing last trajectory ["
<<
backIndex_
<<
"]"
);
47
48
auto
initialTime =
trajectory
.joint_trajectory.points.back().time_from_start;
49
50
reversed
=
trajectory
;
51
52
std::reverse(
53
reversed
.joint_trajectory.points.begin(),
reversed
.joint_trajectory.points.end());
54
55
for
(
auto
& jp :
reversed
.joint_trajectory.points)
56
{
57
jp.time_from_start = rclcpp::Duration(initialTime) - rclcpp::Duration(jp.time_from_start);
58
}
59
60
this->
executeJointSpaceTrajectory
(
reversed
);
61
}
62
else
63
{
64
RCLCPP_WARN_STREAM(
65
getLogger
(),
"["
<<
getName
() <<
"] could not undo last trajectory, trajectory not found."
);
66
}
67
}
68
69
virtual
void
generateTrajectory
() {}
70
71
private
:
72
int
backIndex_
= -1;
73
74
moveit_msgs::msg::RobotTrajectory
trajectory
;
75
moveit_msgs::msg::RobotTrajectory
reversed
;
76
};
77
78
}
// namespace cl_moveit2z
cb_move_end_effector_trajectory.hpp
cl_moveit2z::CbMoveEndEffectorTrajectory
Definition
cb_move_end_effector_trajectory.hpp:61
cl_moveit2z::CbMoveEndEffectorTrajectory::movegroupClient_
ClMoveit2z * movegroupClient_
Definition
cb_move_end_effector_trajectory.hpp:582
cl_moveit2z::CbMoveEndEffectorTrajectory::executeJointSpaceTrajectory
void executeJointSpaceTrajectory(const moveit_msgs::msg::RobotTrajectory &computedJointTrajectory)
Definition
cb_move_end_effector_trajectory.hpp:458
cl_moveit2z::CbUndoLastTrajectory
Definition
cb_undo_last_trajectory.hpp:29
cl_moveit2z::CbUndoLastTrajectory::CbUndoLastTrajectory
CbUndoLastTrajectory()
Definition
cb_undo_last_trajectory.hpp:31
cl_moveit2z::CbUndoLastTrajectory::~CbUndoLastTrajectory
virtual ~CbUndoLastTrajectory()
Definition
cb_undo_last_trajectory.hpp:35
cl_moveit2z::CbUndoLastTrajectory::generateTrajectory
virtual void generateTrajectory()
Definition
cb_undo_last_trajectory.hpp:69
cl_moveit2z::CbUndoLastTrajectory::backIndex_
int backIndex_
Definition
cb_undo_last_trajectory.hpp:72
cl_moveit2z::CbUndoLastTrajectory::trajectory
moveit_msgs::msg::RobotTrajectory trajectory
Definition
cb_undo_last_trajectory.hpp:74
cl_moveit2z::CbUndoLastTrajectory::reversed
moveit_msgs::msg::RobotTrajectory reversed
Definition
cb_undo_last_trajectory.hpp:75
cl_moveit2z::CbUndoLastTrajectory::onEntry
virtual void onEntry() override
Definition
cb_undo_last_trajectory.hpp:37
cl_moveit2z::CbUndoLastTrajectory::CbUndoLastTrajectory
CbUndoLastTrajectory(int backIndex)
Definition
cb_undo_last_trajectory.hpp:33
cl_moveit2z::CpTrajectoryHistory
Definition
cp_trajectory_history.hpp:38
cl_moveit2z::CpTrajectoryHistory::getLastTrajectory
bool getLastTrajectory(int backIndex, moveit_msgs::msg::RobotTrajectory &trajectory)
Definition
cp_trajectory_history.hpp:40
smacc2::ISmaccClientBehavior::getName
std::string getName() const
Definition
smacc_client_behavior_base.cpp:36
smacc2::ISmaccClientBehavior::getLogger
virtual rclcpp::Logger getLogger() const
Definition
smacc_client_behavior_base.cpp:43
smacc2::ISmaccClientBehavior::requiresClient
void requiresClient(SmaccClientType *&storage)
Definition
smacc_client_behavior_impl.hpp:67
smacc2::ISmaccClientBehavior::requiresComponent
void requiresComponent(SmaccComponentType *&storage, ComponentRequirement requirementType=ComponentRequirement::SOFT)
Definition
smacc_client_behavior_impl.hpp:73
cp_trajectory_history.hpp
cl_moveit2z
Definition
cl_moveit2z.hpp:35
Generated by
1.12.0