Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
panda_mqtt_connector
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
CeTI
ROS
ROS Packages
panda_mqtt_connector
Commits
016d2bf3
Commit
016d2bf3
authored
5 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
robot now changes speed inbetween two trajectory points
parent
a7ebe96d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/config.yaml
+3
-3
3 additions, 3 deletions
config/config.yaml
src/TimedPlanner.cpp
+42
-10
42 additions, 10 deletions
src/TimedPlanner.cpp
src/util/TrajectoryUtil.cpp
+3
-11
3 additions, 11 deletions
src/util/TrajectoryUtil.cpp
src/util/TrajectoryUtil.h
+2
-2
2 additions, 2 deletions
src/util/TrajectoryUtil.h
with
50 additions
and
26 deletions
config/config.yaml
+
3
−
3
View file @
016d2bf3
panda_mqtt_connector
:
panda_mqtt_connector
:
server
:
"
tcp://localhost:1883"
server
:
"
tcp://localhost:1883"
robot_speed_factor
:
.
9
5
robot_speed_factor
:
.5
robot_planning_mode
:
"
fluid_path"
# "fluid_path" or "cartesian_path"
robot_planning_mode
:
"
fluid_path"
# "fluid_path" or "cartesian_path"
default_trajectory
:
"
squar
e"
# "square" or "circle", everything else is ignored
default_trajectory
:
"
circl
e"
# "square" or "circle", everything else is ignored
topics
:
topics
:
robotConfig
:
"
robotconfig"
robotConfig
:
"
robotconfig"
dataConfig
:
"
dataconfig"
dataConfig
:
"
dataconfig"
zone_size
:
0.5
zone_size
:
0.5
zones
:
zones
:
-
"
1
1"
-
"
1
1"
-
"
0
1"
-
"
-1
-1
1"
parts
:
parts
:
panda
:
panda
:
Link0
:
"
panda::panda_link0"
Link0
:
"
panda::panda_link0"
...
...
This diff is collapsed.
Click to expand it.
src/TimedPlanner.cpp
+
42
−
10
View file @
016d2bf3
...
@@ -23,7 +23,6 @@ namespace PlannerState {
...
@@ -23,7 +23,6 @@ namespace PlannerState {
const
double
default_velocity
=
1.0
;
const
double
default_velocity
=
1.0
;
const
std
::
string
default_planning_mode
=
TrajectoryUtil
::
FLUID_PATH
;
const
std
::
string
default_planning_mode
=
TrajectoryUtil
::
FLUID_PATH
;
const
bool
useCircle
=
true
;
bool
isLooping
=
true
;
bool
isLooping
=
true
;
...
@@ -106,6 +105,30 @@ bool loadWaypoints(std::vector<geometry_msgs::Pose> &waypoints, const ros::NodeH
...
@@ -106,6 +105,30 @@ bool loadWaypoints(std::vector<geometry_msgs::Pose> &waypoints, const ros::NodeH
}
}
}
}
static
std
::
vector
<
moveit_msgs
::
RobotTrajectory
>
split
(
moveit
::
planning_interface
::
MoveGroupInterface
&
group
,
const
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
)
{
std
::
vector
<
moveit_msgs
::
RobotTrajectory
>
trajectories
;
auto
currentState
=
group
.
getCurrentState
();
auto
robotModel
=
currentState
->
getRobotModel
();
robot_trajectory
::
RobotTrajectory
rt
(
robotModel
,
"panda_arm"
);
rt
.
setRobotTrajectoryMsg
(
*
currentState
,
plan
.
start_state_
,
plan
.
trajectory_
);
for
(
int
wpIndex
=
0
;
wpIndex
<
rt
.
getWayPointCount
()
-
1
;
++
wpIndex
)
{
robot_trajectory
::
RobotTrajectory
wpTrajectory
{
robotModel
,
"panda_arm"
};
moveit
::
core
::
RobotState
waypointState
{
robotModel
};
wpTrajectory
.
insertWayPoint
(
0
,
rt
.
getWayPoint
(
wpIndex
),
0
);
wpTrajectory
.
insertWayPoint
(
1
,
rt
.
getWayPoint
(
wpIndex
+
1
),
rt
.
getWayPointDurationFromPrevious
(
wpIndex
+
1
));
moveit_msgs
::
RobotTrajectory
wpTrajectoryMsg
{};
wpTrajectory
.
getRobotTrajectoryMsg
(
wpTrajectoryMsg
);
trajectories
.
push_back
(
wpTrajectoryMsg
);
}
return
trajectories
;
}
void
doMotion
(
const
ros
::
NodeHandle
&
node_handle
,
moveit
::
planning_interface
::
MoveGroupInterface
&
group
)
{
void
doMotion
(
const
ros
::
NodeHandle
&
node_handle
,
moveit
::
planning_interface
::
MoveGroupInterface
&
group
)
{
bool
newTrajectoryAvailable
=
false
;
bool
newTrajectoryAvailable
=
false
;
...
@@ -129,24 +152,33 @@ void doMotion(const ros::NodeHandle &node_handle, moveit::planning_interface::Mo
...
@@ -129,24 +152,33 @@ void doMotion(const ros::NodeHandle &node_handle, moveit::planning_interface::Mo
node_handle
.
getParam
(
"new_trajectory_available"
,
newTrajectoryAvailable
);
node_handle
.
getParam
(
"new_trajectory_available"
,
newTrajectoryAvailable
);
node_handle
.
getParam
(
"loop_trajectory"
,
PlannerState
::
isLooping
);
node_handle
.
getParam
(
"loop_trajectory"
,
PlannerState
::
isLooping
);
double
velocity
;
if
(
!
node_handle
.
getParam
(
"robot_speed_factor"
,
velocity
))
{
velocity
=
PlannerState
::
default_velocity
;
}
std
::
string
planning_mode
;
std
::
string
planning_mode
;
if
(
!
node_handle
.
getParam
(
"robot_planning_mode"
,
planning_mode
))
{
if
(
!
node_handle
.
getParam
(
"robot_planning_mode"
,
planning_mode
))
{
planning_mode
=
PlannerState
::
default_planning_mode
;
planning_mode
=
PlannerState
::
default_planning_mode
;
}
}
ROS_INFO_STREAM
(
"Planning the next trajectory in "
<<
planning_mode
<<
" with velocity "
<<
velocity
);
ROS_INFO_STREAM
(
"Planning the next trajectory in "
<<
planning_mode
);
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
plan
;
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
plan
;
if
(
PlannerState
::
traj_util
.
computePathToPose
(
group
,
plan
,
PlannerState
::
raw_trajectory
.
at
(
i
),
planning_mode
,
0.8
,
if
(
PlannerState
::
traj_util
.
computePathToPose
(
group
,
plan
,
PlannerState
::
raw_trajectory
.
at
(
i
),
planning_mode
,
0.8
,
0.8
,
velocity
))
{
0.8
))
{
group
.
execute
(
plan
);
for
(
auto
trajectory
:
split
(
group
,
plan
))
{
double
motionSpeedFactor
;
if
(
!
node_handle
.
getParam
(
"robot_speed_factor"
,
motionSpeedFactor
))
{
motionSpeedFactor
=
PlannerState
::
default_velocity
;
}
if
(
motionSpeedFactor
<=
0
||
motionSpeedFactor
>
1.0
)
{
ROS_ERROR_STREAM
(
"Invalid motion speed factor "
<<
motionSpeedFactor
<<
". Must be in (0,1]."
);
return
;
}
ROS_INFO_STREAM
(
"Moving to the next waypoint with speed factor "
<<
motionSpeedFactor
);
TrajectoryUtil
::
applyMotionSpeedFactor
(
trajectory
,
motionSpeedFactor
);
moveit_msgs
::
MoveItErrorCodes
errorCode
=
group
.
execute
(
trajectory
);
if
(
errorCode
.
val
!=
errorCode
.
SUCCESS
)
{
ROS_ERROR_STREAM
(
"Error Code from executing segment: "
<<
errorCode
);
}
}
}
else
{
}
else
{
ROS_ERROR_STREAM
(
"The planner was unable to compute a path to the pose with the given settings."
);
ROS_ERROR_STREAM
(
"The planner was unable to compute a path to the pose with the given settings."
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/util/TrajectoryUtil.cpp
+
3
−
11
View file @
016d2bf3
...
@@ -11,7 +11,7 @@ bool TrajectoryUtil::computePathToPose(moveit::planning_interface::MoveGroupInte
...
@@ -11,7 +11,7 @@ bool TrajectoryUtil::computePathToPose(moveit::planning_interface::MoveGroupInte
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
,
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
,
geometry_msgs
::
Pose
targetPose
,
geometry_msgs
::
Pose
targetPose
,
const
std
::
string
&
pathType
,
double
maxVelocityFactor
,
const
std
::
string
&
pathType
,
double
maxVelocityFactor
,
double
maxAccelerationFactor
,
double
motionSpeedFactor
)
{
double
maxAccelerationFactor
)
{
if
(
maxVelocityFactor
<=
0
||
maxVelocityFactor
>
1.0
)
{
if
(
maxVelocityFactor
<=
0
||
maxVelocityFactor
>
1.0
)
{
ROS_ERROR_STREAM
(
"Invalid maximum velocity scaling factor "
<<
maxVelocityFactor
<<
". Must be in (0,1]."
);
ROS_ERROR_STREAM
(
"Invalid maximum velocity scaling factor "
<<
maxVelocityFactor
<<
". Must be in (0,1]."
);
return
false
;
return
false
;
...
@@ -20,10 +20,6 @@ bool TrajectoryUtil::computePathToPose(moveit::planning_interface::MoveGroupInte
...
@@ -20,10 +20,6 @@ bool TrajectoryUtil::computePathToPose(moveit::planning_interface::MoveGroupInte
ROS_ERROR_STREAM
(
"Invalid maximum acceleration scaling factor "
<<
maxAccelerationFactor
<<
". Must be in (0,1]."
);
ROS_ERROR_STREAM
(
"Invalid maximum acceleration scaling factor "
<<
maxAccelerationFactor
<<
". Must be in (0,1]."
);
return
false
;
return
false
;
}
}
if
(
motionSpeedFactor
<=
0
||
motionSpeedFactor
>
1.0
)
{
ROS_ERROR_STREAM
(
"Invalid motion speed factor "
<<
motionSpeedFactor
<<
". Must be in (0,1]."
);
return
false
;
}
group
.
setStartStateToCurrentState
();
group
.
setStartStateToCurrentState
();
group
.
setPlanningTime
(
10.0
);
group
.
setPlanningTime
(
10.0
);
...
@@ -67,14 +63,11 @@ bool TrajectoryUtil::computePathToPose(moveit::planning_interface::MoveGroupInte
...
@@ -67,14 +63,11 @@ bool TrajectoryUtil::computePathToPose(moveit::planning_interface::MoveGroupInte
ROS_ERROR
(
"Invalid type of path provided."
);
ROS_ERROR
(
"Invalid type of path provided."
);
return
false
;
return
false
;
}
}
manipulateVelocity
(
plan
,
motionSpeedFactor
);
return
true
;
return
true
;
}
}
void
TrajectoryUtil
::
manipulateVelocity
(
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
,
double
velocity
)
{
void
TrajectoryUtil
::
applyMotionSpeedFactor
(
moveit_msgs
::
RobotTrajectory
&
trajectory
,
double
velocity
)
{
ROS_INFO_STREAM
(
"slowing down plan with "
<<
plan
.
trajectory_
.
joint_trajectory
.
points
.
size
()
<<
" joints"
);
for
(
auto
&
point
:
trajectory
.
joint_trajectory
.
points
)
{
for
(
auto
&
point
:
plan
.
trajectory_
.
joint_trajectory
.
points
)
{
point
.
time_from_start
*=
1
/
velocity
;
point
.
time_from_start
*=
1
/
velocity
;
for
(
double
&
v
:
point
.
velocities
)
{
for
(
double
&
v
:
point
.
velocities
)
{
v
*=
velocity
;
v
*=
velocity
;
...
@@ -84,5 +77,4 @@ void TrajectoryUtil::manipulateVelocity(moveit::planning_interface::MoveGroupInt
...
@@ -84,5 +77,4 @@ void TrajectoryUtil::manipulateVelocity(moveit::planning_interface::MoveGroupInt
acceleration
=
sqrt
(
std
::
abs
(
acceleration
));
acceleration
=
sqrt
(
std
::
abs
(
acceleration
));
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/util/TrajectoryUtil.h
+
2
−
2
View file @
016d2bf3
...
@@ -25,11 +25,11 @@ public:
...
@@ -25,11 +25,11 @@ public:
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
,
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
,
geometry_msgs
::
Pose
targetPose
,
geometry_msgs
::
Pose
targetPose
,
const
std
::
string
&
pathType
,
double
maxVelocityFactor
,
const
std
::
string
&
pathType
,
double
maxVelocityFactor
,
double
maxAccelerationFactor
,
double
motionSpeedFactor
);
double
maxAccelerationFactor
);
static
void
applyMotionSpeedFactor
(
moveit_msgs
::
RobotTrajectory
&
trajectory
,
double
velocity
);
private:
private:
static
void
manipulateVelocity
(
moveit
::
planning_interface
::
MoveGroupInterface
::
Plan
&
plan
,
double
velocity
);
};
};
#endif //PANDA_SIMULATION_TRAJECTORYUTIL_H
#endif //PANDA_SIMULATION_TRAJECTORYUTIL_H
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment