Hardware Reference
In-Depth Information
In this example, we've defined a motor as a “joint,” which makes sense in the context
of a LEGO Mindstorms robot. The motor turns, and it makes the robot flex at that
point. Because we've added a joint, we also need to tell ROS to aggregate the joint
states in our robot.launch file. Edit that file so that it now looks like this:
<launch>
<node pkg="nxt_ros" type="nxt_ros.py" name="nxt_ros" output="screen" re
spawn="true">
<rosparam command="load" file="$(find my_nxt_robot)/robot.yaml" />
</node>
<node pkg="nxt_ros" type="joint_states_aggregator.py"
name="joint_state_publisher" output="screen" />
</launch>
By adding sensors and output motors, you have the building blocks of an ROS robot.
The ROS framework is incredibly powerful, but also very complicated.
Unfortunately, going into details on building more complicated robots in ROS would
be a whole topic unto itself! In fact, there has been at least one published so far. There
is a lot of documentation on how to use ROS , and the ROS community is generally very
helpful to newcomers, which will help you get to the next step of the robot of your
imagination.
Just Python, Please
ROS is very cool, but if you just want to build a simple Mindstorms robot, you can use
a set of NXT Python bindings without the complexity of ROS.
Raspbian has a python-nxt package that you can install via apt-get :
$ sudo apt-get install python-nxt
This code is similar to the ROS nxt_python component, but it is much newer and does
not depend on ROS. The python-nxt component includes a simple sensors test case.
Connect a touch sensor to Port 1, a sound sensor to Port 2, a light sensor to Port 3,
and an ultrasonic sensor to Port 4. Then run the test code (as root):
$ sudo python /usr/share/doc/python-nxt/examples/test_sensors.py
Touch: False
Sound: 0
Light: 0
Ultrasonic: 22
Search WWH ::




Custom Search