-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Need surj input, but use micro-ros to control pumps between states of testing (only a certain group on at a time) such that it can have a custom message to control. I gave an example in lesson 4 of ros:
Now a lot of this code is c++ based and I haven’t explicitly covered it but theres something really important in ros2 messages. We can make enumerations or enums. I recommend you do your own research, but they are incredibly helpful tools to improve code readability. For example lets say the rover science module needed to have 5 different “states” while doing tests: extracting sample, doing spectrometer test, doing peptide detection test, coring sample, etc. instead of having 5 booleans in one message to communicate that we can use the fact that these might be exclusive commands and use the following message:
uint8 ROVER_SCIENCE_STATE_SAMPLE_EXTRACTION=0
uint8 ROVER_SCIENCE_STATE_SPECTROMETER=1
uint8 ROVER_SCIENCE_STATE_PEPTIDE_DETECTION=2
uint8 ROVER_SCIENCE_STATE_SAMPLE_CORING=3
uint8 rover_science_state
Then when programming in a node we might say
if msg.rover_science_state == msg.ROVER_SCIENCE_STATE_SPECTROMETER:
doSomething()
Metadata
Metadata
Assignees
Labels
No labels