64 boost::mutex::scoped_lock lock(
mMutex);
72 char cmd_str[5] = { (char)0xcd, (
char)0xeb, (char)0xd7, (
char)0x01, (char)0x43 };
84 char cmd_str[6] = { (char)0xcd, (
char)0xeb, (char)0xd7, (
char)0x02, (char)0x44, (
char)0x01 };
93 char cmd_str[6] = { (char)0xcd, (
char)0xeb, (char)0xd7, (
char)0x02, (char)0x44, (
char)0x00 };
102 static time_t t1 = time(NULL), t2;
103 int i = 0, wheel_ppr = 1;
104 double separation = 0, radius = 0, speed_lin = 0, speed_ang = 0, speed_temp[2];
105 char speed[2] = { 0, 0 };
106 char cmd_str[13] = { (char)0xcd, (
char)0xeb, (char)0xd7, (
char)0x09, (char)0x74, (
char)0x53, (char)0x53,
107 (
char)0x53, (char)0x53, (
char)0x00, (char)0x00, (
char)0x00, (char)0x00 };
115 speed_lin = command.linear.x / (2.0 *
PI * radius);
116 speed_ang = command.angular.z * separation / (2.0 *
PI * radius);
118 float scale = std::max(std::abs(speed_lin + speed_ang / 2.0), std::abs(speed_lin - speed_ang / 2.0)) /
max_wheelspeed;
128 speed_temp[0] = scale * (speed_lin + speed_ang / 2) /
max_wheelspeed * 100.0;
129 speed_temp[0] = std::min(speed_temp[0], 100.0);
130 speed_temp[0] = std::max(-100.0, speed_temp[0]);
132 speed_temp[1] = scale * (speed_lin - speed_ang / 2) /
max_wheelspeed * 100.0;
133 speed_temp[1] = std::min(speed_temp[1], 100.0);
134 speed_temp[1] = std::max(-100.0, speed_temp[1]);
140 for (i = 0; i < 2; i++)
142 speed[i] = speed_temp[i];
145 cmd_str[5 + i] = (char)0x42;
146 cmd_str[9 + i] = -speed[i];
148 else if (speed[i] > 0)
150 cmd_str[5 + i] = (char)0x46;
151 cmd_str[9 + i] = speed[i];
155 cmd_str[5 + i] = (char)0x53;
156 cmd_str[9 + i] = (char)0x00;
191 boost::mutex::scoped_lock lock(
mMutex);
194 cmd_str[5] = (char)0x53;
195 cmd_str[6] = (char)0x53;
double get_wheel_radius()
void updateMoveFlag(const std_msgs::Bool &moveFlag)
StatusPublisher * xq_status
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void spin(Spinner &spinner)
void sendcmd(const geometry_msgs::Twist &command)
void write(const char *data, size_t size)
void updateBarDetectFlag(const std_msgs::Bool &DetectFlag)
CallbackAsyncSerial * cmd_serial
void imuCalibration(const std_msgs::Bool &calFlag)
double get_wheel_separation()