2020-11-16 07:53:43 -0500 | received badge | ● Nice Question
(source)
|
2019-12-17 14:07:10 -0500 | received badge | ● Famous Question
(source)
|
2019-12-17 14:07:10 -0500 | received badge | ● Notable Question
(source)
|
2019-11-20 10:15:37 -0500 | received badge | ● Notable Question
(source)
|
2019-11-20 10:15:37 -0500 | received badge | ● Famous Question
(source)
|
2019-11-20 10:15:37 -0500 | received badge | ● Popular Question
(source)
|
2019-04-07 22:40:23 -0500 | marked best answer | Subscribe cmd_vel with Arduino Hello, I would want to send PWM signal with an arduino in order to control motors.
But, as a beginner, I am not exactly sure of what to do.
I need first to publish "cmd_vel". Then I need to write a node in Arduino which subscribe to "cmd_vel", right ? If so, I am not confident with the code I wrote : include "ros.h"
include "geometry_msgs/Twist.h"
ros::NodeHandle nh;
void velCallback(const geometry_msgs::Twist& vel) {
geometry_msgs::Twist new_vel = vel;
// HERE I WANT TO USE vel TO DEFINE PWM }
void setup() {
nh.initNode();
ros::Subscriber<geometry_msgs::Twist> ("cmd_vel", &velCallback);
}
void loop()
{
nh.spinOnce();
delay(1);
}
It is the right way to do ? And is that code correct ? PS : Sorry but I don't how to properly insert cpp code citation Regards, Matt |
2018-11-29 12:51:46 -0500 | received badge | ● Famous Question
(source)
|
2018-08-08 01:44:41 -0500 | marked best answer | Troubles with loginfo on Arduino Hello, I am working with a Raspberry Pi and an Arduino on ROS indigo.
I would want to add a loginfo message to my script. However, each time I add this line : if (voltageValue<3.6) {nh.loginfo("Low Voltage");} , my rosserial node displays the following message and then stops to work : [INFO] [WallTime: 1492093431.082536] Setup publisher on cell_voltage [std_msgs/Float32]
[INFO] [WallTime: 1492093431.087959] wrong checksum for topic id and msg
[WARN] [WallTime: 1492093431.112029] Serial Port read returned short (expected 78 bytes, received 73 instead).
[WARN] [WallTime: 1492093431.116379] Serial Port read failure:
[INFO] [WallTime: 1492093431.119876] Packet Failed : Failed to read msg data
[INFO] [WallTime: 1492093431.122835] msg len is 8
[INFO] [WallTime: 1492093431.147052] Setup publisher on cell_voltage [std_msgs/Float32]
[INFO] [WallTime: 1492093431.155512] wrong checksum for topic id and msg
[INFO] [WallTime: 1492093431.172463] Setup publisher on cell_voltage [std_msgs/Float32]
[INFO] [WallTime: 1492093431.179750] wrong checksum for topic id and msg
[INFO] [WallTime: 1492093431.200429] wrong checksum for topic id and msg
[ERROR] [WallTime: 1492093446.191686] Lost sync with device, restarting...
My Arduino script is #include <Timer.h>
#include <ros.h>
#include <std_msgs/Float32.h>
#include <geometry_msgs/Twist.h>
// voltage sensor
int sensorPin = A1;
int sensorValue = 0;
float voltageValue = 0;
Timer _timer_2(500), //2Hz
_timer_100(10); //100Hz
unsigned long temps = 0;
ros::NodeHandle nh;
//Def
std_msgs::Float32 float_msg;
std_msgs::Float32 float_msg_compas;
//Pub/sub
ros::Publisher pu("cell_voltage", &float_msg);
ros::Publisher compas("compas", &float_msg_compas);
ros::Subscriber<geometry_msgs::Twist> su("cmd_vel" , messageCb);
void setup() {
nh.getHardware()->setBaud(115200);
nh.initNode();
nh.advertise(pu);
nh.advertise(compas);
nh.subscribe(su);
temps = millis();
_timer_2.start((unsigned long) millis());
_timer_100.start((unsigned long) millis());
}
void messageCb( const geometry_msgs::Twist& vel)
{
float xx = vel.linear.x;
float zz = vel.angular.z;
if (xx>0.08){ nh.loginfo("AVANCE"); // THIS ONE IS WORKING
...}
}
void voltageCb(){
sensorValue = analogRead(sensorPin);
voltageValue = sensorValue * 5.0 /1023.0;
float_msg.data = voltageValue;
pu.publish( &float_msg );
if (voltageValue<3.6) {nh.loginfo("Low Voltage");} // THIS ONE NOT IS WORKING
delay(10);
}
void loop() {
if (_timer_100.delay(millis())){ nh.spinOnce();}
if (_timer_2.delay(millis())){ voltageCb(); }
}
Does anybody know how to fix this problem ? I suppose the problem comes from the lack of argument in voltageCb(). But I am not sure what shall be put inside this function ? Regards Matthieu |
2018-07-16 11:03:16 -0500 | received badge | ● Popular Question
(source)
|
2018-06-25 08:23:02 -0500 | received badge | ● Famous Question
(source)
|
2018-05-20 10:27:14 -0500 | received badge | ● Notable Question
(source)
|
2018-05-18 04:00:17 -0500 | received badge | ● Famous Question
(source)
|
2018-04-18 04:57:41 -0500 | asked a question | [Hector Mapping] Could not transform while tf being published [Hector Mapping] Could not transform while tf being published
Hello,
I am trying to set a basic launch file to create a |
2018-04-09 08:06:35 -0500 | received badge | ● Famous Question
(source)
|
2018-03-22 20:52:33 -0500 | received badge | ● Famous Question
(source)
|
2018-02-27 03:39:42 -0500 | commented answer | Custom message That's was not the point, as that it works both with and without std_msgs
thank you for your input
|
2018-02-27 03:38:28 -0500 | commented answer | Custom message You are right, It now works
Thanks for your comment
|
2018-02-27 03:37:20 -0500 | marked best answer | Custom message Hello, I have defined this custom message, FloatsStamped.msg : Header header
float32[] data
The CMakeLists.txt is: cmake_minimum_required(VERSION 2.8.3)
project(grideye)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
################################################
## Declare ROS messages, services and actions ##
################################################
## Generate messages in the 'msg' folder
add_message_files(
FILES
FloatsStamped.msg
)
## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)
###################################
## catkin specific configuration ##
###################################
catkin_package(
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
)
###########
## Build ##
###########
include_directories(
${catkin_INCLUDE_DIRS}
)
My package.xml is : <?xml version="1.0"?>
<package>
<name>grideye</name>
<version>0.0.0</version>
<description>The grideye package</description>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>message_generation</build_depend>
<run_depend>message_runtime</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>std_msgs</run_depend>
<build_depend>python-numpy</build_depend>
<run_depend>python-numpy</run_depend>
</package>
And finally the code I use is: #!/usr/bin/env python
import rospy
import numpy
from grideye.msg import FloatsStamped
from grideye_class import GridEye
def talker():
pub = rospy.Publisher('thermal_pixels', FloatsStamped, queue_size=10)
rospy.init_node('grideye', anonymous=True)
r = rospy.Rate(5)
pix = []
while not rospy.is_shutdown():
pix = mysensor.getPixels()
print(pix)
#feed a FloatsStamped msg
a = FloatsStamped
a.header.stamp = rospy.Time.now()
a.data = numpy.array(pix, dtype=numpy.float32)
pub.publish(a)
r.sleep()
if __name__ == '__main__':
mysensor = GridEye()
rospy.loginfo("Starting data retrieving from Grid Eye sensor Board")
talker()
I get an error message indicating that : a.header.stamp = rospy.Time.now() AttributeError: 'member_descriptor'
object has no attribute 'stamp' I declare a as FloatsStamped message and this message includes the Header message, so I don't understand why I get this error message. matt |
2018-02-27 00:51:11 -0500 | received badge | ● Notable Question
(source)
|
2018-02-25 08:39:54 -0500 | commented answer | how to increase rosserial buffer size Really clear, thank you for that explanation!
|
2018-02-25 07:20:02 -0500 | marked best answer | Publish LaserScan from Arduino Hello, I am using an arduino Mega to publish LaserScan message. But I have a weird result, when i run this code: #include <ros.h>
#include <sensor_msgs/LaserScan.h>
ros::NodeHandle nh;
// Laser Scan
sensor_msgs::LaserScan lidar_msg;
ros::Publisher lidar_pub("/laser_scan", &lidar_msg);
float ranges[10] = {0};
float intensities[10] = {0};
void setup()
{
// Initialize ROS node handle, advertise and subscribe the topics
nh.initNode();
nh.getHardware()->setBaud(57600);
nh.advertise(lidar_pub);
// Set LaserScan Definition
lidar_msg.header.frame_id = "lidar";
lidar_msg.angle_min = 0.0; // start angle of the scan [rad]
lidar_msg.angle_max = 3.14*2; // end angle of the scan [rad]
lidar_msg.angle_increment = 3.14*2/360; // angular distance between measurements [rad]
lidar_msg.range_min = 0.3; // minimum range value [m]
lidar_msg.range_max = 50.0; // maximum range value [m]
}
void loop(){
// simple loop to generate values
for (int i=0 ; i<10 ; ++i){
ranges[i] = 1.0*i;
}
lidar_msg.ranges = ranges;
lidar_msg.header.stamp = nh.now();
lidar_pub.publish(&lidar_msg);
nh.spinOnce();
}
Then, I launch rosserial node to start serial communication: $ rosrun rosserial_python serial_node.py /dev/ttyUSB2
[INFO] [1519508591.451838]: ROS Serial Python Node
[INFO] [1519508591.468653]: Connecting to /dev/ttyUSB2 at 57600 baud
[INFO] [1519508593.624826]: Note: publish buffer size is 512 bytes
[INFO] [1519508593.625218]: Setup publisher on /laser_scan [sensor_msgs/LaserScan]
But when, i echo the topic, I didn't get any values in ranges: ---
header:
seq: 112
stamp:
secs: 1519508602
nsecs: 77765016
frame_id: "lidar"
angle_min: 0.0
angle_max: 6.28000020981
angle_increment: 0.0174444448203
time_increment: 0.0
scan_time: 0.0
range_min: 0.300000011921
range_max: 50.0
ranges: []
intensities: []
---
Any idea ? matt |
2018-02-25 07:19:59 -0500 | commented answer | Publish LaserScan from Arduino ranges_length and intensities_length were the point !
Thanks you
|
2018-02-25 05:44:40 -0500 | received badge | ● Popular Question
(source)
|
2018-02-25 03:21:29 -0500 | received badge | ● Famous Question
(source)
|
2018-02-24 15:44:37 -0500 | asked a question | Publish LaserScan from Arduino Publish LaserScan from Arduino
Hello,
I am using an arduino Mega to publish LaserScan message. But I have a weird resul |
2018-02-24 05:03:21 -0500 | received badge | ● Notable Question
(source)
|
2018-02-23 06:28:30 -0500 | received badge | ● Popular Question
(source)
|
2018-02-22 16:30:40 -0500 | commented answer | Custom message Ok, I will give it a try on next week
|
2018-02-22 06:09:19 -0500 | asked a question | Custom message Custom message
Hello,
I have defined this custom message, FloatsStamped.msg :
Header header
float32[] data
The CMak |
2018-02-12 00:51:30 -0500 | received badge | ● Popular Question
(source)
|
2018-01-11 06:26:24 -0500 | commented question | Inconsistent localization in gmapping Yes in fact, running also fake node created conflicts in publishing map->base_link transform.
Now i don't run fake_no |
2018-01-11 02:12:39 -0500 | asked a question | Inconsistent localization in gmapping Inconsistent localization in gmapping
Hello,
I am trying to map the turtlebot3.world as explain in wiki. Thus i run thi |
2017-10-16 17:28:01 -0500 | marked best answer | What arguments for rospy.ServiceProxy ? Hello, I would want to call a service using python. Currently this command line is working : rosservice call /camera/start_capture
but I can't figure out how to do the same thing with python. I already tried this without succes : rospy.ServiceProxy('/camera/start_capture',True)
Any idea ? Matt |
2017-10-06 13:53:45 -0500 | received badge | ● Notable Question
(source)
|
2017-10-06 13:53:45 -0500 | received badge | ● Famous Question
(source)
|
2017-09-06 09:54:00 -0500 | received badge | ● Famous Question
(source)
|
2017-09-06 05:13:28 -0500 | received badge | ● Popular Question
(source)
|
2017-09-06 05:13:28 -0500 | received badge | ● Notable Question
(source)
|
2017-09-06 05:13:28 -0500 | received badge | ● Famous Question
(source)
|
2017-08-28 02:30:10 -0500 | received badge | ● Famous Question
(source)
|
2017-08-28 02:30:10 -0500 | received badge | ● Notable Question
(source)
|