Skip to content

Commit

Permalink
Merge pull request #1 from szlachcic/master
Browse files Browse the repository at this point in the history
fix angleCallback
  • Loading branch information
bjsowa authored May 10, 2019
2 parents 9639c1f + faff49b commit 750270a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DiffController *dc;
class ServoWrapper
{
int num;
int per;
IServo& servo;

public:
Expand All @@ -40,13 +41,18 @@ class ServoWrapper

void angleCallback(const std_msgs::Int16& msg)
{
servo.setPeriod(SERVO_PERIOD);
if (per!=SERVO_PERIOD)
{
servo.setPeriod(SERVO_PERIOD);
per=SERVO_PERIOD;
}
servo.rotAbs(msg.data);
Serial.printf("[servo%dAngleCallback] angle: %d\r\n", num, msg.data);
}

void pwmCallback(const std_msgs::UInt16MultiArray& msg)
{
per=msg.data[0];
servo.setPeriod(msg.data[0]);
servo.setWidth(msg.data[1]);
Serial.printf("[servo%dPWMCallback] period: %d width: %d\r\n", num, msg.data[0], msg.data[1]);
Expand Down

0 comments on commit 750270a

Please sign in to comment.