Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cobot1_TRON_testing
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Schröter
cobot1_TRON_testing
Commits
1d32add1
Commit
1d32add1
authored
3 years ago
by
Christoph Schröter
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
91faa066
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tron_adapter.cpp
+22
-1
22 additions, 1 deletion
src/tron_adapter.cpp
with
22 additions
and
1 deletion
src/tron_adapter.cpp
+
22
−
1
View file @
1d32add1
...
...
@@ -9,6 +9,8 @@
#include
<cooperation_msgs/PressureMsg.h>
#include
<moveit_msgs/PickupActionResult.h>
#include
<moveit_msgs/MoveItErrorCodes.h>
#include
<moveit_msgs/MoveGroupActionResult.h>
#include
<control_msgs/FollowJointTrajectoryAction.h>
const
std
::
string
IP
=
"127.0.0.1"
;
const
uint16_t
PORT
=
8080
;
...
...
@@ -357,10 +359,11 @@ void report_now(Channel& chan, uint16_t var_count = 0, int32_t *vars = nullptr){
void
report_now
(
std
::
string
chan
,
uint16_t
var_count
=
0
,
int32_t
*
vars
=
nullptr
){
for
(
Mapping
&
map
:
mappings
)
if
(
map
.
channel
.
name
==
chan
)
{
if
(
map
.
channel
.
name
==
chan
&&
!
map
.
channel
.
is_input
)
{
report_now
(
map
.
channel
,
var_count
,
vars
);
return
;
}
throw
"could not report to channel"
;
}
// callback reports to TRON like defined in mappings
...
...
@@ -404,6 +407,12 @@ void on_pickup_result(const moveit_msgs::PickupActionResult::ConstPtr &msg) {
else
report_now
(
"pickup_fail"
);
}
void
on_move_result
(
const
control_msgs
::
FollowJointTrajectoryActionResult
::
ConstPtr
&
msg
){
if
(
msg
->
result
.
error_code
==
control_msgs
::
FollowJointTrajectoryResult
::
SUCCESSFUL
)
report_now
(
"move_success"
);
else
report_now
(
"move_fail"
);
}
void
configuration_phase
(
ros
::
NodeHandle
&
nh
){
/* note: for configuration phase maximum message length is 256 Bytes,
therefore heap allocation can be avoided most of the time in called functions */
...
...
@@ -418,8 +427,20 @@ void configuration_phase(ros::NodeHandle& nh){
output_subscribers
.
push_back
(
nh
.
subscribe
(
"/pressure"
,
10
,
on_pressure
));
map
=
Mapping
(
"/pickup/result"
,
"pickup_fail"
,
false
);
mappings
.
push_back
(
map
);
map
=
Mapping
(
"/pickup/result"
,
"pickup_success"
,
false
);
mappings
.
push_back
(
map
);
output_subscribers
.
push_back
(
nh
.
subscribe
(
"/pickup/result"
,
10
,
on_pickup_result
));
// there is a separate controller for hand movement, this one is for arm movement
map
=
Mapping
(
"/position_joint_trajectory_controller/follow_joint_trajectory/result"
,
"move_fail"
,
false
);
mappings
.
push_back
(
map
);
map
=
Mapping
(
"/position_joint_trajectory_controller/follow_joint_trajectory/result"
,
"move_success"
,
false
);
mappings
.
push_back
(
map
);
output_subscribers
.
push_back
(
nh
.
subscribe
(
"/position_joint_trajectory_controller/follow_joint_trajectory/result"
,
10
,
on_move_result
));
// TODO: place and variables
// not obvious in documentation: local variables are not supported
// add_var_to_channel(socketfd, "ausloesen", "lokal");
uint64_t
microseconds
=
1000000
;
// one second
...
...
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