How to run ros noetic in ubuntu vm (Notes only | unfinished)

How to run ros noetic in ubuntu vm (Notes only | unfinished)
sudo apt-get install ros-noetic-rviz


source /opt/ros/noetic/setup.bash
roscore &
rosrun rviz rviz

https://www.arduino.cc/en/guide/linux#toc2
fix: `Permission denied on /dev/ttyACM0`

sudo chmod a+rw /dev/ttyACM0


roscore
rosrun rosserial_python serial_node.py /dev/ttyACM0
<!-- rostopic pub toggle_led std_msgs/Empty --once -->


rostopic pub toggle_led std_msgs/Float32 6.1 --once

[ROS/Tutorials/UnderstandingTopics - ROS Wiki](http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics)
rosrun turtlesim turtlesim_node

rosrun turtlesim turtle_teleop_key
sudo apt-get install ros-noetic-rqt
sudo apt-get install ros-noetic-rqt-common-plugins
rosrun rqt_graph rqt_graph

rostopic -h
rostopic bw     display bandwidth used by topic
rostopic echo   print messages to screen
rostopic hz     display publishing rate of topic    
rostopic list   print information about active topics
rostopic pub    publish data to topic
rostopic type   print topic type

rostopic list -h
rostopic list -v
rostopic type [topic]
rostopic type /turtle1/cmd_vel

-----------
You should get:
geometry_msgs/Twist

------

rosmsg show geometry_msgs/Twist

Using rostopic pub

rostopic pub [topic] [msg_type] [args]

rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'

-1 = This option (dash-one) causes rostopic to only publish one message then exit:

-- = This option (double-dash) tells the option parser that none of the following arguments is an option. This is required in cases where your arguments have a leading dash -, like negative numbers.

'[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]' = These arguments are actually in YAML syntax, which is described more in the YAML command line documentation.
YAML command line documentation.

How to run a rosserial servo motor

without a custom node for testing

/*
 * Controlling ros arduino node to control 2 servo motors
 * by oran collins
 * github.com/wisehackermonkey
 * [email protected]
 * 20210224
 * This sketch demonstrates the control of hobby R/C servos
 * using ROS and the arduiono
 * 
 * For the full tutorial write up, visit
 * www.ros.org/wiki/rosserial_arduino_demos
 *
 * For more information on the Arduino Servo Library
 * Checkout :
 * http://www.arduino.cc/en/Reference/Servo
 */

#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
#endif

#include <Servo.h> 
#include <ros.h>
#include <std_msgs/Float32.h>
#include <std_msgs/String.h>

String HEAD_SEND_TOPIC = "debug_head_position";
String HEAD_RECEIVE_TOPIC = "head_servo_position";

ros::NodeHandle  nh;

std_msgs::String debug_message;

Servo servo;

void servo_cb( const std_msgs::Float32& cmd_msg){
  servo.write(cmd_msg.data); //set servo angle, should be from 0-180  
  digitalWrite(13, HIGH-digitalRead(13));  //toggle led  
}



ros::Subscriber<std_msgs::Float32> sub("head_servo_position", servo_cb);
// allow sending data back to computer for debugging purposes on ros topic "head_debug"
ros::Publisher debug_position("head_servo_position", &debug_message);

void setup(){
  Serial.begin(115200);
  pinMode(13, OUTPUT);

  nh.initNode();
  nh.subscribe(sub);
//  nh.advertise(debug_message);

  Serial.println("Setarting Ros Node Servo Control");
//  debug_message.data = "Works!";
  servo.attach(9); //attach it to pin 9
}

void loop(){
  
  debug_position.publish(&debug_message);
  nh.spinOnce();
  delay(1);
}

terminal 1

ls -hal /dev/ttyA*
get the output ting /dev/ttyA
rosrun rosserial_python serial_node.py /dev/ttyACM0

terminal 2

rostopic pub servo std_msgs/UInt16 180
rostopic pub servo std_msgs/UInt16 0

(young frankinstine voice) ITS ALIVE!

Links

rosserial_arduino/Tutorials - ROS Wiki
ROS/Tutorials/UnderstandingTopics - ROS Wiki
If you want to help me out and give some donations here's my monero address: 432ZNGoNLjTXZHz7UCJ8HLQQsRGDHXRRVLJi5yoqu719Mp31x4EQWKaQ9DCQ5p2FvjQ8mJSQHbD9WVmFNhctJsjkLVHpDEZ I use a tracker that is pravicy focused so if you block its cool, im big on blocking stuff on my own machine. im doing it to see if anyone is actualy reading my blog posts...:)