Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iri_ana_odom
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
labrobotica
ros
robots
ana
iri_ana_odom
Commits
e4f4e5f1
Commit
e4f4e5f1
authored
6 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a subscriber of the cmd_vel topic to generate a new one with the gearbox correction applied.
parent
e42327d1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+3
-2
3 additions, 2 deletions
CMakeLists.txt
include/ana_odom_alg_node.h
+10
-0
10 additions, 0 deletions
include/ana_odom_alg_node.h
package.xml
+1
-0
1 addition, 0 deletions
package.xml
src/ana_odom_alg_node.cpp
+34
-6
34 additions, 6 deletions
src/ana_odom_alg_node.cpp
with
48 additions
and
8 deletions
CMakeLists.txt
+
3
−
2
View file @
e4f4e5f1
...
...
@@ -6,7 +6,7 @@ find_package(catkin REQUIRED)
# ********************************************************************
# Add catkin additional components here
# ********************************************************************
find_package
(
catkin REQUIRED COMPONENTS iri_base_algorithm nav_msgs rosaria
)
find_package
(
catkin REQUIRED COMPONENTS iri_base_algorithm
geometry_msgs
nav_msgs rosaria
)
## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)
...
...
@@ -60,7 +60,7 @@ catkin_package(
# ********************************************************************
# Add ROS and IRI ROS run time dependencies
# ********************************************************************
CATKIN_DEPENDS iri_base_algorithm nav_msgs rosaria
CATKIN_DEPENDS iri_base_algorithm
geometry_msgs
nav_msgs rosaria
# ********************************************************************
# Add system and labrobotica run time dependencies here
# ********************************************************************
...
...
@@ -94,6 +94,7 @@ target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})
# Add message headers dependencies
# ********************************************************************
# add_dependencies(${PROJECT_NAME} <msg_package_name>_generate_messages_cpp)
add_dependencies
(
${
PROJECT_NAME
}
geometry_msgs_generate_messages_cpp
)
add_dependencies
(
${
PROJECT_NAME
}
nav_msgs_generate_messages_cpp
)
add_dependencies
(
${
PROJECT_NAME
}
rosaria_generate_messages_cpp
)
# ********************************************************************
...
...
This diff is collapsed.
Click to expand it.
include/ana_odom_alg_node.h
+
10
−
0
View file @
e4f4e5f1
...
...
@@ -29,6 +29,7 @@
#include
"ana_odom_alg.h"
// [publisher subscriber headers]
#include
<geometry_msgs/Twist.h>
#include
<nav_msgs/Odometry.h>
#include
<rosaria/Encoders.h>
...
...
@@ -45,10 +46,19 @@ class AnaOdomAlgNode : public algorithm_base::IriBaseAlgorithm<AnaOdomAlgorithm>
{
private:
// [publisher attributes]
ros
::
Publisher
cmd_vel_out_publisher_
;
geometry_msgs
::
Twist
cmd_vel_out_Twist_msg_
;
ros
::
Publisher
odom_publisher_
;
nav_msgs
::
Odometry
odom_Odometry_msg_
;
// [subscriber attributes]
ros
::
Subscriber
cmd_vel_in_subscriber_
;
void
cmd_vel_in_callback
(
const
geometry_msgs
::
Twist
::
ConstPtr
&
msg
);
pthread_mutex_t
cmd_vel_in_mutex_
;
void
cmd_vel_in_mutex_enter
(
void
);
void
cmd_vel_in_mutex_exit
(
void
);
ros
::
Subscriber
encoders_subscriber_
;
void
encoders_callback
(
const
rosaria
::
Encoders
::
ConstPtr
&
msg
);
pthread_mutex_t
encoders_mutex_
;
...
...
This diff is collapsed.
Click to expand it.
package.xml
+
1
−
0
View file @
e4f4e5f1
...
...
@@ -50,6 +50,7 @@
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>
catkin
</buildtool_depend>
<build_depend>
iri_base_algorithm
</build_depend>
<depend>
geometry_msgs
</depend>
<depend>
nav_msgs
</depend>
<depend>
rosaria
</depend>
<build_export_depend>
iri_base_algorithm
</build_export_depend>
...
...
This diff is collapsed.
Click to expand it.
src/ana_odom_alg_node.cpp
+
34
−
6
View file @
e4f4e5f1
...
...
@@ -7,9 +7,13 @@ AnaOdomAlgNode::AnaOdomAlgNode(void) :
//this->loop_rate_ = 2;//in [Hz]
// [init publishers]
this
->
cmd_vel_out_publisher_
=
this
->
private_node_handle_
.
advertise
<
geometry_msgs
::
Twist
>
(
"cmd_vel_out"
,
1
);
this
->
odom_publisher_
=
this
->
private_node_handle_
.
advertise
<
nav_msgs
::
Odometry
>
(
"odom"
,
1
);
// [init subscribers]
this
->
cmd_vel_in_subscriber_
=
this
->
private_node_handle_
.
subscribe
(
"cmd_vel_in"
,
1
,
&
AnaOdomAlgNode
::
cmd_vel_in_callback
,
this
);
pthread_mutex_init
(
&
this
->
cmd_vel_in_mutex_
,
NULL
);
this
->
encoders_subscriber_
=
this
->
private_node_handle_
.
subscribe
(
"encoders"
,
1
,
&
AnaOdomAlgNode
::
encoders_callback
,
this
);
pthread_mutex_init
(
&
this
->
encoders_mutex_
,
NULL
);
...
...
@@ -26,27 +30,51 @@ AnaOdomAlgNode::AnaOdomAlgNode(void) :
AnaOdomAlgNode
::~
AnaOdomAlgNode
(
void
)
{
// [free dynamic memory]
pthread_mutex_destroy
(
&
this
->
cmd_vel_in_mutex_
);
pthread_mutex_destroy
(
&
this
->
encoders_mutex_
);
}
void
AnaOdomAlgNode
::
mainNodeThread
(
void
)
{
// [fill msg structures]
// Initialize the topic message structure
//this->odom_Odometry_msg_.data = my_var;
// [fill srv structure and make request to the server]
// [fill action structure and make request to the action server]
// [publish messages]
// Uncomment the following line to publish the topic message
//this->odom_publisher_.publish(this->odom_Odometry_msg_);
}
/* [subscriber callbacks] */
void
AnaOdomAlgNode
::
cmd_vel_in_callback
(
const
geometry_msgs
::
Twist
::
ConstPtr
&
msg
)
{
ROS_INFO
(
"AnaOdomAlgNode::cmd_vel_in_callback: New Message Received"
);
//use appropiate mutex to shared variables if necessary
//this->alg_.lock();
this
->
cmd_vel_in_mutex_enter
();
cmd_vel_out_Twist_msg_
=*
msg
;
cmd_vel_out_Twist_msg_
.
linear
.
x
*=
this
->
config_
.
prev_gearbox_ratio
/
this
->
config_
.
current_gearbox_ratio
;
cmd_vel_out_Twist_msg_
.
angular
.
z
*=
this
->
config_
.
prev_gearbox_ratio
/
this
->
config_
.
current_gearbox_ratio
;
this
->
cmd_vel_out_publisher_
.
publish
(
this
->
cmd_vel_out_Twist_msg_
);
//std::cout << msg->data << std::endl;
//unlock previously blocked shared variables
//this->alg_.unlock();
this
->
cmd_vel_in_mutex_exit
();
}
void
AnaOdomAlgNode
::
cmd_vel_in_mutex_enter
(
void
)
{
pthread_mutex_lock
(
&
this
->
cmd_vel_in_mutex_
);
}
void
AnaOdomAlgNode
::
cmd_vel_in_mutex_exit
(
void
)
{
pthread_mutex_unlock
(
&
this
->
cmd_vel_in_mutex_
);
}
void
AnaOdomAlgNode
::
encoders_callback
(
const
rosaria
::
Encoders
::
ConstPtr
&
msg
)
{
static
long
int
prev_left_enc
=
0
;
...
...
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