Skip to content

Commit

Permalink
fix for the rflex delay on atrvjr.
Browse files Browse the repository at this point in the history
We should not wait to propagate the commands down to the driver,
it should be immediate.
  • Loading branch information
Mikhail Medvedev committed Oct 9, 2012
1 parent df3f4a1 commit 09d9e16
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions atrvjr_drivers/rflex/src/atrvjr_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ ATRVJRNode::~ATRVJRNode() {
void ATRVJRNode::NewCommand(const geometry_msgs::Twist::ConstPtr& msg) {
cmdTranslation = msg->linear.x;
cmdRotation = msg->angular.z;
driver.setMovement(cmdTranslation, cmdRotation, acceleration);
}

/// cmd_acceleration callback
Expand All @@ -134,13 +135,14 @@ void ATRVJRNode::SetAcceleration (const std_msgs::Float32::ConstPtr& msg) {
/// cmd_sonar_power callback
void ATRVJRNode::ToggleSonarPower(const std_msgs::Bool::ConstPtr& msg) {
isSonarOn=msg->data;
sonar_dirty = true;
driver.setSonarPower(isSonarOn);
driver.sendSystemStatusCommand();
}

/// cmd_brake_power callback
void ATRVJRNode::ToggleBrakePower(const std_msgs::Bool::ConstPtr& msg) {
isBrakeOn = msg->data;
brake_dirty = true;
driver.setBrakePower(isBrakeOn);
}

void ATRVJRNode::spinOnce() {
Expand All @@ -151,20 +153,6 @@ void ATRVJRNode::spinOnce() {
}
updateTimer++;

if (cmdTranslation != 0 || cmdRotation != 0)
driver.setMovement(cmdTranslation, cmdRotation, acceleration);

if (sonar_dirty) {
driver.setSonarPower(isSonarOn);
sonar_dirty = false;
driver.sendSystemStatusCommand();
}
if (brake_dirty) {
driver.setBrakePower(isBrakeOn);
brake_dirty = false;
updateTimer = 99;
}

std_msgs::Bool bmsg;
bmsg.data = isSonarOn;
sonar_power_pub.publish(bmsg);
Expand Down Expand Up @@ -317,9 +305,9 @@ int main(int argc, char** argv) {
ros::Rate loop_rate(hz);

while (ros::ok()) {
node.spinOnce();
// Process a round of subscription messages
ros::spinOnce();
node.spinOnce();
// This will adjust as needed per iteration
loop_rate.sleep();
}
Expand Down

0 comments on commit 09d9e16

Please sign in to comment.