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
91faa066
Commit
91faa066
authored
3 years ago
by
Christoph Schröter
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
a87d8246
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+2
-0
2 additions, 0 deletions
CMakeLists.txt
launch/cobot1_mock_test.launch
+1
-0
1 addition, 0 deletions
launch/cobot1_mock_test.launch
src/tron_adapter.cpp
+26
-6
26 additions, 6 deletions
src/tron_adapter.cpp
with
29 additions
and
6 deletions
CMakeLists.txt
+
2
−
0
View file @
91faa066
...
...
@@ -4,6 +4,8 @@ project(cobot_1)
#add_compile_options(-std=c++14)
set
(
GCC_COVERAGE_COMPILE_FLAGS
"-fpermissive"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
GCC_COVERAGE_COMPILE_FLAGS
}
${
GAZEBO_CXX_FLAGS
}
"
)
# Wichtig für VSCode debugging
set
(
CMAKE_BUILD_TYPE Debug
)
# Find catkin macros and libraries if COMPONENTS list like `find_package(catkin REQUIRED COMPONENTS xyz)` is used,
# also find other catkin packages
...
...
This diff is collapsed.
Click to expand it.
launch/cobot1_mock_test.launch
+
1
−
0
View file @
91faa066
...
...
@@ -9,6 +9,7 @@
<include file="$(find pressure_sensor)/launch/pressure_sensor_mock.launch" />
<node name="Cobot1_TRONAdapter" pkg="cobot_1" type="TRON_Adapter" respawn="false" output="screen"/>
<node name="Cobot1_Controller" pkg="cobot_1" type="CobotController" respawn="false" output="screen">
<rosparam command="load" file="$(find cobot_1)/config/cobot1_config.yaml" />
</node>
...
...
This diff is collapsed.
Click to expand it.
src/tron_adapter.cpp
+
26
−
6
View file @
91faa066
...
...
@@ -7,6 +7,8 @@
#include
<boost/make_shared.hpp>
#include
<memory>
#include
<cooperation_msgs/PressureMsg.h>
#include
<moveit_msgs/PickupActionResult.h>
#include
<moveit_msgs/MoveItErrorCodes.h>
const
std
::
string
IP
=
"127.0.0.1"
;
const
uint16_t
PORT
=
8080
;
...
...
@@ -185,7 +187,7 @@ struct Mapping {
this
->
channel
=
*
send_channel_decl_msg
(
channelIsInput
,
channel
).
get
();
}
void
add_var_to_mapping
(
std
::
string
name_tron
,
int
byte_offset
,
void
add_var_to_mapping
(
std
::
string
name_tron
,
int
byte_offset
=
0
,
int32_t
(
*
conv_to_TRON
)(
byte
*
,
int
*
)
=
nullptr
,
void
(
*
conv_to_topic
)(
int32_t
,
byte
*
,
int
*
)
=
nullptr
){
add_var_to_channel
(
this
->
channel
,
this
->
channel
.
is_input
,
name_tron
);
...
...
@@ -353,6 +355,14 @@ void report_now(Channel& chan, uint16_t var_count = 0, int32_t *vars = nullptr){
acks_missing
++
;
}
void
report_now
(
std
::
string
chan
,
uint16_t
var_count
=
0
,
int32_t
*
vars
=
nullptr
){
for
(
Mapping
&
map
:
mappings
)
if
(
map
.
channel
.
name
==
chan
)
{
report_now
(
map
.
channel
,
var_count
,
vars
);
return
;
}
}
// callback reports to TRON like defined in mappings
template
<
class
T
>
void
mappings_callback_to_TRON
(
const
ros
::
MessageEvent
<
T
>&
event
){
...
...
@@ -381,25 +391,35 @@ void mappings_callback_to_TRON(const ros::MessageEvent<T>& event){
}
int32_t
retry_count
;
void
on_pressure
(
const
cooperation_msgs
::
PressureMsg
::
ConstPtr
&
msg
)
{
if
(
msg
->
pressed
)
for
(
Mapping
&
map
:
mappings
)
{
if
(
map
.
channel
.
name
==
"pressed"
&&
map
.
channel
.
is_input
==
false
)
report_now
(
map
.
channel
);
report_now
(
"pressed"
,
1
,
&
retry_count
);
}
void
on_pickup_result
(
const
moveit_msgs
::
PickupActionResult
::
ConstPtr
&
msg
)
{
if
(
msg
->
result
.
error_code
.
val
==
moveit_msgs
::
MoveItErrorCodes
::
SUCCESS
)
report_now
(
"pickup_success"
);
else
report_now
(
"pickup_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 */
nh
.
getParam
(
"/planning/retries"
,
retry_count
);
// note: since we are not an actual client (or server)
// we need to use the high level packet::*Action* messages.
// custom callbacks are implemented in order to not worry about header size
Mapping
map
=
Mapping
(
"/pressure"
,
"pressed"
,
false
);
map
.
add_var_to_mapping
(
"init_retry_count"
);
mappings
.
push_back
(
map
);
output_subscribers
.
push_back
(
nh
.
subscribe
(
"/pressure"
,
10
,
on_pressure
));
map
=
Mapping
(
"/pickup/result"
,
"pickup_fail"
,
false
);
map
=
Mapping
(
"/pickup/result"
,
"pickup_success"
,
false
);
output_subscribers
.
push_back
(
nh
.
subscribe
(
"/pickup/result"
,
10
,
on_pickup_result
));
// 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