Yunfan REN
GIVE ME A STAR ⭐️⭐️⭐️⭐️⭐️⭐️⭐️ NOW!!!
sudo apt-get install ros-${your_ros_version}-serial
mkdir -p catkin_ws/src
cd catkin_ws/src
git clone git@github.com:RENyunfan/wtr_serial.git
cd ..
catkin_make
Plug in the USB2TTL module
and then authorize the serial port
sudo chmod +777 /dev/ttyUSB0
Launch the main node
cd catkin_ws
source devel/setup.bash
rosrun wtr_serial main
Then you just need to publish a message of typegeometry_msgs/Twist
to the topic /wtr/chassis/twist
with a recommended rate of 100Hz
to control the chassis. See the example in ./wtr_serial/App/controller.cpp
Attention:Please set the speed in a relative low value, try from 0.1
#include <ros/ros.h>
#include "geometry_msgs/Twist.h"
using namespace std;
ros::Publisher twistPub;
int main(int argc, char** argv)
{
ros::init(argc, argv, "wtr_twist");
ros::NodeHandle n;
twistPub = n.advertise<geometry_msgs::Twist>("/wtr/chassis/twist",1);
ros::Rate loop_rate(100);
geometry_msgs::Twist speedToPub;
while(ros::ok())
{
speedToPub.angular.z = 0.1;
speedToPub.linear.x = 0.1;
speedToPub.linear.y = 0.1;
twistPub.publish(speedToPub);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
See more in joy2twist