Closed Astrobubu closed 3 years ago
alright, the new odrive update ruins the entire robot code...
Master Bruton, Don't update ODrive :P
as for the solution, use windows to reflash odrive firmware. ubuntu just throws unicode errors make sure to follow the instructions and use the STM32Cube tool to reflash, it will do it in a second compared to the crappy dfu tool which will make ur night hell.
i have played around and converted the wheel calculation to the new odrive standards, using this equation Turns = Counts/EncoderCpr
everything works perfectly except the odometry messages not sending the correct orientation of the robot. more like it is oscillating right and left while moving forward. here is a link of the movement: https://youtu.be/_V9KNEuVXbw and the low refresh rate is also a problem :( do keep in mind the robot is connected to the pc and the data of the movement is coming from odom
the only different thing I'm using is Teensy 4.0
I'm using the First upload of the here is the Arduino code:
include
//ODrive Objects ODriveArduino odrive1(Serial1);
//ROS
include "ros.h"
include "geometry_msgs/Twist.h"
include <ros/time.h>
include <tf/tf.h>
include <tf/transform_broadcaster.h>
include <nav_msgs/Odometry.h>
include <geometry_msgs/Vector3.h>
ros::NodeHandle nh; geometry_msgs::TransformStamped t; nav_msgs::Odometry odom_msg; ros::Publisher odom_pub("odom", &odom_msg); tf::TransformBroadcaster broadcaster;
// tf variables to be broadcast double x = 0; double y = 0; double theta = 0;
char base_link[] = "/base_link"; char odom[] = "/odom";
// cmd_vel variables to be received to drive with float demandx; float demandz;
// timers for the sub-main loop unsigned long currentMillis; long previousMillis = 0; // set up timers float loopTime = 10;
// ODrive init stuff int button; int requested_state;
// output variables to drive the ODrive int forward0; int forward1; int turn0; int turn1;
// position and velocity variables read from the ODrive int vel0; int vel1; long pos0; long pos1;
// variables to work out the different on each cycle
long pos0_old; long pos1_old; long pos0_diff; long pos1_diff; float pos0_mm_diff; float pos1_mm_diff; float pos_average_mm_diff; float pos_total_mm;
// ROS callback & subscriber
void velCallback( const geometry_msgs::Twist& vel) { demandx = vel.linear.x; demandz = vel.angular.z; }
ros::Subscriber sub("cmd_vel" , velCallback);
// Setup
void setup() {
}
// Main loop
void loop() {
} // end of main loop
.