mirror of
https://github.com/modelec/ros2_roboclaw_driver.git
synced 2026-01-18 16:47:26 +01:00
29 lines
836 B
C++
29 lines
836 B
C++
#pragma once
|
|
|
|
#include "roboclaw_cmd.h"
|
|
|
|
class CmdSetEncoderValue : public Cmd {
|
|
public:
|
|
CmdSetEncoderValue(RoboClaw &roboclaw, RoboClaw::kMotor motor, long value)
|
|
: Cmd(roboclaw, "SetEncoderValue", motor), value_(value) {}
|
|
|
|
void send() override {
|
|
roboclaw_.appendToWriteLog(
|
|
"SetEncoderValue: motor: %d (%s) value: %ld, WROTE: ", motor_,
|
|
RoboClaw::motorNames_[motor_], value_);
|
|
try {
|
|
roboclaw_.writeN2(true, 6, roboclaw_.portAddress_,
|
|
motor_ == RoboClaw::kM1 ? RoboClaw::SETM1ENCODER
|
|
: RoboClaw::SETM2ENCODER,
|
|
SetDWORDval(value_));
|
|
return;
|
|
} catch (...) {
|
|
RCUTILS_LOG_ERROR(
|
|
"[RoboClaw::CmdSetEncoderValue] Uncaught exception !!!");
|
|
}
|
|
}
|
|
|
|
private:
|
|
long value_;
|
|
};
|