Unable to publish cmd_vel topic from command line

I want to publish /cmd_vel topic from command line.

ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "linear: x: 0.1, y: 0.0, z: 0.0 angular: x: 0.0, y: 0.0, z: 0.0"

But it gives below error :

Traceback (most recent call last):
  File "/opt/ros/foxy/bin/ros2", line 11, in <module>
    load_entry_point('ros2cli==0.9.7', 'console_scripts', 'ros2')()
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main
    rc = extension.main(parser=parser, args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/command/topic.py", line 41, in main
    return extension.main(args=args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 93, in main
    return main(args)
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 103, in main
    return publisher(
  File "/opt/ros/foxy/lib/python3.8/site-packages/ros2topic/verb/pub.py", line 126, in publisher
    values_dictionary = yaml.safe_load(values)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 162, in safe_load
    return load(stream, SafeLoader)
  File "/usr/lib/python3/dist-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/lib/python3/dist-packages/yaml/constructor.py", line 49, in get_single_data
    node = self.get_single_node()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib/python3/dist-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib/python3/dist-packages/yaml/parser.py", line 428, in parse_block_mapping_key
    if self.check_token(KeyToken):
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 223, in fetch_more_tokens
    return self.fetch_value()
  File "/usr/lib/python3/dist-packages/yaml/scanner.py", line 577, in fetch_value
    raise ScannerError(None, None,
yaml.scanner.ScannerError: mapping values are not allowed here
  in "<unicode string>", line 1, column 10:
    linear: x: 0.1, y: 0.0, z: 0.0 angular: x ...

Hi!

The format of your message is not correct. Please see the example below and correct the format.

ros2 topic pub /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.1, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.0}}"

Thanks.
I am unable to use IDE.

user:~$ ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
[ERROR] [1641307386.765420998]: [registerPublisher] Failed to contact master at [2_simulation:11311].  Retrying...

In which unit of the course are you having this issue, and what part of the notes are you trying to complete?

Mini project 1 in Section 5.

Did you source the ROS2 .bashrc? Please ensure you follow all the instructions in the notebook and the chapters you have covered prior to this, so that you are executing things correctly.

Yes, I’ve followed instructions.
To launch ROS1 bridge, I am supposed to source ~/.bashrc_bridge right ?

user:~$ . ~/.bashrc_bridge && ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
ROS_DISTRO was set to 'noetic' before. Please make sure that the environment does not mix paths from different distributions.
ROS_DISTRO was set to 'foxy' before. Please make sure that the environment does not mix paths from different distributions.


[ERROR] [1641376514.383826190]: [registerPublisher] Failed to contact master at [3_simulation:11311].  Retrying...

Hi,

The error says that the master can’t be contacted. Have you launched the simulation? What do you see when you do the following commands?

source /opt/ros/noetic/setup.bash
rostopic list

To launch the ROS1 bridge you can run it with the following commands:

source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
user:~$ source /opt/ros/noetic/setup.bash
user:~$ rostopic list
ERROR: Unable to communicate with master!
user:~$
user:~$ source /opt/ros/noetic/setup.bash
user:~$ source /opt/ros/foxy/setup.bash
ROS_DISTRO was set to 'noetic' before. Please make sure that the environment does not mix paths from different distributions.

user:~$
user:~$ ros2 run ros1_bridge dynamic_bridge --bridge-all-topics
Package 'ros1_bridge' not found