2020-04-24 14:58:56 -0500 | received badge | ● Famous Question
(source)
|
2020-04-22 01:30:10 -0500 | received badge | ● Famous Question
(source)
|
2018-09-21 03:29:08 -0500 | received badge | ● Good Question
(source)
|
2018-09-19 14:16:39 -0500 | marked best answer | Publish data from PCI-6229 Hi I want to read encoder data from a NI PCI-6229 and publish it to a topic (for gmapping).
Are there any tutorials about this or can someone help me with this?
I can't seem to get started. Thanks! |
2018-09-19 14:16:14 -0500 | received badge | ● Famous Question
(source)
|
2018-09-19 14:16:14 -0500 | received badge | ● Notable Question
(source)
|
2018-09-18 15:22:44 -0500 | received badge | ● Nice Question
(source)
|
2018-09-18 08:51:29 -0500 | received badge | ● Notable Question
(source)
|
2018-05-31 18:20:24 -0500 | received badge | ● Student
(source)
|
2018-05-30 11:18:02 -0500 | received badge | ● Notable Question
(source)
|
2018-05-30 11:18:02 -0500 | received badge | ● Popular Question
(source)
|
2018-04-23 11:15:42 -0500 | received badge | ● Famous Question
(source)
|
2017-05-15 04:01:34 -0500 | received badge | ● Famous Question
(source)
|
2016-08-17 09:01:59 -0500 | received badge | ● Famous Question
(source)
|
2016-07-21 10:16:53 -0500 | received badge | ● Famous Question
(source)
|
2016-07-16 01:37:48 -0500 | received badge | ● Popular Question
(source)
|
2016-06-22 02:49:42 -0500 | received badge | ● Famous Question
(source)
|
2016-06-13 08:22:53 -0500 | received badge | ● Famous Question
(source)
|
2016-06-02 14:58:34 -0500 | marked best answer | Odometry message errors Hi! With examples I found online I made an odometry publisher that generates odometry data (for gmapping) from encoder ticks. But When the robot is going straight forward, the odometry data gives the same translation in x en y direction.
Where are my mistakes? Here is the full publisher: #include "ros/ros.h"
#include <geometry_msgs/Vector3.h>
#include <tf/transform_broadcaster.h>
#include <nav_msgs/Odometry.h>
#include "mastering_ros_demo_pkg/encoder_msg.h"
long _PreviousLeftEncoderCounts = 0;
long _PreviousRightEncoderCounts = 0;
ros::Time current_time_encoder, last_time_encoder;
//double DistancePerCount = (3.14159265 * 0.1524) / 200;
double DistancePerCount=1;
double x;
double y;
double th=0;
double W;
double V;
double vx;
double vy;
double vth;
double deltaLeft;
double deltaRight;
double d=50; //afstand tussen de wielen
int ticks_links;
int ticks_rechts;
//void WheelCallback(const geometry_msgs::Vector3::ConstPtr& ticks)
void WheelCallback(const mastering_ros_demo_pkg::encoder_msg::ConstPtr& msg)
{
//tijd van de meting
current_time_encoder = ros::Time::now();
//verschil in ticks tov vorige berekening
deltaLeft = msg->ticks_links - _PreviousLeftEncoderCounts;
deltaRight = msg->ticks_rechts - _PreviousRightEncoderCounts;
//snelheid links (x) en rechts (y)
vx = deltaLeft * DistancePerCount / (current_time_encoder - last_time_encoder).toSec();
vy = deltaRight * DistancePerCount / (current_time_encoder - last_time_encoder).toSec();
//als snelheid links = snelheid rechts -> snelheid = snelheid links en hoeksnelheid = 0
if (vx == vy)
{
V = vx;
W = 0;
}
else
{
// Assuming the robot is rotating about point A
// W = vel_left/r = vel_right/(r + d), see the image below for r and d
double r = (vx * d) / (vy - vx); // Anti Clockwise is positive
W = vx/r; // Rotational velocity of the robot
V = W * (r + d/2); // Translation velocity of the robot
}
//vth = hoeksnelheid
vth= W;
//aantal ticks onthouden
_PreviousLeftEncoderCounts = msg->ticks_links;
_PreviousRightEncoderCounts = msg->ticks_rechts;
//tijd van de laatste meting onthouden
last_time_encoder = current_time_encoder;
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "odometry_publisher");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("tick_topic", 100, WheelCallback);
//ros::Subscriber sub1 = n.subscribe("tick_topic", 100, ticks_topic_callback);
ros::Publisher odom_pub = n.advertise<nav_msgs::Odometry>("odom", 50);
tf::TransformBroadcaster odom_broadcaster;
ros::Time current_time, last_time;
current_time = ros::Time::now();
last_time = ros::Time::now();
ros::Rate r(20.0);
while(n.ok()){
current_time = ros::Time::now();
//compute odometry in a typical way given the velocities of the robot
double dt = (current_time - last_time).toSec();
double delta_x = (vx * cos(th) - vy * sin(th)) * dt;
double delta_y = (vx * sin(th) + vy * cos(th)) * dt;
double delta_th = vth * dt;
x += delta_x;
y += delta_y;
th += delta_th;
//since all odometry is 6DOF we'll need a quaternion created from yaw
geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);
//first, we'll publish the transform over tf
geometry_msgs::TransformStamped odom_trans;
odom_trans.header.stamp = current_time;
odom_trans.header.frame_id = "odom";
odom_trans.child_frame_id = "base_link";
odom_trans.transform.translation.x = x;
odom_trans.transform.translation.y = y;
odom_trans.transform.translation.z = 0.0;
odom_trans.transform.rotation = odom_quat;
//send the transform
odom_broadcaster.sendTransform(odom_trans);
//next, we'll publish the odometry message over ROS
nav_msgs::Odometry odom;
odom.header.stamp = current_time;
odom.header.frame_id = "odom";
//set the position
odom.pose.pose.position.x = x;
odom.pose.pose.position.y = y;
odom.pose.pose.position.z = 0.0;
odom.pose.pose.orientation = odom_quat;
//set the velocity
odom.child_frame_id = "base_link";
odom.twist.twist.linear ... (more) |
2016-05-30 03:14:46 -0500 | commented answer | What is tf_static? In my launch file I use: <!-- tf transform -->
<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="-0.45 0 0 3.1765 0 3.1415 /base_link /laser 100"/>
Has this anything to do with /tf_static or is it just the /map_nav_broadcaster node? |
2016-05-30 01:54:49 -0500 | received badge | ● Notable Question
(source)
|
2016-05-28 16:47:42 -0500 | received badge | ● Popular Question
(source)
|
2016-05-28 09:11:35 -0500 | asked a question | What is tf_static? Hi I am currently writing my masters thesis. I used a lot of different algorithms like Hector mapping, Gmapping and AMCL.
I am trying to explain those by using the RQT-graphs. In each of those graphs I see the tf_static topic. What is function of this?
Thanks! |
2016-05-13 02:40:04 -0500 | received badge | ● Notable Question
(source)
|
2016-05-12 22:32:45 -0500 | received badge | ● Notable Question
(source)
|
2016-05-12 20:22:24 -0500 | received badge | ● Popular Question
(source)
|
2016-05-12 08:09:37 -0500 | asked a question | Path planning with adaptive Monte Carlo Localization ( AMCL ) Hi The localisation for my mobile robot works with the AMCL package. Apparently you can also implement path planning with this package. But I don't find anything about this, how does this work? This is my current launch file for the localisation: <?xml version="1.0"?>
<launch>
<!-- load map -->
<arg name="map_file" default="$(find mastering_ros_demo_pkg)/trappenhaliteratie20.yaml"/>
<node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)" />
<!-- start hokuyo_node -->
<node name="hokuyo_node" pkg="hokuyo_node" type="hokuyo_node" output="screen"/>
<arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
<arg name="base_frame" default="base_footprint"/>
<arg name="odom_frame" default="nav"/>
<arg name="pub_map_odom_transform" default="true"/>
<arg name="scan_subscriber_queue_size" default="5"/>
<arg name="scan_topic" default="scan"/>
<arg name="map_size" default="2048"/>
<!-- start odometry_node -->
<node name="odometry" pkg="mastering_ros_demo_pkg" type="odometry" output="screen"/>
<!-- tf transform -->
<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="-0.45 0 0 3.1765 0 3.1415 /base_link /laser 100"/>
<!-- Generate robot model -->
<param name="robot_description" command="cat $(find mastering_ros_demo_pkg)/urdf/rolstoel.urdf" />
<node pkg="rviz" type="rviz" name="rviz"/>
<node pkg="amcl" type="amcl" name="amcl" output="screen">
<!-- Publish scans from best pose at a max of 10 Hz -->
<param name="odom_model_type" value="diff"/>
<param name="odom_alpha5" value="0.1"/>
<param name="transform_tolerance" value="0.2" />
<param name="gui_publish_rate" value="10.0"/>
<param name="laser_max_beams" value="30"/>
<param name="min_particles" value="500"/>
<param name="max_particles" value="5000"/>
<param name="kld_err" value="0.05"/>
<param name="kld_z" value="0.99"/>
<param name="odom_alpha1" value="0.2"/>
<param name="odom_alpha2" value="0.2"/>
<!-- translation std dev, m -->
<param name="odom_alpha3" value="0.8"/>
<param name="odom_alpha4" value="0.2"/>
<param name="laser_z_hit" value="0.5"/>
<param name="laser_z_short" value="0.05"/>
<param name="laser_z_max" value="0.05"/>
<param name="laser_z_rand" value="0.5"/>
<param name="laser_sigma_hit" value="0.2"/>
<param name="laser_lambda_short" value="0.1"/>
<param name="laser_lambda_short" value="0.1"/>
<param name="laser_model_type" value="likelihood_field"/>
<!-- <param name="laser_model_type" value="beam"/> -->
<param name="laser_likelihood_max_dist" value="2.0"/>
<param name="update_min_d" value="0.2"/>
<param name="update_min_a" value="0.5"/>
<param name="odom_frame_id" value="odom"/>
<param name="resample_interval" value="1"/>
<param name="transform_tolerance" value="0.1"/>
<param name="recovery_alpha_slow" value="0.0"/>
<param name="recovery_alpha_fast" value="0.0"/>
</node>
</launch>
|
2016-05-12 03:46:00 -0500 | commented answer | Visualize robot in gmapping Do I need the xacro file? Or can I just work with my urdf file? |
2016-05-12 02:16:03 -0500 | received badge | ● Popular Question
(source)
|
2016-05-11 14:20:49 -0500 | asked a question | Visualize robot in gmapping Hi I have gmapping working for my mobile robot.
Now I can see the position of my robot by visualizing tf, so that I can see the base link and laser.
But I want to see a simplified version of my robot, a rectangle should do, but how do I get this? Thanks! EDIT:
This is my current launch file: <?xml version="1.0"?>
<launch>
<!-- start hokuyo_node -->
<node name="hokuyo_node" pkg="hokuyo_node" type="hokuyo_node" output="screen"/>
<arg name="tf_map_scanmatch_transform_frame_name" default="scanmatcher_frame"/>
<arg name="base_frame" default="base_footprint"/>
<arg name="odom_frame" default="nav"/>
<arg name="pub_map_odom_transform" default="true"/>
<arg name="scan_subscriber_queue_size" default="5"/>
<arg name="scan_topic" default="scan"/>
<arg name="map_size" default="2048"/>
<!-- start odometry_node -->
<node name="odometry" pkg="mastering_ros_demo_pkg" type="odometry" output="screen"/>
<!-- start g_mapping -->
<node name="slam_gmapping" pkg="gmapping" type="slam_gmapping" output="screen">
<param name="ogain" value="10"/> <!-- default 3 -->
<param name="throttle_scans" value="1"/>
<param name="map_update_interval" value="1"/>
<param name="iterations" value="20"/> <!-- default 5 -->
<param name="lsigma" value="0.075"/> <!-- default 0.075 -->
<param name="delta" value="0.03"/> <!-- default 0.05 -->
<param name="linearUpdate" value="0.5"/> <!-- default 1.0 -->
<param name="angularUpdate" value="0.5"/> <!-- default 0.5 -->
</node>
<!-- Frame names -->
<param name="map_frame" value="map" />
<!--
<param name="base_frame" value="$(arg base_frame)" />
<param name="odom_frame" value="$(arg odom_frame)" />
-->
<param name="base_frame" value="base_frame" />
<param name="odom_frame" value="base_frame" />
<!-- Tf use -->
<param name="use_tf_scan_transformation" value="true"/>
<param name="use_tf_pose_start_estimate" value="false"/>
<!--
<param name="pub_map_odom_transform" value="$(arg pub_map_odom_transform)"/>
-->
<param name="pub_map_odom_transform" value="true"/>
<!-- Map size / start point -->
<param name="map_resolution" value="0.010"/>
<param name="map_size" value="$(arg map_size)"/>
<param name="map_start_x" value="0.5"/>
<param name="map_start_y" value="0.5" />
<param name="map_multi_res_levels" value="2" />
<!-- Map update parameters -->
<param name="update_factor_free" value="0.4"/>
<param name="update_factor_occupied" value="0.9" />
<param name="map_update_distance_thresh" value="0.4"/>
<param name="map_update_angle_thresh" value="0.06" />
<param name="laser_z_min_value" value = "-1.0" />
<param name="laser_z_max_value" value = "1.0" />
<!-- Advertising config -->
<param name="advertise_map_service" value="true"/>
<param name="scan_subscriber_queue_size" value="$(arg scan_subscriber_queue_size)"/>
<param name="scan_topic" value="$(arg scan_topic)"/>
<!-- Debug parameters -->
<!--
<param name="output_timing" value="false"/>
<param name="pub_drawings" value="true"/>
<param name="pub_debug_output" value="true"/>
-->
<param name="tf_map_scanmatch_transform_frame_name" value="$(arg tf_map_scanmatch_transform_frame_name)" />
<!--
</node>
-->
<node pkg="tf" type="static_transform_publisher" name="map_nav_broadcaster" args="-0.45 0 0 3.1765 0 3.1415 /base_link /laser 100"/>
<node pkg="rviz" type="rviz" name="rviz"/>
</launch>
|
2016-04-28 04:12:58 -0500 | asked a question | Problem publishing from txt file to topic Hi I have a txt file with encoder data that looks like this: ...
1 277.87333332 269.94188565 2111.27302100 2111.27305200 2.40910042 0.58907051
1 277.88407118 269.94457012 2111.27810100 2111.27812500 2.33276239 0.58943359
1 277.89595953 269.94725459 2111.28316700 2111.28318600 2.33464865 0.57762184
1 277.90746439 269.94993905 2111.28825800 2111.28828900 2.32527232 0.56519989
1 277.91935274 269.95262352 2111.29334100 2111.29336900 2.30780781 0.54064191
1 277.93315857 269.95569148 2111.29842600 2111.29847000 2.36224113 0.54073054
1 277.94658090 269.95875944 2111.30351200 2111.30353700 2.38172210 0.55344243
1 277.96153721 269.96182740 2111.30858400 2111.30860500 2.42912526 0.56616211
1 277.97572653 269.96451187 2111.31365500 2111.31367500 2.46379925 0.56604012
1 277.98953236 269.96796333 2111.31872300 2111.31873900 2.50533659 0.59181053
...
I want to publish this data to an odometry publisher. In the original program a while loop is used for publishing the topics. I had to remove this loop to come back into my for loop, but now the /odom and /tf topic are not constantly published. What can I do to solve this? Afterwards I want to record the /tf topic, together with a sensordata topic (with the same timestamps). But the publishing of these topics is not equal with the timestamps, does de rosbag arrange the topics with help from the timestamps I set in the publisher (coming from the txt file). This is my code:
int main(int argc, char **argv)
{ ros::init(argc, argv, "odometry_from_text_publisher");
ros::NodeHandle n;
ros::Rate r(100.0);
//ros::Publisher odom_pub = n.advertise<nav_msgs::Odometry>("odom", 50);
//tf::TransformBroadcaster odom_broadcaster;
std::ifstream file("/home/bert/catkin_ws/src/mastering_ros_demo_pkg/src/WheelEncoders1.txt");
std::vector<int> data;
if(file.is_open())
{
for(int i=0;i<36747 && file.good() ;i++)
{
double index;
//Created a message
//mastering_ros_demo_pkg::angle_msg msg;
file >> index;
file >> angle_left;
file >> angle_right;
file >> angle_timestamp1;
file >> angle_timestamp2;
file >> index2;
file >> index3;
//Printing message data
//ROS_INFO("%f",index);
ROS_INFO("%f",angle_left);
ROS_INFO("%f",angle_right);
ROS_INFO("%f",angle_timestamp1);
//ROS_INFO("%f",msg.angle_timestamp2);
//ROS_INFO("%f",index2);
//ROS_INFO("%f",index3);
//ros::init(argc, argv, "odometry_from_text_publisher");
//ros::NodeHandle n;
//tijd van de meting
ros::Time current_time_encoder(angle_timestamp1);
//verschil in hoek tov vorige berekening
deltaLeft = angle_left - _PreviousLeftEncoderAngle;
deltaRight = angle_right - _PreviousRightEncoderAngle;
//snelheid links (x) en rechts (y)
vx = deltaLeft * DistancePerRadian / (current_time_encoder - last_time_encoder).toSec();
vy = deltaRight * DistancePerRadian / (current_time_encoder - last_time_encoder).toSec();
//als snelheid links = snelheid rechts -> snelheid = snelheid links en hoeksnelheid = 0
if(abs(vx-vy)<0.00001)
//if (vx == vy)
{
V = vx;
W = 0;
}
else
{
// Assuming the robot is rotating about point A
// W = vel_left/r = vel_right/(r + d), see the image below for r and d
double r = (vx * d) / (vy - vx); // Anti Clockwise is positive
W = vx/r; // Rotational velocity of the robot
V = W * (r + d/2); // Translation velocity of the robot
}
//vth = hoeksnelheid
vth= W;
//hoek onthouden
_PreviousLeftEncoderAngle = angle_left;
_PreviousRightEncoderAngle = angle_right;
//tijd van de laatste meting onthouden
last_time_encoder = current_time_encoder;
ros::Publisher odom_pub = n.advertise<nav_msgs ... (more) |
2016-04-28 03:47:19 -0500 | marked best answer | Integer to Ros::time Hi! I have a txt file with encoderdata and timestamps. I am reading from this file and want to put this timestamps in variables declared as Ros::time, but I cant manage to get this right. Is it possible to do this? The timestamp is coming from a msg like this. ros::Time current_time_encoder;
current_time_encoder = msg->angle_timestamp1;
|
2016-04-28 03:47:11 -0500 | received badge | ● Notable Question
(source)
|