Skip to content

Commit

Permalink
Setting the timer_cb frequency explicitly during creation rather usin…
Browse files Browse the repository at this point in the history
…g rate::sleep()
  • Loading branch information
adnanmunawar committed Oct 27, 2017
1 parent 9a99846 commit 579fb24
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion dvrk_arm/include/dvrk_arm/Bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DVRK_Bridge: public States, public DVRK_FootPedals{
friend class DVRK_FootPedals;
friend class DVRK_Console;

DVRK_Bridge(const std::string &arm_name);
DVRK_Bridge(const std::string &arm_name, int bridge_frequnce = 1000);
~DVRK_Bridge();

template <class T, class U>
Expand Down Expand Up @@ -61,6 +61,7 @@ class DVRK_Bridge: public States, public DVRK_FootPedals{
ros::Timer timer;
AspinPtr aspin;
RatePtr rate;
int _freq;

double scale;
bool _is_cnvFcn_set;
Expand Down
6 changes: 2 additions & 4 deletions dvrk_arm/src/Bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "dvrk_arm/Bridge.h"

DVRK_Bridge::DVRK_Bridge(const std::string &arm_name){
DVRK_Bridge::DVRK_Bridge(const std::string &arm_name, int bridge_frequency): _freq(bridge_frequency){
valid_arms.push_back("MTML");
valid_arms.push_back("MTMR");
valid_arms.push_back("PSM1");
Expand Down Expand Up @@ -30,13 +30,12 @@ void DVRK_Bridge::init(){
char** argv;
ros::M_string s;
ros::init(s, arm_name + "_interface_node");

n.reset(new ros::NodeHandle);
nTimer.reset(new ros::NodeHandle);
n->setCallbackQueue(&cb_queue);
nTimer->setCallbackQueue(&cb_queue_timer);
rate.reset(new ros::Rate(1000));
timer = nTimer->createTimer(ros::Duration(), &DVRK_Bridge::timer_cb, this);
timer = nTimer->createTimer(ros::Duration(1/(double)_freq), &DVRK_Bridge::timer_cb, this);
aspin.reset(new ros::AsyncSpinner(0, &cb_queue_timer));

pose_sub = n->subscribe("/dvrk/" + arm_name + "/position_cartesian_current", 10, &DVRK_Bridge::pose_sub_cb, this);
Expand Down Expand Up @@ -86,7 +85,6 @@ void DVRK_Bridge::state_sub_cb(const std_msgs::StringConstPtr &msg){
}

void DVRK_Bridge::timer_cb(const ros::TimerEvent& event){
_rate_sleep();
cb_queue.callAvailable();
if(_start_pubs == true){
switch (activeState) {
Expand Down

0 comments on commit 579fb24

Please sign in to comment.